Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  * @see PHPUnit_Framework_TestCase::runTest()
  */
 protected function runTest()
 {
     if (isset($this->getAnnotations()['method']['functional']) && $this->isSkipFunctionalTests()) {
         $this->markTestSkipped();
     }
     return parent::runTest();
 }
Exemplo n.º 2
0
 /**
  * Vynucuje existenci @covers anotace při generování code coverage.
  *
  * @author Jan Tvrdík
  * @return mixed
  */
 protected function runTest()
 {
     $annotations = $this->getAnnotations();
     if (!isset($annotations['class']['covers']) && !isset($annotations['method']['covers']) && !isset($annotations['class']['coversNothing']) && !isset($annotations['method']['coversNothing'])) {
         $this->markTestIncomplete('Missing mandatory @covers or @coversNothing annotation');
     }
     return parent::runTest();
 }
Exemplo n.º 3
0
 protected function runTest()
 {
     if (\PhpSpock\Adapter\PhpUnitAdapter::isSpecification($this)) {
         return \PhpSpock\Adapter\PhpUnitAdapter::runTest($this);
     } else {
         return parent::runTest();
     }
 }
Exemplo n.º 4
0
 protected function runTest()
 {
     if ($this->isExternal() && !$this->allowExternal()) {
         $this->markTestSkipped('Test requires external reference');
         return false;
     }
     return parent::runTest();
 }
Exemplo n.º 5
0
 function runTest()
 {
     $startTime = microtime(true);
     parent::runTest();
     $endTime = microtime(true);
     if (0 != $this->maxRunningTime && $endTime - $startTime > $this->maxRunningTime) {
         $this->fail('expected running time: <= ' . $this->maxRunningTime . ' but was ' . ($endTime - $startTime));
     }
 }
Exemplo n.º 6
0
 /**
  * @access protected
  */
 protected function runTest()
 {
     PHPUnit_Util_Timer::start();
     parent::runTest();
     $time = PHPUnit_Util_Timer::stop();
     if ($this->maxRunningTime != 0 && $time > $this->maxRunningTime) {
         $this->fail(sprintf('expected running time: <= %s but was: %s', $this->maxRunningTime, $time));
     }
 }
Exemplo n.º 7
0
 /**
  * @access public
  */
 protected function runTest()
 {
     $timer = new Benchmark_Timer();
     $timer->start();
     parent::runTest();
     $timer->stop();
     if ($this->fMaxRunningTime != 0 && $timer->timeElapsed() > $this->fMaxRunningTime) {
         PHPUnit_Framework_Assert::fail(sprintf('expected running time: <= %s but was: %s', $this->fMaxRunningTime, $timer->timeElapsed()));
     }
 }
Exemplo n.º 8
0
 /**
  * @access public
  */
 protected function runTest()
 {
     try {
         parent::runTest();
     } catch (Exception $e) {
         if (is_a($e, $this->fExpected)) {
             return;
         } else {
             throw $e;
         }
     }
     $this->fail('Expected exception ' . $this->fExpected);
 }
Exemplo n.º 9
0
 /**
  * Wraps the default #runTest() method to provide an exception hook.
  *
  * @return mixed|null
  *
  * @throws \Exception
  */
 protected function runTest()
 {
     try {
         $result = parent::runTest();
     } catch (\Exception $ex) {
         $this->exceptionHook($ex);
         return;
     }
     // @codeCoverageIgnoreStart
     if ($this->expectException) {
         $this->fail('An exception was expected but none has been thrown.');
     }
     // @codeCoverageIgnoreEnd
     return $result;
 }
Exemplo n.º 10
0
 protected function runTest()
 {
     $result = parent::runTest();
     if ($this->logStream !== NULL) {
         $this->addToAssertionCount(1);
         fseek($this->logStream, 0);
         $actualLogs = stream_get_contents($this->logStream);
         fclose($this->logStream);
         $actualLogs = array_map('rtrim', explode("\n", $actualLogs));
         $actualLogs = array_values(array_filter($actualLogs, 'strlen'));
         if ($this->expectedLogs !== NULL) {
             if (count($this->expectedLogs)) {
                 $this->assertEquals($this->expectedLogs, $actualLogs);
             } else {
                 if (count($actualLogs)) {
                     $this->fail("No logs expected, but we received:\n" . var_export($actualLogs, TRUE));
                 }
             }
         }
     }
     return $result;
 }
Exemplo n.º 11
0
 /**
  * @access protected
  */
 protected function runTest()
 {
     $this->start();
     parent::runTest();
     try {
         $this->stop();
     } catch (RuntimeException $e) {
     }
 }
Exemplo n.º 12
0
 /**
  * @throws RuntimeException
  */
 protected function runTest()
 {
     $this->prepareSession();
     $thrownException = NULL;
     if ($this->collectCodeCoverageInformation) {
         $this->url($this->coverageScriptUrl);
         // phpunit_coverage.php won't do anything if the cookie isn't set, which is exactly what we want
         $this->session->cookie()->add('PHPUNIT_SELENIUM_TEST_ID', $this->testId)->set();
     }
     try {
         $this->setUpPage();
         $result = parent::runTest();
         if (!empty($this->verificationErrors)) {
             $this->fail(implode("\n", $this->verificationErrors));
         }
     } catch (Exception $e) {
         $thrownException = $e;
     }
     if ($this->collectCodeCoverageInformation) {
         $this->session->cookie()->remove('PHPUNIT_SELENIUM_TEST_ID');
     }
     if (NULL !== $thrownException) {
         throw $thrownException;
     }
     return $result;
 }
    /**
     * @throws RuntimeException
     */
    protected function runTest()
    {
        if (!$this->serverRunning) {
            $this->markTestSkipped(
              sprintf(
                'Could not connect to Selenium RC on %s:%d.',
                $this->drivers[0]->getHost(),
                $this->drivers[0]->getPort()
              )
            );
        }

        $this->start();

        if (!is_file($this->getName(FALSE))) {
            parent::runTest();
        } else {
            $this->runSelenese($this->getName(FALSE));
        }

        if (!empty($this->verificationErrors)) {
            $this->fail(implode("\n", $this->verificationErrors));
        }

        try {
            $this->stop();
        }

        catch (RuntimeException $e) {
        }
    }
 /**
  * @return mixed
  * @throws RuntimeException
  */
 protected function runTest()
 {
     ob_start();
     $this->obActive = TRUE;
     try {
         $testResult = parent::runTest();
     } catch (Exception $e) {
         ob_end_clean();
         $this->obActive = FALSE;
         throw $e;
     }
     if ($this->outputCallback === FALSE) {
         $this->output = ob_get_contents();
     } else {
         $this->output = call_user_func_array($this->outputCallback, array(ob_get_contents()));
     }
     ob_end_clean();
     $this->obActive = FALSE;
     if ($this->expectedRegex !== NULL) {
         $this->assertRegExp($this->expectedRegex, $this->output);
         $this->expectedRegex = NULL;
     } else {
         if ($this->expectedString !== NULL) {
             $this->assertEquals($this->expectedString, $this->output);
             $this->expectedString = NULL;
         }
     }
     return $testResult;
 }
Exemplo n.º 15
0
 /**
  * @throws RuntimeException
  */
 protected function runTest()
 {
     $this->start();
     if (!is_file($this->getName(FALSE))) {
         parent::runTest();
     } else {
         $this->runSelenese($this->getName(FALSE));
     }
     if (!empty($this->verificationErrors)) {
         $this->fail(implode("\n", $this->verificationErrors));
     }
     try {
         $this->stop();
     } catch (RuntimeException $e) {
     }
 }
 /**
  * Overrides runTest method for the phpunit framework
  * @see PHPUnit_Framework_TestCase::runTest()
  */
 public function runTest()
 {
     $name = $this->getName(true);
     KalturaLog::debug("In runTest for test [{$name}]\n");
     //print("In KalturaTestCaseBase::runTest for test [$name]\n");
     foreach ($this->getDependencyInputs() as $index => $value) {
         KalturaLog::debug("Adding key [{$index}], value [{$value}] to the test data\n");
         //TODO: fix access to data
         $this->data[$index] = $value;
     }
     $this->currentFailure = null;
     $testResult = parent::runTest();
     return $testResult;
 }
Exemplo n.º 17
0
 /**
  * Run this test's scenario.
  *
  * @return mixed
  * @throws RuntimeException
  */
 protected function runTest()
 {
     $testResult = parent::runTest();
     $this->scenario->run($this->world);
     return $testResult;
 }
Exemplo n.º 18
0
 /**
  * @access protected
  */
 protected function runTest()
 {
     try {
         parent::runTest();
     } catch (Exception $e) {
         if ($this->expectedException !== NULL && $e instanceof $this->expectedException) {
             return;
         } else {
             throw $e;
         }
     }
     if ($this->expectedException !== NULL) {
         $this->fail('Expected exception ' . $this->expectedException);
     }
 }
Exemplo n.º 19
0
 /**
  * Overrides the runTest method to add additional annotations
  * @return PHPUnit_Framework_TestResult
  */
 protected function runTest()
 {
     if (null === $this->plugin) {
         throw new RuntimeException('Tests cannot be run before plugin is set');
     }
     // Clean the event handler... important!
     $this->handler->clearEvents();
     $info = $this->getAnnotations();
     $event = null;
     $eventArgs = array();
     if (isset($info['method']['event']) && isset($info['method']['event'][0])) {
         if (!is_string($info['method']['event'][0])) {
             throw new InvalidArgumentException('Only one event may be specified');
         }
         $event = $info['method']['event'][0];
         if (stristr($event, '::')) {
             $event = explode('::', $event);
         }
     }
     if (isset($info['method']['eventArg'])) {
         $eventArgs = $info['method']['eventArg'];
     }
     if (null !== $event) {
         $this->setEvent($event, $eventArgs);
     }
     $testResult = parent::runTest();
     // Clean the event handler again... just incase this time.
     $this->handler->clearEvents();
     return $testResult;
 }
Exemplo n.º 20
0
 /**
  * @throws RuntimeException
  */
 protected function runTest()
 {
     $this->skipWithNoServerRunning();
     if (self::$shareSession && self::$sessionId !== NULL) {
         $this->setSessionId(self::$sessionId);
         $this->selectWindow('null');
     } else {
         self::$sessionId = $this->start();
     }
     if (!is_file($this->getName(FALSE))) {
         parent::runTest();
     } else {
         $this->runSelenese($this->getName(FALSE));
     }
     if (!empty($this->verificationErrors)) {
         $this->fail(implode("\n", $this->verificationErrors));
     }
     if (!self::$shareSession) {
         $this->stopSession();
     }
 }
 /**
  * @throws RuntimeException
  */
 protected function runTest()
 {
     $this->prepareSession();
     $thrownException = NULL;
     if ($this->collectCodeCoverageInformation) {
         $this->session->cookie()->remove('PHPUNIT_SELENIUM_TEST_ID');
         $this->session->cookie()->add('PHPUNIT_SELENIUM_TEST_ID', $this->testId)->set();
     }
     try {
         $result = parent::runTest();
         if (!empty($this->verificationErrors)) {
             $this->fail(implode("\n", $this->verificationErrors));
         }
     } catch (Exception $e) {
         $thrownException = $e;
     }
     if (NULL !== $thrownException) {
         throw $thrownException;
     }
     return $result;
 }
Exemplo n.º 22
0
 /**
  * Switches the target test method to "runTestCaseWithinLoop" when the test method is a generator method.
  */
 protected function runTest()
 {
     $this->testMethodNameBackup = $this->getName(false);
     $ref = new \ReflectionMethod(static::class, $this->testMethodNameBackup);
     if (!$ref->isGenerator()) {
         return parent::runTest();
     }
     $this->setName('runTestCaseWithinLoop');
     try {
         return parent::runTest();
     } finally {
         $this->setName($this->testMethodNameBackup);
     }
 }
Exemplo n.º 23
0
 /**
  * Run test
  *
  * @return mixed
  * @see    ____func_see____
  * @since  1.0.0
  */
 protected function runTest()
 {
     $result = null;
     $shortName = lcfirst(substr($this->getName(), 4));
     if (self::$testsRange && !in_array($shortName, self::$testsRange)) {
         $this->markTestSkipped();
     } else {
         try {
             $result = parent::runTest();
         } catch (PHPUnit_Framework_AssertionFailedError $exception) {
             if ($this->makeSqlBackupOnFailure) {
                 $path = LC_DIR_ROOT . 'var/log/unit-' . date('Ymd-His') . '-' . $this->getName() . '.sql';
                 try {
                     $this->doMakeBackup($path);
                 } catch (\Exception $e) {
                 }
             }
             throw $exception;
         }
     }
     return $result;
 }
Exemplo n.º 24
0
 /**
  * @access protected
  */
 protected function runTest()
 {
     $this->setupSelenium();
     $this->start();
     parent::runTest();
     try {
         $this->stop();
     } catch (Selenium_Exception $e) {
     }
     $this->selenium = NULL;
 }
 /**
  * @throws RuntimeException
  */
 protected function runTest()
 {
     $this->prepareSession();
     parent::runTest();
     if (!empty($this->verificationErrors)) {
         $this->fail(implode("\n", $this->verificationErrors));
     }
     self::sessionStrategy()->endOfTest($this->session);
 }
Exemplo n.º 26
0
 /**
  * @access protected
  */
 protected function runTest()
 {
     $this->start();
     if (!is_file($this->name)) {
         parent::runTest();
     } else {
         $this->runSelenese($this->name);
     }
     if ($this->autoStop) {
         try {
             $this->stop();
         } catch (RuntimeException $e) {
         }
     }
 }
Exemplo n.º 27
0
 /**
  * Override to use Mink exceptions.
  *
  * @return mixed
  *   Either a test result or NULL.
  *
  * @throws \PHPUnit_Framework_AssertionFailedError
  *   When exception was thrown inside the test.
  */
 protected function runTest()
 {
     try {
         return parent::runTest();
     } catch (Exception $e) {
         throw new \PHPUnit_Framework_AssertionFailedError($e->getMessage());
     }
 }
Exemplo n.º 28
0
 /**
  * @throws RuntimeException
  */
 protected function runTest()
 {
     $this->skipWithNoServerRunning();
     $this->prepareTestSession();
     if (!is_file($this->getName(FALSE))) {
         $result = parent::runTest();
     } else {
         $this->runSelenese($this->getName(FALSE));
         $result = NULL;
     }
     if (!empty($this->verificationErrors)) {
         $this->fail(implode("\n", $this->verificationErrors));
     }
     if (!self::$shareSession) {
         $this->stopSession();
     }
     return $result;
 }
Exemplo n.º 29
0
 /**
  * Run this test's scenario.
  *
  * @throws RuntimeException
  */
 protected function runTest()
 {
     parent::runTest();
     $this->scenario->run($this->world);
 }
Exemplo n.º 30
0
 /**
  * @return mixed
  * @throws RuntimeException
  */
 protected function runTest()
 {
     PHPUnit_Util_DeprecatedFeature_Logger::log('The functionality of PHPUnit_Extensions_OutputTestCase has been ' . 'merged into PHPUnit_Framework_TestCase. Please update your test ' . 'by extending PHPUnit_Framework_TestCase instead of ' . 'PHPUnit_Extensions_OutputTestCase.');
     return parent::runTest();
 }