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


PHP Stub::once方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     $backend = Stub::make('Codeception\\Util\\Mink', array('_saveScreenshot' => Stub::once()));
     $backend->session = new \Codeception\Maybe();
     $this->module = Stub::make('Codeception\\Module\\WebDebug', array('getModules' => array($backend)));
     $this->module->_initialize();
     $this->module->_before(Stub::make('Codeception\\TestCase\\Cept'));
 }
开发者ID:lenninsanchez,项目名称:donadores,代码行数:8,代码来源:WebDebugTest.php

示例2: testCreateSnapshotOnFail

 public function testCreateSnapshotOnFail()
 {
     $module = Stub::construct(get_class($this->module), [make_container()], ['_savePageSource' => Stub::once(function ($filename) {
         $this->assertEquals(codecept_log_dir('Codeception.Module.UniversalFramework.looks.like..test.fail.html'), $filename);
     })]);
     $module->amOnPage('/');
     $cest = new \Codeception\Test\Cest($this->module, 'looks:like::test', 'demo1Cest.php');
     $module->_failed($cest, new PHPUnit_Framework_AssertionFailedError());
 }
开发者ID:solutionDrive,项目名称:Codeception,代码行数:9,代码来源:FrameworksTest.php

示例3: testBuildingWithCustomService

 public function testBuildingWithCustomService()
 {
     /* Given... (Fixture) */
     $params = Stub::makeEmpty('GoIntegro\\Hateoas\\JsonApi\\Request\\Params', ['primaryType' => 'users']);
     $defaultBuilder = Stub::makeEmpty('GoIntegro\\Hateoas\\Entity\\AbstractBuilderInterface', ['create' => Stub::never()]);
     $userBuilder = Stub::makeEmpty('GoIntegro\\Hateoas\\Entity\\BuilderInterface', ['create' => Stub::once()]);
     $builder = new Builder();
     $builder->addBuilder($defaultBuilder, Builder::DEFAULT_BUILDER)->addBuilder($userBuilder, 'users');
     /* When... (Action) */
     $entity = $builder->create($params, [], []);
     /* Then... (Assertions) */
 }
开发者ID:gointegro,项目名称:hateoas,代码行数:12,代码来源:BuilderTest.php

示例4: testDeletingWithCustomService

 public function testDeletingWithCustomService()
 {
     /* Given... (Fixture) */
     $params = Stub::makeEmpty('GoIntegro\\Hateoas\\JsonApi\\Request\\Params', ['primaryType' => 'users']);
     $entity = Stub::makeEmpty('GoIntegro\\Hateoas\\JsonApi\\ResourceEntityInterface');
     $defaultDeleter = Stub::makeEmpty('GoIntegro\\Hateoas\\Entity\\DeleterInterface', ['create' => Stub::never()]);
     $userDeleter = Stub::makeEmpty('GoIntegro\\Hateoas\\Entity\\DeleterInterface', ['create' => Stub::once()]);
     $deleter = new Deleter();
     $deleter->addDeleter($defaultDeleter, Deleter::DEFAULT_DELETER)->addDeleter($userDeleter, 'users');
     /* When... (Action) */
     $entity = $deleter->delete($params, $entity);
     /* Then... (Assertions) */
 }
开发者ID:gointegro,项目名称:hateoas,代码行数:13,代码来源:DeleterTest.php

示例5: testDeletingWithCustomService

 public function testDeletingWithCustomService()
 {
     /* Given... (Fixture) */
     $params = Stub::makeEmpty('GoIntegro\\Hateoas\\JsonApi\\Request\\Params', ['primaryType' => 'users']);
     $entity = Stub::makeEmpty('GoIntegro\\Hateoas\\JsonApi\\ResourceEntityInterface');
     $defaultMutator = Stub::makeEmpty('GoIntegro\\Hateoas\\Entity\\MutatorInterface', ['create' => Stub::never()]);
     $userMutator = Stub::makeEmpty('GoIntegro\\Hateoas\\Entity\\MutatorInterface', ['create' => Stub::once()]);
     $mutator = new Mutator();
     $mutator->addMutator($defaultMutator, Mutator::DEFAULT_MUTATOR)->addMutator($userMutator, 'users');
     /* When... (Action) */
     $entity = $mutator->update($params, $entity, [], []);
     /* Then... (Assertions) */
 }
开发者ID:gointegro,项目名称:hateoas,代码行数:13,代码来源:MutatorTest.php

示例6: testGettingMappingForEntity

 public function testGettingMappingForEntity()
 {
     /* Given... (Fixture) */
     $callOnce = Stub::once(function () {
         return "The mapping.";
     });
     $entityManager = Stub::makeEmpty('Doctrine\\ORM\\EntityManagerInterface', ['getClassMetadata' => $callOnce]);
     $metadataCache = new ArrayMetadataCache($entityManager);
     /* When... (Action) */
     $classMapping = $metadataCache->getMapping('GoIntegro\\Hateoas\\JsonApi\\ResourceEntityInterface');
     $sameMapping = $metadataCache->getMapping('GoIntegro\\Hateoas\\JsonApi\\ResourceEntityInterface');
     /* Then... (Assertions) */
     $this->assertEquals('The mapping.', $classMapping);
     $this->assertEquals($classMapping, $sameMapping);
 }
开发者ID:gointegro,项目名称:hateoas,代码行数:15,代码来源:ArrayMetadataCacheTest.php

示例7: testMe

 public function testMe()
 {
     /** @var CacheItemPoolInterface $pool */
     $pool = Stub::makeEmpty(CacheItemPoolInterface::class, ['getItem' => Stub::atLeastOnce(function () {
         return Stub::makeEmpty(CacheItemInterface::class, ['isHit' => Stub::once(function () {
             return false;
         }), 'set' => Stub::once(function () {
         }), 'get' => Stub::once(function () {
         })]);
     }), 'save' => Stub::exactly(2, function () {
     })]);
     $router = new \axisy\router\ContainerCacheable($pool, ['foo' => function () {
     }, 'bar' => function () {
     }]);
     try {
         $router->route('foo');
     } catch (ErrorException $e) {
     }
 }
开发者ID:axisy,项目名称:router,代码行数:19,代码来源:CacheTest.php

示例8: testBeforeTestProfiler

 public function testBeforeTestProfiler()
 {
     $this->specify('profiler should invoke before test event', function ($config, $options, $testCaseClass, $testCaseName) {
         /** @var Profiler $profiler */
         $profiler = Stub::construct('\\Codeception\\Extension\\Profiler', [$config, $options], ['beforeTest' => Stub::once()]);
         $this->eventsManager->addSubscriber($profiler);
         /** @var Test $testCase */
         $testCase = Stub::construct($testCaseClass, ['name' => $testCaseName]);
         $this->eventsManager->dispatch(Events::TEST_BEFORE, new TestEvent($testCase));
         $this->tester->addStubToVerify($profiler);
     }, ['examples' => $this->getBeforeTestProfilerData()]);
     $this->specify('profiler should be initialized', function ($config, $options, $testCaseClass, $testCaseName) {
         $profiler = new Profiler($config, $options);
         $this->eventsManager->addSubscriber($profiler);
         /** @var Test $testCase */
         $testCase = Stub::construct($testCaseClass, ['name' => $testCaseName]);
         $this->eventsManager->dispatch(Events::TEST_BEFORE, new TestEvent($testCase));
         $profileData = $this->tester->getProtectedProperty($profiler, 'profile');
         $this->assertArrayHasKey(get_class($testCase), $profileData);
     }, ['examples' => $this->getBeforeTestProfilerData()]);
 }
开发者ID:tankist,项目名称:codeception-profiler,代码行数:21,代码来源:ProfilerTest.php

示例9: testImport

 public function testImport()
 {
     $this->specify("должен бросать исключение если файлы импорта не существуют", function () {
         $er = new ExchangeRates();
         $er->parse('fail.file');
     }, ['throws' => 'PHPExcel_Reader_Exception']);
     $this->specify("должен бросать исключение если не возможно определить какие курсы валют в нем содержатся", function () {
         $er = new ExchangeRates();
         $er->parse($this->data('wrong.xls'));
     }, ['throws' => 'Matchish\\Exceptions\\ExchangeRatesParseException']);
     $this->specify("должен правильно определять тип курсов в файле", function ($filename, $parserClassName) {
         Stub::make($parserClassName, array('parse' => Stub::once(function () {
             return [];
         })));
         $er = new ExchangeRates();
         $er->parse($this->data($filename));
     }, ['examples' => [['cash.xls', '\\Matchish\\ExchangeRatesCashParser'], ['card.xls', '\\Matchish\\ExchangeRatesCardParser']]]);
     $this->specify("должен принимать массив имен файлов", function () {
         $er = new ExchangeRates();
         $er->parse([$this->data('cash.xls'), $this->data('card.xls')]);
     });
 }
开发者ID:Husband,项目名称:test-assigments,代码行数:22,代码来源:ExchangeRatesTest.php

示例10: matcherProvider

 public static function matcherProvider()
 {
     return array(array(0, Stub::never()), array(1, Stub::once()), array(2, Stub::atLeastOnce()), array(3, Stub::exactly(3)), array(1, Stub::once(function () {
         return true;
     }), true), array(2, Stub::atLeastOnce(function () {
         return array();
     }), array()), array(1, Stub::exactly(1, function () {
         return null;
     }), null), array(1, Stub::exactly(1, function () {
         return 'hello world!';
     }), 'hello world!'));
 }
开发者ID:hitechdk,项目名称:Codeception,代码行数:12,代码来源:StubTest.php

示例11: testCreateTestScreenshotOnFail

 public function testCreateTestScreenshotOnFail()
 {
     $test = Stub::make('\\Codeception\\TestCase\\Test', ['getName' => 'testLogin']);
     $fakeWd = Stub::make(self::WEBDRIVER_CLASS, ['takeScreenshot' => Stub::once(function ($filename) use($test) {
         PHPUnit_Framework_Assert::assertEquals(codecept_log_dir(get_class($test) . '.testLogin.fail.png'), $filename);
     }), 'getPageSource' => Stub::once(function () {
     }), 'manage' => Stub::make('\\Facebook\\WebDriver\\WebDriverOptions', ['getAvailableLogTypes' => Stub::atLeastOnce(function () {
         return [];
     })])]);
     $module = Stub::make(self::MODULE_CLASS, ['webDriver' => $fakeWd]);
     $module->_failed($test, new PHPUnit_Framework_AssertionFailedError());
 }
开发者ID:surjit,项目名称:Codeception,代码行数:12,代码来源:WebDriverTest.php

示例12: testCreateTestScreenshotOnFail

 public function testCreateTestScreenshotOnFail()
 {
     $test = Stub::make('\\Codeception\\TestCase\\Test', ['getName' => 'testLogin']);
     $fakeWd = Stub::make('\\RemoteWebDriver', ['takeScreenshot' => Stub::once(function ($filename) use($test) {
         PHPUnit_Framework_Assert::assertEquals(codecept_log_dir(get_class($test) . '.testLogin.fail.png'), $filename);
     }), 'getPageSource' => Stub::once(function () {
     })]);
     $this->module->webDriver = $fakeWd;
     $this->module->_failed($test, new PHPUnit_Framework_AssertionFailedError());
 }
开发者ID:augustus-amalejo,项目名称:palittayo,代码行数:10,代码来源:WebDriverTest.php

示例13: testAsClass

 /**
  * Test for asClass method
  *
  * ./vendor/bin/codecept run unit SoapClientTest.php:testAsClass
  *
  * @return void
  *
  * @covers \ITMH\Soap\Client::asClass
  */
 public function testAsClass()
 {
     $object = Stub::make(self::CLASS_NAME, ['mapObject' => Stub::once()], $this);
     /* @var \ITMH\Soap\Client $object */
     $data = ['root' => (object) ['foo' => 'bar']];
     $object->asClass((object) $data);
 }
开发者ID:itmh,项目名称:soap-client,代码行数:16,代码来源:SoapClientTest.php

示例14: testFindAll

 public function testFindAll()
 {
     $stub_record = Stub::makeEmptyExcept('Comment', 'findAll', ['findBy' => Stub::once(function () {
         return true;
     })]);
     $stub_record->findAll();
 }
开发者ID:arduanov,项目名称:simple-record,代码行数:7,代码来源:SimpleRecordTest.php

示例15: testCreateTestScreenshotOnFail

 public function testCreateTestScreenshotOnFail()
 {
     $test = Stub::make('\\Codeception\\TestCase\\Test', ['getName' => 'testLogin']);
     $wd = Stub::make('\\Codeception\\Module\\WebDriver', ['_saveScreenshot' => Stub::once(function ($actual) use($test) {
         PHPUnit_Framework_Assert::assertEquals(codecept_log_dir(get_class($test) . '.testLogin.fail.png'), $actual);
     })]);
     $wd->_failed($test, new PHPUnit_Framework_AssertionFailedError());
 }
开发者ID:Eli-TW,项目名称:Codeception,代码行数:8,代码来源:WebDriverTest.php


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