/**
  * 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();
     }
 }
 /**
  * Hook, called from "BrowserTestCase::setUp" method.
  *
  * @param TestEvent $event Test event.
  *
  * @return void
  */
 public function onTestSetup(TestEvent $event)
 {
     if (!$event->validateSubscriber($this->getTestCase())) {
         return;
     }
     parent::onTestSetup($event);
     $desired_capabilities = $this->getDesiredCapabilities();
     if (getenv('PHPUNIT_MINK_TUNNEL_ID')) {
         $desired_capabilities['tunnel-identifier'] = getenv('PHPUNIT_MINK_TUNNEL_ID');
     }
     $this->setDesiredCapabilities($desired_capabilities);
 }
예제 #3
0
 /**
  * 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']);
     }
 }
예제 #4
0
 /**
  * Verify how the API calls were made.
  *
  * @param TestEvent $event Event.
  *
  * @return void
  */
 public function verifyRemoteAPICalls(TestEvent $event)
 {
     if (!$event->validateSubscriber($this)) {
         return;
     }
     $test_case = $event->getTestCase();
     $test_name = $test_case->getName(false);
     if (!isset($this->_sessionIds[$test_name])) {
         return;
     }
     $browser = $this->getBrowser();
     if ($browser instanceof ApiBrowserConfiguration) {
         $api_client = $browser->getAPIClient();
         $session_info = $api_client->getInfo($this->_sessionIds[$test_name]);
         $this->assertEquals(get_class($test_case) . '::' . $test_name, $session_info['name']);
         if ($browser instanceof SauceLabsBrowserConfiguration) {
             $passed_mapping = array('testSuccess' => true, 'testFailure' => false);
             $this->assertSame($passed_mapping[$test_name], $session_info['passed']);
         } elseif ($browser instanceof BrowserStackBrowserConfiguration) {
             $passed_mapping = array('testSuccess' => 'done', 'testFailure' => 'error');
             $this->assertSame($passed_mapping[$test_name], $session_info['status']);
         }
     }
 }
예제 #5
0
 /**
  * Hook, called from "BrowserTestCase::setUp" method.
  *
  * @param TestEvent $event Test event.
  *
  * @return void
  */
 public function onTestSetup(TestEvent $event)
 {
     if (!$event->validateSubscriber($this->getTestCase())) {
         return;
     }
     // Place code here.
 }
 /**
  * Hook, called from "BrowserTestCase::setUp" method.
  *
  * @param TestEvent $event Test event.
  *
  * @return void
  */
 public function onTestSetup(TestEvent $event)
 {
     if (!$event->validateSubscriber($this->getTestCase())) {
         return;
     }
     parent::onTestSetup($event);
     $desired_capabilities = $this->getDesiredCapabilities();
     $desired_capabilities[self::NAME_CAPABILITY] = $this->getJobName($event->getTestCase());
     if (getenv('BUILD_NUMBER')) {
         $desired_capabilities[self::BUILD_NUMBER_CAPABILITY] = getenv('BUILD_NUMBER');
         // Jenkins.
     } elseif (getenv('TRAVIS_BUILD_NUMBER')) {
         $desired_capabilities[self::BUILD_NUMBER_CAPABILITY] = getenv('TRAVIS_BUILD_NUMBER');
     }
     $this->setDesiredCapabilities($desired_capabilities);
 }
예제 #7
0
 /**
  * Remembers the exception which caused test to fail.
  *
  * @param \Exception      $e         Exception.
  * @param BrowserTestCase $test_case Test case.
  * @param Session         $session   Session.
  */
 public function __construct(\Exception $e, BrowserTestCase $test_case, Session $session = null)
 {
     parent::__construct($test_case, $session);
     $this->_exception = $e;
 }
예제 #8
0
 /**
  * Remembers the exception which caused test to fail.
  *
  * @param BrowserTestCase               $test_case   Test case.
  * @param \PHPUnit_Framework_TestResult $test_result Test result.
  * @param Session                       $session     Session.
  */
 public function __construct(BrowserTestCase $test_case, \PHPUnit_Framework_TestResult $test_result, Session $session = null)
 {
     parent::__construct($test_case, $session);
     $this->_testResult = $test_result;
 }
예제 #9
0
 /**
  * Checks, that event can be handled by this class.
  *
  * @param TestEvent $event Test event.
  *
  * @return boolean
  */
 private function _isEventForMe(TestEvent $event)
 {
     return $event->getTestCase()->getSessionStrategy() instanceof self;
 }
예제 #10
0
 /**
  * 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();
 }
예제 #11
0
 /**
  * Test description.
  *
  * @return void
  */
 public function testGetSession()
 {
     $this->assertSame($this->session, $this->event->getSession());
 }