/** * Test for the fix for issue #41 */ public function testCompilerLeftOverDocblock() { $mockConfigProvider = m::mock('\\Weasel\\Annotation\\AnnotationConfigProvider'); $mockConfigProvider->shouldReceive('get')->with('\\HelloWorld')->andReturn(new Annotation('\\stdClass', array(), 1)); require __DIR__ . '/resources/AnnotatedClass.php'; $reader = new AnnotationReader(new \ReflectionClass('\\Weasel_Annotation_TestResources_AnnotatedClass'), $mockConfigProvider); $read = $reader->getClassAnnotations(); // Ordering is important. We need to require the NoDocBlock file immediately to ensure that the last thing // parsed was the AnnotatedClass require __DIR__ . '/resources/NoDocBlock.php'; $this->assertNotEmpty($read); $reader = new AnnotationReader(new \ReflectionClass('\\Weasel_Annotation_TestResources_NoDocBlock'), $mockConfigProvider); $this->assertEmpty($reader->getClassAnnotations()); }
/** * @covers \Weasel\JsonMarshaller\Config\Annotations\JsonCreator */ public function testParseClassAnnotations() { $annotationReader = new AnnotationReader(new \ReflectionClass('\\Weasel\\JsonMarshaller\\Config\\Annotations\\JsonCreator'), new AnnotationConfigurator()); $expected = array('\\Weasel\\Annotation\\Config\\Annotations\\Annotation' => array(new \Weasel\Annotation\Config\Annotations\Annotation(array("method"), 1))); $this->assertEquals($expected, $annotationReader->getClassAnnotations()); }