Пример #1
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $excludeBundles = $input->getOption('exclude');
     if (!empty($excludeBundles)) {
         /** @var ContainerProxy $containerProxy */
         $containerProxy = $this->getContainer();
         $kernelProxy = new KernelProxy($containerProxy->get('kernel'));
         foreach ($excludeBundles as $bundleName) {
             $kernelProxy->excludeBundle($bundleName);
         }
         $containerProxy->replace('kernel', $kernelProxy);
     }
     parent::execute($input, $output);
 }
Пример #2
0
 public function testExclude()
 {
     $bundle1 = $this->getMock('Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface');
     $bundle1->expects($this->any())->method('getName')->will($this->returnValue('bundle1'));
     $bundle2 = $this->getMock('Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface');
     $bundle2->expects($this->any())->method('getName')->will($this->returnValue('bundle2'));
     $this->target->expects($this->any())->method('getBundles')->will($this->returnValue([$bundle1, $bundle2]));
     $this->target->expects($this->any())->method('getBundle')->with('bundle2')->will($this->returnValue($bundle2));
     $this->assertEquals([$bundle1, $bundle2], $this->proxy->getBundles());
     $this->assertEquals($bundle2, $this->proxy->getBundle('bundle2'));
     $this->proxy->excludeBundle('bundle2');
     $this->assertEquals([$bundle1], $this->proxy->getBundles());
     $this->setExpectedException('\\InvalidArgumentException', 'Bundle "bundle2" is in exclude list.');
     $this->proxy->getBundle('bundle2');
 }