本文整理汇总了PHP中Codeception\TestCase类的典型用法代码示例。如果您正苦于以下问题:PHP TestCase类的具体用法?PHP TestCase怎么用?PHP TestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestCase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _failed
public function _failed(\Codeception\TestCase $test, $fail)
{
if (!$this->client || !$this->client->getInternalResponse()) {
return;
}
file_put_contents(\Codeception\Configuration::logDir() . basename($test->getFileName()) . '.page.debug.html', $this->client->getInternalResponse()->getContent());
}
开发者ID:lenninsanchez,项目名称:donadores,代码行数:7,代码来源:Framework.php
示例2: _failed
public function _failed(TestCase $test, $fail)
{
if (!$this->client || !$this->client->getInternalResponse()) {
return;
}
$this->_savePageSource(codecept_output_dir() . str_replace(['::', '\\', '/'], ['.', '.', '.'], TestCase::getTestSignature($test)) . '.fail.html');
}
开发者ID:vladislavl-hyuna,项目名称:crmapp,代码行数:7,代码来源:InnerBrowser.php
示例3: _setupTestCase
/**
* Setups common environment for a test case.
*
* @since 1.0.0
*
* @access protected
* @param \Codeception\TestCase $testCase The test case object.
* @param string $name Test case name.
* @param string $file The file name.
*/
protected function _setupTestCase(TestCase $testCase, $name, $file)
{
$testCase->setBackupGlobals(false);
$testCase->setBackupStaticAttributes(false);
$testCase->setRunTestInSeparateProcess(false);
$testCase->setInIsolation(false);
$testCase->setPreserveGlobalState(false);
if ($testCase instanceof Configurable) {
$testCase->configName($name);
$testCase->configFile($file);
$testCase->initConfig();
}
}
开发者ID:gedex,项目名称:wp-codeception,代码行数:23,代码来源:TestLoader.php
示例4: _failed
public function _failed(TestCase $test, $fail)
{
if (!$this->client || !$this->client->getInternalResponse()) {
return;
}
$filename = str_replace(['::', '\\', '/'], ['.', '', ''], TestCase::getTestSignature($test)) . '.fail.html';
file_put_contents(codecept_output_dir($filename), $this->client->getInternalResponse()->getContent());
}
开发者ID:Eli-TW,项目名称:Codeception,代码行数:8,代码来源:InnerBrowser.php
示例5: testCeptNamings
/**
* @group core
*/
public function testCeptNamings()
{
$cept = new \Codeception\TestCase\Cept();
$cept->configName('LoginCept.php')->config('testFile', 'tests/acceptance/LoginCept.php');
$this->assertEquals('tests/acceptance/LoginCept.php', \Codeception\TestCase::getTestFileName($cept));
$this->assertEquals('tests/acceptance/LoginCept.php', \Codeception\TestCase::getTestFullName($cept));
$this->assertEquals('LoginCept', \Codeception\TestCase::getTestSignature($cept));
}
开发者ID:hitechdk,项目名称:Codeception,代码行数:11,代码来源:CeptTest.php
示例6: testCestNamings
/**
* @group core
*/
public function testCestNamings()
{
$cept = new \Codeception\TestCase\Cest();
$klass = new stdClass();
$cept->config('testClassInstance', $klass)->config('testMethod', 'user')->config('testFile', 'tests/acceptance/LoginCest.php');
$this->assertEquals('tests/acceptance/LoginCest.php:user', \Codeception\TestCase::getTestFullName($cept));
$this->assertEquals('tests/acceptance/LoginCest.php', \Codeception\TestCase::getTestFileName($cept));
$this->assertEquals('stdClass::user', \Codeception\TestCase::getTestSignature($cept));
}
开发者ID:hitechdk,项目名称:Codeception,代码行数:12,代码来源:CestTest.php
示例7: getTestNames
protected function getTestNames($tests)
{
$testNames = [];
foreach ($tests as $test) {
if ($test instanceof \PHPUnit_Framework_TestCase) {
$testNames[] = \Codeception\TestCase::getTestSignature($test);
}
}
return $testNames;
}
开发者ID:hitechdk,项目名称:Codeception,代码行数:10,代码来源:TestLoaderTest.php
示例8: _after
public function _after(TestCase $test)
{
$this->debug(__CLASS__ . '::' . __FUNCTION__ . '()');
$unfinished_transaction = $this->transaction_level > 0;
if ($unfinished_transaction) {
$this->debug("Unfinished transaction was found; rolling back (after test '{$test->getName(false)}')");
// wrap up the transaction so that the clean-up below can succeed.
// it is not possible to switch connectors mid-transaction.
$this->rollbackTransaction();
}
foreach ($this->test_cleanup_actions as $cleanup_action) {
$this->debugSection('cleanup', $cleanup_action->getDefinition());
call_user_func($cleanup_action, $this);
}
if ($unfinished_transaction) {
$this->fail("Unfinished transaction was found (after test '{$test->getName(false)}')");
}
$this->test_cleanup_actions = [];
parent::_after($test);
}
开发者ID:codemedic,项目名称:Codeception-MultiDb,代码行数:20,代码来源:MultiDb.php
示例9: assertContainsTestName
protected function assertContainsTestName($name, $tests)
{
foreach ($tests as $test) {
if ($test instanceof \PHPUnit_Framework_TestCase) {
$testName = \Codeception\TestCase::getTestSignature($test);
if ($testName == $name) {
return;
}
codecept_debug($testName);
}
}
$this->fail("{$name} not found in tests");
}
开发者ID:itillawarra,项目名称:cmfive,代码行数:13,代码来源:TestLoaderTest.php
示例10: saveFailed
public function saveFailed(PrintResultEvent $e)
{
$file = $this->getLogDir() . $this->config['file'];
$result = $e->getResult();
if ($result->wasSuccessful()) {
if (is_file($file)) {
unlink($file);
}
return;
}
$output = [];
foreach ($result->failures() as $fail) {
$output[] = $this->localizePath(TestCase::getTestFullName($fail->failedTest()));
}
foreach ($result->errors() as $fail) {
$output[] = $this->localizePath(TestCase::getTestFullName($fail->failedTest()));
}
file_put_contents($file, implode("\n", $output));
}
开发者ID:namnv609,项目名称:Codeception,代码行数:19,代码来源:RunFailed.php
示例11: run
public function run()
{
if (!class_exists('\\Codeception\\Lib\\TestLoader')) {
throw new TaskException($this, "This task requires Codeception to be loaded. Please require autoload.php of Codeception");
}
$testLoader = new \Codeception\Lib\TestLoader($this->testsFrom);
$testLoader->loadTests();
$tests = $testLoader->getTests();
$i = 0;
$groups = [];
$this->printTaskInfo("Processing " . count($tests) . " files");
// splitting tests by groups
foreach ($tests as $test) {
$groups[$i % $this->numGroups + 1][] = \Codeception\TestCase::getTestFullName($test);
$i++;
}
// saving group files
foreach ($groups as $i => $tests) {
$filename = $this->saveTo . $i;
$this->printTaskInfo("Writing {$filename}");
file_put_contents($filename, implode("\n", $tests));
}
}
开发者ID:gdscei,项目名称:robo-paracept,代码行数:23,代码来源:SplitTestsByGroups.php
示例12: seeNoDifferenceToReferenceImage
/**
* Checks item in Memcached exists and the same as expected.
*
* @param string $referenceImageIdentifier
* @param null|string $selector
* @throws ModuleException
*/
public function seeNoDifferenceToReferenceImage($referenceImageIdentifier, $selector = null)
{
if ($selector === null) {
$selector = 'body';
}
$elements = $this->webDriver->_findElements($selector);
if (count($elements) == 0) {
throw new ElementNotFound($selector);
} elseif (count($elements) > 1) {
throw new ModuleException(__CLASS__, 'Multiple elements found for given selector "' . $selector . '" but need exactly one element!');
}
/** @var RemoteWebElement $element */
$image = $this->_createScreenshot($referenceImageIdentifier, reset($elements));
$windowSizeString = $this->moduleFileSystemUtil->getCurrentWindowSizeString($this->webDriver);
$referenceImagePath = $this->moduleFileSystemUtil->getReferenceImagePath($referenceImageIdentifier, $windowSizeString);
if (!file_exists($referenceImagePath)) {
// Ensure that the target directory exists
$this->moduleFileSystemUtil->createDirectoryRecursive(dirname($referenceImagePath));
copy($image->getImageFilename(), $referenceImagePath);
$this->currentTestCase->markTestIncomplete('Reference Image does not exist.
Test is skipeed but will now copy reference image to target directory...');
} else {
$referenceImage = new \Imagick($referenceImagePath);
/** @var \Imagick $comparedImage */
list($comparedImage, $difference) = $referenceImage->compareImages($image, \Imagick::METRIC_MEANSQUAREERROR);
$calculatedDifferenceValue = round((double) substr($difference, 0, 6) * 100, 2);
$this->currentTestCase->getScenario()->comment('Difference between reference and current image is around ' . $calculatedDifferenceValue . '%');
if ($calculatedDifferenceValue > $this->config['maxDifference']) {
$failImagePath = $this->moduleFileSystemUtil->getFailImagePath($referenceImageIdentifier, $windowSizeString, 'diff');
$this->moduleFileSystemUtil->createDirectoryRecursive(dirname($failImagePath));
$image->writeImage($this->moduleFileSystemUtil->getFailImagePath($referenceImageIdentifier, $windowSizeString, 'fail'));
$comparedImage->setImageFormat('png');
$comparedImage->writeImage($failImagePath);
$this->fail('Image does not match to the reference image.');
}
}
}
开发者ID:sascha-egerer,项目名称:css-regression,代码行数:44,代码来源:CssRegression.php
示例13: _before
public function _before(\Codeception\TestCase $test)
{
$this->scenario = $test->getScenario();
}
开发者ID:hitechdk,项目名称:Codeception,代码行数:4,代码来源:EmulateModuleHelper.php
示例14: _failed
public function _failed(\Codeception\TestCase $test, $fail)
{
$output = \Codeception\Configuration::logDir() . DIRECTORY_SEPARATOR . basename($test->getFileName()) . '.page.debug.html';
file_put_contents($output, $this->browser->getResponse()->getContent());
}
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:5,代码来源:Symfony1.php
示例15: _failed
public function _failed(\Codeception\TestCase $test, $error)
{
$this->_saveScreenshot(\Codeception\Configuration::logDir() . basename($test->getFileName()) . '.fail.png');
$this->debug("Screenshot was saved into 'log' dir");
$this->session->stop();
}
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:6,代码来源:Selenium.php
示例16: isExecutedInCurrentEnvironment
protected function isExecutedInCurrentEnvironment(\Codeception\TestCase $test)
{
$envs = $test->getEnvironment();
if (empty($envs)) {
return true;
}
$currentEnvironments = explode(',', $this->env);
foreach ($envs as $envList) {
$envList = explode(',', $envList);
if (count($envList) == count(array_intersect($currentEnvironments, $envList))) {
return true;
}
}
return false;
}
开发者ID:hitechdk,项目名称:Codeception,代码行数:15,代码来源:SuiteManager.php
示例17: checkEnvironmentExists
protected function checkEnvironmentExists(\Codeception\TestCase $test)
{
$envs = $test->getEnvironment();
if (empty($envs)) {
return;
}
if (!isset($this->settings['env'])) {
Notification::warning("Environments are not configured", TestCase::getTestFullName($test));
return;
}
$availableEnvironments = array_keys($this->settings['env']);
$listedEnvironments = explode(',', implode(',', $test->getEnvironment()));
foreach ($listedEnvironments as $env) {
if (!in_array($env, $availableEnvironments)) {
Notification::warning("Environment {$env} was not configured but used in test", TestCase::getTestFullName($test));
}
}
}
开发者ID:hitechdk,项目名称:Codeception,代码行数:18,代码来源:SuiteManager.php
示例18: _failed
public function _failed(\Codeception\TestCase $test, $fail)
{
$filename = str_replace(['::', '\\', '/'], ['.', '', ''], \Codeception\TestCase::getTestSignature($test)) . '.fail.png';
$this->_saveScreenshot(codecept_output_dir($filename));
$this->debug("Screenshot was saved into '_output' dir");
}
开发者ID:Eli-TW,项目名称:Codeception,代码行数:6,代码来源:WebDriver.php
示例19: persist
public function persist(TestEvent $e)
{
if (!$this->webDriverModule or !$this->dir) {
return;
}
$indicatorHtml = '';
$slideHtml = '';
foreach ($this->slides as $i => $step) {
$indicatorHtml .= (new Template($this->indicatorTemplate))->place('step', (int) $i)->place('isActive', (int) $i ? '' : 'class="active"')->produce();
$slideHtml .= (new Template($this->slidesTemplate))->place('image', $i)->place('caption', $step->getHumanizedArguments())->place('isActive', (int) $i ? '' : 'active')->place('isError', $step->hasFailed() ? 'error' : '')->produce();
}
$html = (new Template($this->template))->place('indicators', $indicatorHtml)->place('slides', $slideHtml)->place('feature', ucfirst($e->getTest()->getFeature()))->place('test', TestCase::getTestSignature($e->getTest()))->produce();
$indexFile = $this->dir . DIRECTORY_SEPARATOR . 'index.html';
file_put_contents($indexFile, $html);
$testName = TestCase::getTestSignature($e->getTest()) . ' - ' . ucfirst($e->getTest()->getFeature());
$this->recordedTests[$testName] = substr($indexFile, strlen(codecept_output_dir()));
}
开发者ID:2pisoftware,项目名称:testrunner,代码行数:17,代码来源:ScreenCapture.php
示例20: _failed
public function _failed(TestCase $test, $fail)
{
$this->debugWebDriverLogs();
$filename = str_replace(['::', '\\', '/'], ['.', '', ''], TestCase::getTestSignature($test)) . '.fail';
$this->_saveScreenshot(codecept_output_dir() . $filename . '.png');
$this->_savePageSource(codecept_output_dir() . $filename . '.html');
$this->debug("Screenshot and page source were saved into '_output' dir");
}
开发者ID:nsgomez,项目名称:Codeception,代码行数:8,代码来源:WebDriver.php
注:本文中的Codeception\TestCase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论