/** * Checks if deployment configuration has been changed by a test * * Changing deployment configuration violates isolation between tests, so further tests may become broken. * To fix this issue, find out why this test changes deployment configuration. * If this is intentional, then it must be reverted to the previous state within the test. * After that, the application needs to be wiped out and reinstalled. * * @param \PHPUnit_Framework_TestCase $test * @return void */ public function endTest(\PHPUnit_Framework_TestCase $test) { $config = $this->reader->load(); if ($this->config != $config) { $error = "\n\nERROR: deployment configuration is corrupted. The application state is no longer valid.\n" . 'Further tests may fail.' . " This test failure may be misleading, if you are re-running it on a corrupted application.\n" . $test->toString() . "\n"; $test->fail($error); } }
/** * Returns a string representation of the test case. * * @return string */ public function toString() { $buffer = parent::toString(); if (!empty($this->browserName)) { $buffer .= ' with browser ' . $this->browserName; } return $buffer; }
/** * Fails the test with specified error message * * @param string $message * @param \PHPUnit_Framework_TestCase $test * @throws \Exception */ private static function fail($message, \PHPUnit_Framework_TestCase $test) { $test->fail("{$message} in the test '{$test->toString()}'"); throw new \Exception('The above line was supposed to throw an exception.'); }
/** * @param \PHPUnit_Framework_TestCase $test * @param bool $inProgress * @return Message */ protected function getTestMessage(\PHPUnit_Framework_TestCase $test, $inProgress = false) { if (!$test instanceof TestCase) { return $this->message = $this->message($test->toString())->style('focus')->prepend($inProgress ? 'Running ' : ''); } $filename = $test->getSignature(); if ($test->getFeature()) { return $this->message = $this->message("<focus>%s</focus> (%s) ")->prepend($inProgress ? 'Trying to ' : '')->with($inProgress ? $test->getFeature() : ucfirst($test->getFeature()), $filename); } return $this->message = $this->message("<focus>%s</focus> ")->prepend($inProgress ? 'Running ' : '')->with($filename); }