Example #1
0
 protected function setUp()
 {
     $this->moduleContainer = new ModuleContainer(Stub::make('Codeception\\Lib\\Di'), []);
     $this->moduleContainer->create('EmulateModuleHelper');
     $this->modules = $this->moduleContainer->all();
     $this->actions = $this->moduleContainer->getActions();
     $this->makeCommand('\\Codeception\\Command\\GenerateScenarios');
     $this->config = array('paths' => array('tests' => 'tests/data/claypit/tests/', 'data' => '_data'), 'class_name' => 'DumbGuy', 'path' => 'tests/data/claypit/tests/dummy/');
 }
Example #2
0
 /**
  * @group core
  */
 public function testRunStep()
 {
     $assertions =& $this->moduleContainer->getModule('EmulateModuleHelper')->assertions;
     $step = new \Codeception\Step\Action('seeEquals', array(5, 5));
     $this->testcase->runStep($step);
     $this->assertEquals(1, $assertions);
     $step = new \Codeception\Step\Action('seeEquals', array(5, 6));
     try {
         $this->testcase->runStep($step);
     } catch (Exception $e) {
         $this->assertInstanceOf('PHPUnit_Framework_ExpectationFailedException', $e);
     }
     $this->assertEquals(1, $assertions);
 }
Example #3
0
 public function testShortConfigDependencies()
 {
     $config = ['modules' => ['enabled' => [['Codeception\\Lib\\DependencyModule' => ['depends' => 'Codeception\\Lib\\ConflictedModule']]]]];
     $this->moduleContainer = new ModuleContainer(Stub::make('Codeception\\Lib\\Di'), $config);
     $this->moduleContainer->create('Codeception\\Lib\\DependencyModule');
     $this->moduleContainer->hasModule('\\Codeception\\Lib\\DependencyModule');
 }
Example #4
0
 protected function getModule($name)
 {
     if (!$this->hasModule($name)) {
         throw new Exception\ModuleException(__CLASS__, "Module {$name} couldn't be connected");
     }
     return $this->moduleContainer->getModule($name);
 }
 public function testInjectModuleIntoHelper()
 {
     $config = ['modules' => ['enabled' => ['Codeception\\Lib\\HelperModule']]];
     $this->moduleContainer = new ModuleContainer(Stub::make('Codeception\\Lib\\Di'), $config);
     $this->moduleContainer->create('Codeception\\Lib\\HelperModule');
     $this->moduleContainer->hasModule('Codeception\\Lib\\HelperModule');
 }
Example #6
0
 /**
  * @param $t
  * @throws Exception\InjectionException
  */
 protected function configureTest($t)
 {
     if (!$t instanceof TestInterface) {
         return;
     }
     $t->getMetadata()->setServices(['di' => clone $this->di, 'dispatcher' => $this->dispatcher, 'modules' => $this->moduleContainer]);
     $t->getMetadata()->setCurrent(['actor' => $this->getActor(), 'env' => $this->env, 'modules' => $this->moduleContainer->all()]);
 }
Example #7
0
 protected function _before()
 {
     $this->moduleContainer = $this->prophesize('Codeception\\Lib\\ModuleContainer');
     $this->moduleContainer->hasModule('WPLoader')->willReturn(true);
     $this->moduleContainer->hasModule('WPBootstrapper')->willReturn(true);
     $this->constants = $this->prophesize('tad\\WPBrowser\\Environment\\Constants');
     $this->wpdb = (object) ['queries' => []];
 }
Example #8
0
 protected function createSuite($name)
 {
     $suite = new Lib\Suite();
     $suite->setBaseName($this->env ? substr($name, 0, strpos($name, '-' . $this->env)) : $name);
     if ($this->settings['namespace']) {
         $name = $this->settings['namespace'] . ".{$name}";
     }
     $suite->setName($name);
     $suite->setModules($this->moduleContainer->all());
     return $suite;
 }
 protected function createSuite($name)
 {
     $suite = new Lib\Suite();
     $suite->setBaseName(preg_replace('~\\s.+$~', '', $name));
     // replace everything after space (env name)
     if ($this->settings['namespace']) {
         $name = $this->settings['namespace'] . ".{$name}";
     }
     $suite->setName($name);
     $suite->setModules($this->moduleContainer->all());
     return $suite;
 }
Example #10
0
 public function run(ModuleContainer $container = null)
 {
     $this->executed = true;
     if (!$container) {
         return null;
     }
     $activeModule = $container->moduleForAction($this->action);
     if (!is_callable([$activeModule, $this->action])) {
         throw new \RuntimeException("Action '{$this->action}' can't be called");
     }
     try {
         $res = call_user_func_array([$activeModule, $this->action], $this->arguments);
     } catch (\Exception $e) {
         $this->failed = true;
         throw $e;
     }
     return $res;
 }
 private function make_instance()
 {
     return new WPBootstrapper($this->module_container->reveal(), $this->config, $this->restorer->reveal(), $this->wp->reveal());
 }
Example #12
0
 /**
  * @return WPCLI
  */
 private function make_instance()
 {
     return new WPCLI($this->moduleContainer->reveal(), $this->config, $this->executor->reveal());
 }
Example #13
0
 /**
  * @return WPDb
  */
 private function make_instance()
 {
     return new WPDb($this->moduleContainer->reveal(), $this->config);
 }
Example #14
0
 /**
  * @return WPLoader
  */
 private function make_instance()
 {
     return new WPLoader($this->moduleContainer->reveal(), $this->config, $this->wp->reveal());
 }
Example #15
0
 public function initConfig()
 {
     $this->scenario = new Scenario($this, ['env' => $this->env, 'modules' => $this->moduleContainer->all(), 'name' => $this->testName]);
     $this->parser = new Parser($this->scenario);
     return $this;
 }
Example #16
0
 /**
  * @return WordPress
  */
 private function make_instance()
 {
     return new WordPress($this->moduleContainer->reveal(), $this->config, $this->client->reveal());
 }