assertEqual($finder->get($reflection), '/** class doccomment */'); } public function testFinderFindsFieldDocBlock() { $reflection = new ReflectionClass('SomeClass'); $property = $reflection->getProperty('field1'); $finder = new DocComment(); $this->assertEqual($finder->get($property), '/** field doccomment */'); $property = $reflection->getProperty('field2'); $finder = new DocComment(); $this->assertFalse($finder->get($property)); } public function testFinderFindsMethodDocBlock() { $reflection = new ReflectionClass('SomeClass'); $method = $reflection->getMethod('method1'); $finder = new DocComment(); $this->assertEqual($finder->get($method), '/** method1 doccomment */'); $method = $reflection->getMethod('method2'); $finder = new DocComment(); $this->assertFalse($finder->get($method)); } public function testMisplacedDocCommentDoesNotCausesDisaster() { $reflection = new ReflectionClass('SomeOtherClass'); $finder = new DocComment(); $this->assertEqual($finder->get($reflection), false); } public function testUnanotatedClassCanHaveAnotatedField() { $reflection = new ReflectionClass('SomeOtherClass'); $property = $reflection->getProperty('field1'); $finder = new DocComment(); $this->assertEqual($finder->get($property), '/** field doccomment */'); } public function testParserIsOnlyCalledOncePerFile() { $reflection = new ReflectionClass('SomeClass'); $finder = new MockDocComment(); $finder->expectOnce('parse'); $this->assertEqual($finder->get($reflection), false); $this->assertEqual($finder->get($reflection), false); $reflection = new ReflectionClass('SomeClass'); $finder = new MockDocComment(); $finder->expectNever('parse'); $this->assertEqual($finder->get($reflection), false); } } ?>