/**
  * Test ModuleRefreshCommand
  */
 public function testModuleRefreshCommand()
 {
     $moduleManagement = new ModuleManagement();
     $moduleManagement->updateModules();
     $module = ModuleQuery::create()->filterByType(1)->orderByPosition(Criteria::DESC)->findOne();
     if ($module !== null) {
         $module->delete();
         $application = new Application($this->getKernel());
         $moduleRefresh = new ModuleRefreshCommand();
         $moduleRefresh->setContainer($this->getContainer());
         $application->add($moduleRefresh);
         $command = $application->find('module:refresh');
         $commandTester = new CommandTester($command);
         $commandTester->execute(['command' => $command->getName()]);
         $expected = $module;
         $actual = ModuleQuery::create()->filterByType(1)->orderByPosition(Criteria::DESC)->findOne();
         $this->assertEquals($expected->getCode(), $actual->getCode(), 'Last standard module code must be same after deleting this one and calling module:refresh');
         $this->assertEquals($expected->getType(), $actual->getType(), 'Last standard module type must be same after deleting this one and calling module:refresh');
         $this->assertEquals($expected->getFullNamespace(), $actual->getFullNamespace(), 'Last standard module namespace must be same after deleting this one and calling module:refresh');
         // Restore activation status
         $actual->setActivate($expected->getActivate())->save();
     } else {
         $this->markTestIncomplete('This test cannot be complete without at least one standard module.');
     }
 }
 public function setUp()
 {
     $application = new Application($this->getKernel());
     $moduleGenerator = new ModuleGenerateCommand();
     $application->add($moduleGenerator);
     $this->command = $application->find("module:generate");
     $this->commandTester = new CommandTester($this->command);
 }
 public function setUp()
 {
     if (null === $this->commandTester) {
         $application = new Application($this->getKernel());
         $configCommand = new ConfigCommand();
         $application->add($configCommand);
         $this->command = $application->find("thelia:config");
         $this->commandTester = new CommandTester($this->command);
     }
 }
 public function testCommand()
 {
     $application = new Application($this->getKernel());
     $checkCommand = new SaleCheckActivationCommand();
     $checkCommand->setContainer($this->getContainer());
     $application->add($checkCommand);
     $command = $application->find("sale:check-activation");
     $commandTester = new CommandTester($command);
     $commandTester->execute(["command" => $command->getName(), "--env" => "test"]);
     $deactivatedSale = SaleQuery::create()->findPk(self::$deactivated);
     $this->assertTrue($deactivatedSale->getActive(), "the sale must be actived now");
     $activatedSale = SaleQuery::create()->findPk(self::$activated);
     $this->assertFalse($activatedSale->getActive(), "the sale must be deactived now");
 }
 /**
  * @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;
     }
 }
示例#6
0
 /**
  * @expectedException \RuntimeException
  */
 public function testCacheClearWithoutWritePermission()
 {
     // Fails on windows - mock this test on windows
     if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
         $fs = new Filesystem();
         $fs->chmod($this->cache_dir, 0100);
         $application = new Application($this->getKernel());
         $cacheClear = new CacheClear();
         $cacheClear->setContainer($this->getContainer());
         $application->add($cacheClear);
         $command = $application->find("cache:clear");
         $commandTester = new CommandTester($command);
         $commandTester->execute(array("command" => $command->getName(), "--env" => "test"));
     } else {
         throw new \RuntimeException("");
     }
 }