/**
  * @test
  */
 public function load_class_loads_metadata_correctly()
 {
     $reflClass = new \ReflectionClass('Kcs\\Metadata\\Tests\\Fixtures\\AnnotationProcessorLoader\\SimpleObject');
     $metadata = new ClassMetadata($reflClass);
     $this->reader->getClassAnnotations($reflClass)->willReturn([new ClassAnnot(), new NotHandledAnnotation()]);
     $this->reader->getMethodAnnotations($reflClass->getMethod('getAuthor'))->willReturn([new NotHandledAnnotation(), new MethodAnnotation1(), new MethodAnnotation2()]);
     $this->reader->getPropertyAnnotations($reflClass->getProperty('createdAt'))->willReturn([new NotHandledAnnotation()]);
     $this->reader->getPropertyAnnotations($reflClass->getProperty('author'))->willReturn([]);
     $this->processorFactory->getProcessor(Argument::type('Kcs\\Metadata\\Tests\\Fixtures\\AnnotationProcessorLoader\\Annotation\\NotHandledAnnotation'))->willReturn();
     $classAnnotationProcessor = $this->prophesize('Kcs\\Metadata\\Loader\\Processor\\ProcessorInterface');
     $classAnnotationProcessor->process(Argument::type('Kcs\\Metadata\\MetadataInterface'), Argument::type('Kcs\\Metadata\\Tests\\Fixtures\\AnnotationProcessorLoader\\Annotation\\ClassAnnot'))->shouldBeCalledTimes(1);
     $this->processorFactory->getProcessor(Argument::type('Kcs\\Metadata\\Tests\\Fixtures\\AnnotationProcessorLoader\\Annotation\\ClassAnnot'))->willReturn($classAnnotationProcessor->reveal());
     $methodAnnotationProcessor = $this->prophesize('Kcs\\Metadata\\Loader\\Processor\\ProcessorInterface');
     $methodAnnotationProcessor->process(Argument::type('Kcs\\Metadata\\MetadataInterface'), Argument::type('Kcs\\Metadata\\Tests\\Fixtures\\AnnotationProcessorLoader\\Annotation\\MethodAnnotation1'))->shouldBeCalledTimes(1);
     $methodAnnotationProcessor->process(Argument::type('Kcs\\Metadata\\MetadataInterface'), Argument::type('Kcs\\Metadata\\Tests\\Fixtures\\AnnotationProcessorLoader\\Annotation\\MethodAnnotation2'))->shouldBeCalledTimes(1);
     $this->processorFactory->getProcessor(Argument::type('Kcs\\Metadata\\Tests\\Fixtures\\AnnotationProcessorLoader\\Annotation\\MethodAnnotation1'))->willReturn($methodAnnotationProcessor->reveal());
     $this->processorFactory->getProcessor(Argument::type('Kcs\\Metadata\\Tests\\Fixtures\\AnnotationProcessorLoader\\Annotation\\MethodAnnotation2'))->willReturn($methodAnnotationProcessor->reveal());
     $this->loader->loadClassMetadata($metadata);
 }
Ejemplo n.º 2
0
 /**
  * Call processors
  *
  * @param MetadataInterface $metadata
  * @param array $descriptors
  */
 private function doLoadFromDescriptors(MetadataInterface $metadata, array $descriptors)
 {
     foreach ($descriptors as $descriptor) {
         $processor = $this->processorFactory->getProcessor($descriptor);
         if (null === $processor) {
             continue;
         }
         $processor->process($metadata, $descriptor);
     }
 }