예제 #1
0
 /**
  * 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 testImmediateSessionFailure()
 {
     $this->_sessionFailure(new \Exception());
     $this->_isolatedStrategy->shouldReceive('session')->once()->andReturn($this->_session1);
     $this->assertSame($this->_session1, $this->strategy->session(m::mock(self::BROWSER_CLASS)));
 }