/**
  * Called, when test ends.
  *
  * @param TestEvent $event Test event.
  *
  * @return void
  */
 public function onTestEnd(TestEvent $event)
 {
     $session = $event->getSession();
     if ($session !== null && $session->isStarted()) {
         $session->stop();
     }
 }
 /**
  * Record WebDriver session ID of the test.
  *
  * @param TestEvent $event Event.
  *
  * @return void
  */
 public function recordSessionId(TestEvent $event)
 {
     $test_case = $event->getTestCase();
     if (get_class($test_case) !== get_class($this) || $test_case->getName() !== $this->getName() || $this->_getTestSkipMessage()) {
         return;
     }
     $session = $event->getSession();
     if ($session === null) {
         $this->markTestSkipped('Unable to connect to SauceLabs/BrowserStack. Please check Internet connection.');
     }
     $this->_sessionIds[$test_case->getName(false)] = $session->getDriver()->getWebDriverSessionId();
 }
 /**
  * Verify how the API calls were made.
  *
  * @param TestEvent $event Event.
  *
  * @return void
  */
 public function verifyRemoteAPICalls(TestEvent $event)
 {
     $test_case = $event->getTestCase();
     if (get_class($test_case) !== get_class($this) || $test_case->getName() !== $this->getName()) {
         return;
     }
     $browser = $this->getBrowser();
     if ($browser instanceof SauceLabsBrowserConfiguration) {
         $session = $event->getSession();
         if ($session === null) {
             $this->markTestSkipped('Unable to connect to SauceLabs. Please check Internet connection.');
         }
         $sauce_rest = new SauceRest($browser->getApiUsername(), $browser->getApiKey());
         $job_info = $sauce_rest->getJob($session->getDriver()->getWebDriverSessionId());
         $this->assertEquals(get_class($test_case) . '::' . $test_case->getName(), $job_info['name']);
         $passed_mapping = array('testSuccess' => true, 'testFailure' => false);
         $this->assertSame($passed_mapping[$test_case->getName()], $job_info['passed']);
     }
 }
Beispiel #4
0
 /**
  * Test description.
  *
  * @return void
  */
 public function testGetSession()
 {
     $this->assertSame($this->session, $this->event->getSession());
 }