/** * Instantiate the container. * * Objects and parameters can be passed as argument to the constructor. * * @param array $values The parameters or objects. */ public function __construct(array $values = array()) { parent::__construct($values); $this['event_dispatcher'] = function () { return new EventDispatcher(); }; $this['session_factory'] = function () { return new SessionFactory(); }; $this['session_strategy_factory'] = function ($c) { $session_strategy_factory = new SessionStrategyFactory(); $session_strategy_factory->setApplication($c['application']); return $session_strategy_factory; }; $this['session_strategy_manager'] = function ($c) { return new SessionStrategyManager($c['session_strategy_factory']); }; $this['isolated_session_strategy'] = $this->factory(function ($c) { $session_strategy = new IsolatedSessionStrategy($c['session_factory']); $session_strategy->setEventDispatcher($c['event_dispatcher']); return $session_strategy; }); $this['shared_session_strategy'] = $this->factory(function ($c) { $session_strategy = new SharedSessionStrategy($c['isolated_session_strategy']); $session_strategy->setEventDispatcher($c['event_dispatcher']); return $session_strategy; }); $this['remote_url'] = function () { return new RemoteUrl(); }; $this['remote_coverage_helper'] = function ($c) { return new RemoteCoverageHelper($c['remote_url']); }; $this['test_suite_factory'] = function ($c) { $test_suite_factory = new TestSuiteFactory($c['session_strategy_manager'], $c['browser_configuration_factory'], $c['remote_coverage_helper']); $test_suite_factory->setApplication($c['application']); return $test_suite_factory; }; $this['regular_test_suite'] = $this->factory(function ($c) { $test_suite = new RegularTestSuite(); $test_suite->setEventDispatcher($c['event_dispatcher']); return $test_suite; }); $this['browser_test_suite'] = $this->factory(function ($c) { $test_suite = new BrowserTestSuite(); $test_suite->setEventDispatcher($c['event_dispatcher']); return $test_suite; }); $this['browser_configuration_factory'] = function ($c) { $browser_configuration_factory = new BrowserConfigurationFactory(); $browser_configuration_factory->register(new BrowserConfiguration($c['event_dispatcher'])); $browser_configuration_factory->register(new SauceLabsBrowserConfiguration($c['event_dispatcher'], $browser_configuration_factory)); $browser_configuration_factory->register(new BrowserStackBrowserConfiguration($c['event_dispatcher'], $browser_configuration_factory)); return $browser_configuration_factory; }; }
/** * Test description. * * @return void */ public function testCreateSuiteFromTestCaseWithBrowsers() { $suite_class_name = 'aik099\\PHPUnit\\TestSuite\\RegularTestSuite'; $test_case_class_name = 'tests\\aik099\\PHPUnit\\Fixture\\WithBrowserConfig'; $browser_suite1 = $this->_createBrowserTestSuiteMock($test_case_class_name, array('browserName' => 'firefox', 'host' => 'localhost')); $browser_suite2 = $this->_createBrowserTestSuiteMock($test_case_class_name, array('browserName' => 'chrome', 'host' => '127.0.0.1')); $this->expectFactoryCall('browser_test_suite', array($browser_suite1, $browser_suite2)); $suite = m::mock($suite_class_name); $suite->shouldReceive('setName')->with($test_case_class_name)->once(); $suite->shouldReceive('addTest')->with($browser_suite1)->once(); $suite->shouldReceive('addTest')->with($browser_suite2)->once(); $this->expectFactoryCall('regular_test_suite', $suite); $actual_suite = $this->_factory->createSuiteFromTestCase($test_case_class_name); $this->assertInstanceOf($suite_class_name, $actual_suite); }