当前位置: 首页>>代码示例>>PHP>>正文


PHP Codeception\TestCase类代码示例

本文整理汇总了PHP中Codeception\TestCase的典型用法代码示例。如果您正苦于以下问题:PHP TestCase类的具体用法?PHP TestCase怎么用?PHP TestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TestCase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: run

 public function run()
 {
     foreach ($this->steps as $k => $step) {
         $this->currentStep = $k;
         $this->test->runStep($step);
     }
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:7,代码来源:Scenario.php

示例15: runStep

 public function runStep(Step $step)
 {
     $this->steps[] = $step;
     $result = $this->test->runStep($step);
     $step->executed = true;
     return $result;
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:7,代码来源:Scenario.php


注:本文中的Codeception\TestCase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。