/**
  * @dataProvider addsDependenciesProvider
  */
 public function testAddsDependencies(array $packages, array $expected_required_packages = [], array $expected_dependent_packages = [])
 {
     $mock = self::createMock('Hostnet\\Component\\EntityPlugin\\PackagePathResolverInterface');
     $mock->expects($this->any())->method('getSourcePath')->will($this->returnValue(__DIR__));
     $builder = new EntityPackageBuilder($mock, $packages);
     $entity_packages = $builder->getEntityPackages();
     foreach ($expected_required_packages as $package_name => $required_packages) {
         $actual_required = [];
         foreach ($entity_packages[$package_name]->getRequiredPackages() as $requirement) {
             $this->assertInstanceOf('Hostnet\\Component\\EntityPlugin\\EntityPackage', $requirement);
             $actual_required[] = $requirement->getPackage();
         }
         $this->assertEquals($required_packages, $actual_required);
     }
     foreach ($expected_dependent_packages as $package_name => $dependent_packages) {
         $actual_dependant = [];
         foreach ($entity_packages[$package_name]->getDependentPackages() as $dep) {
             $this->assertInstanceOf('Hostnet\\Component\\EntityPlugin\\EntityPackage', $dep);
             $actual_dependant[] = $dep->getPackage();
         }
         $this->assertEquals($dependent_packages, $actual_dependant);
     }
 }
Esempio n. 2
0
 /**
  * Ensure all interfaces and traits are filled with correct methods
  *
  * @param EntityPackageBuilder $graph
  */
 private function generateConcreteIndividualCode(EntityPackageBuilder $graph)
 {
     foreach ($graph->getEntityPackages() as $entity_package) {
         /* @var $entity_package EntityPackage */
         $this->writeIfVerbose('    - Generating for package <info>' . $entity_package->getPackage()->getName() . '</info>');
         foreach ($entity_package->getEntityContent()->getClasses() as $entity) {
             $this->writeIfVeryVerbose('        - Generating interface for <info>' . $entity->getName() . '</info>');
             $this->reflection_generator->generate($entity);
         }
     }
 }