本文整理汇总了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) {
}
}
示例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!'));
}
示例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');
}
示例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();
});
}
示例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()]);
}
示例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());
}