Example #1
0
 public function testGetBundles()
 {
     $fatCatMockBundle = new MickadooBaseDataBundle();
     $reflection = new \ReflectionClass($fatCatMockBundle);
     $reflection_property = $reflection->getProperty('name');
     $reflection_property->setAccessible(true);
     $reflection_property->setValue($fatCatMockBundle, 'FatCatMockBundle');
     $flyingPigBundle = new MickadooBaseDataBundle();
     $reflection = new \ReflectionClass($flyingPigBundle);
     $reflection_property = $reflection->getProperty('name');
     $reflection_property->setAccessible(true);
     $reflection_property->setValue($flyingPigBundle, 'FlyingPigBundle');
     $mockBundles = [$fatCatMockBundle, $flyingPigBundle];
     /** @var AppKernel|\PHPUnit_Framework_MockObject_MockObject $mockKernel */
     $mockKernel = $this->getMockBuilder(AppKernel::class)->disableOriginalConstructor()->getMock();
     $mockKernel->expects($this->any())->method('getBundles')->willReturn($mockBundles);
     $bundleHelper = new BundleHelper($mockKernel);
     $this->assertEquals([$fatCatMockBundle, $flyingPigBundle], $bundleHelper->getBundles());
     $this->assertEquals([$fatCatMockBundle], $bundleHelper->getBundles('FatCat'));
 }
 /**
  * @return array
  */
 private function getConfigFiles()
 {
     $configFiles = [];
     $bundles = $this->bundleHelper->getBundles($this->input->getArgument('namespace'));
     foreach ($bundles as $bundle) {
         $configPath = $bundle->getPath() . self::PATH_IN_BUNDLE;
         if (file_exists($configPath)) {
             $loadedConfigFiles = glob($configPath . '*' . self::CONFIG_PATH_SUFFIX);
             $configFiles = array_merge($loadedConfigFiles, $configFiles);
         }
     }
     return $configFiles;
 }