Advertisement
Guest User

Giorgio Sironi

a guest
Sep 28th, 2009
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.45 KB | None | 0 0
  1. <?php
  2.  
  3. class AnnotationsTest extends PHPUNit_Framework_TestCase
  4. {
  5.     public function testMethodRaiseException()
  6.     {
  7.         try {
  8.             $iterator = new ArrayIterator(42);
  9.             $this->fail();
  10.         } catch (InvalidArgumentException $e) {
  11.         }
  12.     }
  13.  
  14.     /**
  15.      * @expectedException InvalidArgumentException
  16.      */
  17.     public function testMethodRaiseExceptionAgain()
  18.     {
  19.         $iterator = new ArrayIterator(42);
  20.     }
  21.  
  22.     public function testBooleanEvaluationInALoop()
  23.     {
  24.         $values = array(1, '1', 'on', true);
  25.         foreach ($values as $value) {
  26.             $actual = (bool) $value;
  27.             $this->assertTrue($actual);
  28.         }
  29.     }
  30.  
  31.     public static function trueValues()
  32.     {
  33.         return array(
  34.             array(1),
  35.             array('1'),
  36.             array('on'),
  37.             array(true)
  38.         );
  39.     }
  40.     /**
  41.      * @dataProvider trueValues
  42.      */
  43.     public function testBooleanEvaluation($value)
  44.     {
  45.         $actual = (bool) $value;
  46.         $this->assertTrue($actual);
  47.     }
  48.  
  49.     public function testArrayAdditionWorks()
  50.     {
  51.         $array = array();
  52.         $array[0] = 'foo';
  53.         $this->assertTrue(isset($array[0]));
  54.         return $array;
  55.     }
  56.  
  57.     /**
  58.      * @depends testArrayAdditionWorks
  59.      */
  60.     public function testArrayRemovalWorks($fixture)
  61.     {
  62.         unset($fixture[0]);
  63.         $this->assertFalse(isset($fixture[0]));
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement