/** * Returns browser configuration instance. * * @param array $config Browser. * @param BrowserTestCase $test_case Test case. * * @return BrowserConfiguration */ public function createBrowserConfiguration(array $config, BrowserTestCase $test_case) { $aliases = $test_case->getBrowserAliases(); $config = BrowserConfiguration::resolveAliases($config, $aliases); $type = isset($config['type']) ? $config['type'] : 'default'; return $this->create($type)->setAliases($aliases)->setup($config); }
/** * Sets event dispatcher. * * @param EventDispatcherInterface $event_dispatcher Event dispatcher. * * @return void */ public function setEventDispatcher(EventDispatcherInterface $event_dispatcher) { parent::setEventDispatcher($event_dispatcher); // Use priority for this listener to be called before one, that stops the session. $event_dispatcher->addListener(self::TEST_ENDED_EVENT, array($this, 'recordSessionId'), 200); $event_dispatcher->addListener(self::TEST_ENDED_EVENT, array($this, 'verifyRemoteAPICalls')); }
/** * Set session meta-info for "Sauce Labs". * * @return void */ protected function setUp() { if (!getenv('SAUCE_USERNAME') || !getenv('SAUCE_ACCESS_KEY')) { $this->markTestSkipped('SauceLabs integration is not configured'); } parent::setUp(); }
protected function setUp() { // To create regular browser configuration via BrowserConfigurationFactory. $browser = $this->createBrowserConfiguration(array()); // To create "Sauce Labs" browser configuration via BrowserConfigurationFactory. $browser = $this->createBrowserConfiguration(array('type' => 'saucelabs', 'api_username' => 'sauce_username', 'api_key' => 'sauce_api_key')); // Options can be changed later (optional). $browser->setHost('selenium_host')->setPort('selenium_port')->setTimeout(30); $browser->setBrowserName('browser name')->setDesiredCapabilities(array('version' => '6.5')); $browser->setBaseUrl('http://www.test-host.com'); // Set browser configuration to test case. $this->setBrowser($browser); parent::setUp(); }
/** * Creating browser configuration that would listen for events. * * @return void */ protected function setUp() { $api_client = m::mock('aik099\\PHPUnit\\APIClient\\IAPIClient'); $api_client->shouldReceive('updateStatus')->withAnyArgs()->once(); /** @var IBrowserConfigurationFactory $factory */ $factory = m::mock('aik099\\PHPUnit\\BrowserConfiguration\\IBrowserConfigurationFactory'); $factory->shouldReceive('createAPIClient')->once()->andReturn($api_client); $browser_config = array('api_username' => 'a', 'api_key' => 'b'); $browser = new SauceLabsBrowserConfiguration($this->readAttribute($this, '_eventDispatcher'), $factory); $factory->shouldReceive('createBrowserConfiguration')->with($browser_config, $this)->once()->andReturn($browser); $this->setBrowserConfigurationFactory($factory); $this->setBrowserFromConfiguration($browser_config); parent::setUp(); }
/** * Creating browser configuration that would listen for events. * * @return void */ protected function setUp() { $api_client = m::mock('aik099\\PHPUnit\\APIClient\\IAPIClient'); $api_client->shouldReceive('updateStatus')->withAnyArgs()->once(); /** @var IBrowserConfigurationFactory $factory */ $factory = m::mock('aik099\\PHPUnit\\BrowserConfiguration\\IBrowserConfigurationFactory'); $browser_config = array('apiUsername' => 'a', 'apiKey' => 'b'); $browser = m::mock('aik099\\PHPUnit\\BrowserConfiguration\\SauceLabsBrowserConfiguration[getAPIClient]', array($this->readAttribute($this, '_eventDispatcher'), $this->createDriverFactoryRegistry())); // These magic methods can't be properly passed through to mocked object otherwise. $browser->shouldReceive('getSessionStrategy')->andReturn('isolated'); $browser->shouldReceive('getDesiredCapabilities')->andReturn(array(SauceLabsBrowserConfiguration::NAME_CAPABILITY => 'something')); $browser->shouldReceive('getAPIClient')->once()->andReturn($api_client); $factory->shouldReceive('createBrowserConfiguration')->with($browser_config, $this)->once()->andReturn($browser); $this->setBrowserConfigurationFactory($factory); $this->setBrowserFromConfiguration($browser_config); parent::setUp(); }
/** * Returns test run status based on session strategy requested by browser. * * @param BrowserTestCase $test_case Browser test case. * @param \PHPUnit_Framework_TestResult $test_result Test result. * * @return boolean * @see IsolatedSessionStrategy * @see SharedSessionStrategy */ public function getTestStatus(BrowserTestCase $test_case, \PHPUnit_Framework_TestResult $test_result) { if ($this->isShared()) { // All tests in a test case use same session -> failed even if 1 test fails. return $test_result->wasSuccessful(); } // Each test in a test case are using it's own session -> failed if test fails. return !$test_case->hasFailed(); }
/** * Sets event dispatcher. * * @param EventDispatcherInterface $event_dispatcher Event dispatcher. * * @return void */ public function setEventDispatcher(EventDispatcherInterface $event_dispatcher) { parent::setEventDispatcher($event_dispatcher); $event_dispatcher->addListener(self::TEST_ENDED_EVENT, array($this, 'verifyRemoteAPICalls')); }
/** * Determines if received event is designed for this recipient. * * @param TestEvent $event Event. * * @return boolean */ protected function isEventForMe(TestEvent $event) { $test_case = $event->getTestCase(); return get_class($test_case) === get_class($this->_testCase) && $test_case->getName() === $this->_testCase->getName(); }
protected function setUp() { $this->pageFactory = $this->createPageFactory(); parent::setUp(); }