Guest User

Untitled

a guest
Sep 18th, 2013
54
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($setter, $getter, $a)
  8.         {
  9.         if(!is_int($a) || $a < 0 || is_string($a)){
  10.             $this->setExpectedException('\Exception');
  11.         }
  12.        
  13.         $val = $this->model->{$setter}($a);
  14.         $this->assertEquals(true, $this->model->{$getter}());
  15.     }
  16.  
  17.     public function myProvider(){
  18.         return array(
  19.             array('setterA', 'getterA', 1),
  20.             array('setterB', 'getterB', 1.1),
  21.             array('setterC', 'getterC', 'a'),
  22.             array('setterD', 'getterD', -23)
  23.         );
  24.     }
  25. }
  26.  
  27. ?>
RAW Paste Data