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


PHP Stub::atLeastOnce方法代码示例

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


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

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

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

示例3: testSaveSessionSnapshotsExcludeInvalidCookieDomains

 public function testSaveSessionSnapshotsExcludeInvalidCookieDomains()
 {
     $this->notForPhantomJS();
     $fakeWdOptions = Stub::make('\\Facebook\\WebDriver\\WebDriverOptions', ['getCookies' => Stub::atLeastOnce(function () {
         return [['name' => 'PHPSESSID', 'value' => '123456', 'path' => '/'], ['name' => '3rdParty', 'value' => '_value_', 'path' => '/', 'domain' => '.3rd-party.net']];
     })]);
     $fakeWd = Stub::make(self::WEBDRIVER_CLASS, ['manage' => Stub::atLeastOnce(function () use($fakeWdOptions) {
         return $fakeWdOptions;
     })]);
     // Mock the WebDriverOptions::getCookies() method on the first call to introduce a 3rd-party cookie
     // which has to be ignored when saving a snapshot.
     $originalWebDriver = $this->module->webDriver;
     $this->module->webDriver = $fakeWd;
     $this->module->seeCookie('PHPSESSID');
     $this->module->seeCookie('3rdParty');
     $this->module->saveSessionSnapshot('login');
     // Restore the original WebDriver
     $this->module->webDriver = $originalWebDriver;
     $this->webDriver->manage()->deleteAllCookies();
     $this->module->dontSeeCookie('PHPSESSID');
     $this->module->dontSeeCookie('3rdParty');
     $this->module->loadSessionSnapshot('login');
     $this->module->seeCookie('PHPSESSID');
     $this->module->dontSeeCookie('3rdParty');
 }
开发者ID:surjit,项目名称:Codeception,代码行数:25,代码来源:WebDriverTest.php

示例4: testRolenameIsUniqueSpecification

 public function testRolenameIsUniqueSpecification()
 {
     $role = $this->prepareRole();
     $this->specify("Set rolename for new role with existing rolename", function () use($role) {
         $roleRepository = Stub::makeEmpty('Inoplate\\Account\\Domain\\Repositories\\Role', ['findByName' => Stub::atLeastOnce(function () use($role) {
             return $role;
         })], $this);
         $specification = new AccountDomainSpecifications\RolenameIsUnique($roleRepository);
         expect("Specification is not satisfied", $specification->isSatisfiedBy($role->name()))->false();
     });
     $this->specify("Set rolename for existing role with another existing role's name", function () use($role) {
         $roleRepository = Stub::makeEmpty('Inoplate\\Account\\Domain\\Repositories\\Role', ['findByName' => Stub::atLeastOnce(function () use($role) {
             return $role;
         })], $this);
         $specification = new AccountDomainSpecifications\RolenameIsUnique($roleRepository, new AccountDomainModels\RoleId('56678'));
         expect("Specification is not satisfied", $specification->isSatisfiedBy($role->name()))->false();
     });
     $this->specify("Set rolename for existing role with same rolename", function () use($role) {
         $roleRepository = Stub::makeEmpty('Inoplate\\Account\\Domain\\Repositories\\Role', ['findByName' => Stub::atLeastOnce(function () use($role) {
             return $role;
         })], $this);
         $specification = new AccountDomainSpecifications\RolenameIsUnique($roleRepository, new AccountDomainModels\RoleId('789010'));
         expect("Specification is satisfied", $specification->isSatisfiedBy($role->name()))->true();
     });
     $this->specify("Set rolename for existing role with same rolename", function () use($role) {
         $roleRepository = Stub::makeEmpty('Inoplate\\Account\\Domain\\Repositories\\Role', ['findByName' => Stub::atLeastOnce(function () use($role) {
             return null;
         })], $this);
         $specification = new AccountDomainSpecifications\RolenameIsUnique($roleRepository);
         expect("Specification is satisfied", $specification->isSatisfiedBy($role->name()))->true();
     });
 }
开发者ID:inoplate,项目名称:account,代码行数:32,代码来源:SpecificationTest.php

示例5: testCanIgnoreTest

 public function testCanIgnoreTest()
 {
     $this->specify('testcase should be ignored if @ignoreProfiler class annotation met', function ($config, $options, $testCaseClass, $testCaseName, $timeout, $annotations, $expectedOutput) {
         $profiler = new Profiler($config, $options);
         $outputData = '';
         $output = Stub::construct('\\Codeception\\Lib\\Console\\Output', [$options], ['write' => Stub::atLeastOnce(function ($messages) use(&$outputData) {
             $outputData .= $messages;
         })]);
         $this->tester->setProtectedProperty($profiler, 'output', $output);
         $this->eventsManager->addSubscriber($profiler);
         /** @var \PHPUnit_Framework_TestResult $testResult */
         $testResult = Stub::makeEmpty('\\PHPUnit_Framework_TestResult');
         /** @var \PHPUnit_Util_Printer $printer */
         $printer = Stub::makeEmpty('\\PHPUnit_Util_Printer');
         $testCase = $this->getMockBuilder('\\Codeception\\TestCase\\Test')->setMethods(['getAnnotations'])->setMockClassName($testCaseClass)->getMock();
         $testCase->expects($this->exactly(2))->method('getAnnotations')->will($this->returnValue($annotations));
         /** @var Test $testCase */
         $testCase->setName($testCaseName);
         $this->eventsManager->dispatch(Events::TEST_BEFORE, new TestEvent($testCase));
         usleep($timeout * 1000000.0);
         $this->eventsManager->dispatch(Events::TEST_END, new TestEvent($testCase));
         $this->eventsManager->dispatch(Events::RESULT_PRINT_AFTER, new PrintResultEvent($testResult, $printer));
         $this->assertProfileOutput($expectedOutput, $outputData);
     }, ['examples' => $this->getTestIgnoreAnnotationsData()]);
 }
开发者ID:tankist,项目名称:codeception-profiler,代码行数:25,代码来源:ProfilerTest.php

示例6: testMapMethodResponse

 /**
  * Test for testMapMethodResponse method success result
  *
  * ./vendor/bin/codecept run unit MapperTest.php:testMapMethodResponse
  *
  * @return void
  *
  * @covers       \ITMH\Soap\Mapper::mapMethodResponse
  */
 public function testMapMethodResponse()
 {
     $mapper = Stub::make('\\ITMH\\Soap\\Mapper', ['mapData' => Stub::atLeastOnce(), 'unwrapItem' => Stub::atLeastOnce()]);
     /* @var \ITMH\Soap\Mapper $mapper */
     self::assertEquals([], $mapper->mapMethodResponse('method', []));
     $mapper->setConfig(['method' => ['root' => 'ClassName']]);
     $mapper->mapMethodResponse('method', new stdClass());
     $mapper->setConfig(['method' => ['class' => 'ClassName']]);
     $mapper->mapMethodResponse('method', new stdClass());
 }
开发者ID:itmh,项目名称:soap-client,代码行数:19,代码来源:MapperTest.php


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