コード例 #1
0
 public function testIteratorInterface()
 {
     $iterator = new cfhCompile_ClassIterator_Manual();
     $iterator->attach(new cfhCompile_Class_Reflection('cfhCompile_ClassIterator_ManualTest'));
     $iterator->attach(new cfhCompile_Class_Reflection('PHPUnit_Framework_TestCase'));
     $iterator->attach(new cfhCompile_Class_Reflection('cfhCompile_ClassIterator_Manual'));
     $iterator->attach(new cfhCompile_Class_Reflection('cfhCompile_Class_Reflection'));
     $iterator->rewind();
     $this->assertTrue($iterator->valid());
     $this->assertEquals('cfhCompile_ClassIterator_ManualTest', $iterator->key());
     $this->assertEquals('cfhCompile_ClassIterator_ManualTest', $iterator->current()->getName());
     $iterator->next();
     $this->assertTrue($iterator->valid());
     $this->assertEquals('PHPUnit_Framework_TestCase', $iterator->key());
     $this->assertEquals('PHPUnit_Framework_TestCase', $iterator->current()->getName());
     $iterator->next();
     $this->assertTrue($iterator->valid());
     $this->assertEquals('cfhCompile_ClassIterator_Manual', $iterator->key());
     $this->assertEquals('cfhCompile_ClassIterator_Manual', $iterator->current()->getName());
     $iterator->next();
     $this->assertTrue($iterator->valid());
     $this->assertEquals('cfhCompile_Class_Reflection', $iterator->key());
     $this->assertEquals('cfhCompile_Class_Reflection', $iterator->current()->getName());
     $iterator->next();
     $this->assertFalse($iterator->valid());
     $this->assertNull($iterator->key());
     $this->assertNull($iterator->current());
 }
コード例 #2
0
 public function testDuplicateClassNameThrowsException()
 {
     $i = new cfhCompile_ClassIterator_Manual();
     $i->attach(new cfhCompile_Class_Reflection($this));
     $i->attach(new cfhCompile_Class_Reflection($this));
     $c = new cfhCompile_Compiler();
     $c->setCodeReader(new cfhCompile_CodeReader());
     $c->setCodeWriter($this->getMock('cfhCompile_CodeWriter_WriteStrategy_Interface'));
     $c->setClassIterator($i);
     try {
         $c->compile();
     } catch (cfhCompile_ClassRegistry_Exception $e) {
         return;
     }
     $this->fail('Expecting to catch cfhCompile_ClassRegistry_Exception.');
 }