Advertisement
Guest User

Untitled

a guest
Sep 18th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class TestMyModel extends PHPUnit_Framework_TestCase{
  4.     /**
  5.         * @dataProvider myProvider
  6.         */
  7.     public function testMyFunctionOnlyAcceptsPositiveIntegers($a){
  8.         if(!is_int($a) || $a < 0 || is_string($a)){
  9.             $this->setExpectedException('\Exception');
  10.         }
  11.        
  12.         $val = $this->model->myFunction($a);
  13.         $this->assertEquals(true, $val);
  14.     }
  15.  
  16.     public function myProvider(){
  17.         return array(
  18.             array(1),
  19.             array(1.1),
  20.             array('a'),
  21.             array(-23)
  22.         );
  23.     }
  24. }
  25.  
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement