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


PHP TestCase::getScenario方法代码示例

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


在下文中一共展示了TestCase::getScenario方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRunFailedTestEvent

 public function testRunFailedTestEvent()
 {
     $events = array();
     $this->dispatcher->addListener('test.fail', function () use(&$events) {
         $events[] = 'test.fail';
     });
     $this->testcase->getScenario()->assertion(array('seeEquals', 5, 6));
     $this->testcase->run();
     $this->assertEquals($events, array('test.fail'));
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:10,代码来源:TestCaseTest.php

示例2: 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

示例3: createMocks

 /**
  * Very magical function that generates Mock methods for expected assertions
  * Allows the declaration of seeMethodInvoked, seeMethodNotInvoked, etc, AFTER the 'execute' command
  *
  */
 protected function createMocks()
 {
     $scenario = $this->test->getScenario();
     $steps = $scenario->getSteps();
     if (!isset($steps[$scenario->getCurrentStep()])) {
         throw new \Exception("New steps were added to scenario in realtime. Can't proceed.\nRemove loops from your unit test to fix it");
     }
     for ($i = $scenario->getCurrentStep() + 1; $i < count($steps); $i++) {
         $step = $steps[$i];
         if (strpos($action = $step->getAction(), 'seeMethod') === 0) {
             $arguments = $step->getArguments(false);
             $mock = array_shift($arguments);
             $function = array_shift($arguments);
             $params = array_shift($arguments);
             foreach ($this->stubs as $stub) {
                 if (get_class($stub) == get_class($mock)) {
                     $mock = $stub;
                 }
             }
             $invoke = false;
             switch ($action) {
                 case 'seeMethodInvoked':
                 case 'seeMethodInvokedAtLeastOnce':
                     if (!$mock) {
                         throw new \InvalidArgumentException("Stub class not defined");
                     }
                     $invoke = new \PHPUnit_Framework_MockObject_Matcher_InvokedAtLeastOnce();
                     break;
                 case 'seeMethodInvokedOnce':
                     if (!$mock) {
                         throw new \InvalidArgumentException("Stub class not defined");
                     }
                     $invoke = new \PHPUnit_Framework_MockObject_Matcher_InvokedCount(1);
                     break;
                 case 'seeMethodNotInvoked':
                     if (!$mock) {
                         throw new \InvalidArgumentException("Stub class not defined");
                     }
                     $invoke = new \PHPUnit_Framework_MockObject_Matcher_InvokedCount(0);
                     break;
                 case 'seeMethodInvokedMultipleTimes':
                     if (!$mock) {
                         throw new \InvalidArgumentException("Stub class not defined");
                     }
                     $times = $params;
                     if (!is_int($times)) {
                         throw new \InvalidArgumentException("Invoked times count should be an integer");
                     }
                     $params = $arguments;
                     $invoke = new \PHPUnit_Framework_MockObject_Matcher_InvokedCount($times);
                     break;
                 default:
             }
             if ($invoke) {
                 $mockMethod = $mock->expects($invoke)->method($function);
                 $this->debug(get_class($invoke) . ' attached');
                 if ($params) {
                     call_user_func_array(array($mockMethod, 'with'), $params);
                     $this->debug('with ' . json_encode($params));
                 }
             }
         }
         if ($step->getAction() == 'executeTestedMethod') {
             break;
         }
         if ($step->getAction() == 'execute') {
             break;
         }
         if ($step->getAction() == 'executeTestedMethodOn') {
             break;
         }
         if ($step->getAction() == 'executeTestedMethodWith') {
             break;
         }
     }
 }
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:81,代码来源:Unit.php

示例4: _before

 public function _before(\Codeception\TestCase $test)
 {
     $this->scenario = $test->getScenario();
 }
开发者ID:hitechdk,项目名称:Codeception,代码行数:4,代码来源:EmulateModuleHelper.php


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