*/ class ModuleActivateCommandTest extends ContainerAwareTestCase { public function testModuleActivateCommand() { $module = ModuleQuery::create()->findOne(); if (null !== $module) { $prev_activation_status = $module->getActivate(); $application = new Application($this->getKernel()); $module->setActivate(BaseModule::IS_NOT_ACTIVATED); $module->save(); $moduleActivate = new ModuleActivateCommand(); $moduleActivate->setContainer($this->getContainer()); $application->add($moduleActivate); $command = $application->find("module:activate"); $commandTester = new CommandTester($command); $commandTester->execute(array( "command" => $command->getName(), "module" => $module->getCode(), )); $activated = ModuleQuery::create()->findPk($module->getId())->getActivate(); // Restore activation status $module->setActivate($prev_activation_status)->save(); $this->assertEquals(BaseModule::IS_ACTIVATED, $activated); } } /** * @expectedException \RuntimeException * @expectedExceptionMessage module Letshopethismoduledoesnotexists not found */ public function testModuleActivateCommandUnknownModule() { $testedModule = ModuleQuery::create()->findOneByCode('Letshopethismoduledoesnotexists'); if (null == $testedModule) { $application = new Application($this->getKernel()); $moduleActivate = new ModuleActivateCommand(); $moduleActivate->setContainer($this->getContainer()); $application->add($moduleActivate); $command = $application->find("module:activate"); $commandTester = new CommandTester($command); $commandTester->execute(array( "command" => $command->getName(), "module" => "letshopethismoduledoesnotexists", )); $out = true; } } /** * Use this method to build the container with the services that you need. * @param ContainerBuilder $container */ protected function buildContainer(ContainerBuilder $container) { $eventDispatcher = new EventDispatcher(); $eventDispatcher->addSubscriber(new Module($container, $eventDispatcher)); $container->set("event_dispatcher", $eventDispatcher); $container->setParameter('kernel.cache_dir', THELIA_CACHE_DIR . 'dev'); } }