本文整理汇总了PHP中Prophecy\Prophet类的典型用法代码示例。如果您正苦于以下问题:PHP Prophet类的具体用法?PHP Prophet怎么用?PHP Prophet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Prophet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createCategoryDouble
/**
* @param $id
* @return ObjectProphecy
*/
private function createCategoryDouble($id)
{
$prophet = new Prophet();
$categoryDouble = $prophet->prophesize('Prh\\BlogBundle\\Entity\\Category');
$categoryDouble->getId()->willReturn($id);
return $categoryDouble;
}
示例2: Prophet
function it_should_be_able_to_run_processes()
{
$prophet = new Prophet();
$processes = [];
for ($i = 0; $i < 20; $i++) {
$process = $prophet->prophesize(Process::class);
$process->started = false;
$process->terminated = false;
$process->start()->will(function () use($process) {
$process->started = true;
})->shouldBeCalledTimes(1);
$process->isTerminated()->will(function () use($process) {
if (!$process->terminated) {
$process->terminated = true;
return false;
}
return true;
})->shouldBeCalledTimes(2);
// The number of times isStarted() is called starts at 3
// and increases by 2 after each chunk of five processes.
$process->isStarted()->will(function () use($process) {
return $process->started;
})->shouldBeCalledTimes(floor($i / 5) * 2 + 3);
$processes[] = $process->reveal();
}
$this->run($processes);
$prophet->checkPredictions();
}
示例3: testXMLGeneration
/**
* @param Payment $payment
* @param TransactionDetails $transactionDetails
*
* @dataProvider dataProvider
*/
public function testXMLGeneration($payment, $transactionDetails)
{
$prophet = new Prophet();
$orderService = $prophet->prophesize('Checkdomain\\TeleCash\\IPG\\API\\Service\\OrderService');
$sellHosted = new SellHostedData($orderService->reveal(), $payment, $transactionDetails);
$document = $sellHosted->getDocument();
$document->appendChild($sellHosted->getElement());
$elementCCType = $document->getElementsByTagName('ns1:CreditCardTxType');
$this->assertEquals(1, $elementCCType->length, 'Expected element CreditCardTxType not found');
$children = [];
/** @var \DOMNode $child */
foreach ($elementCCType->item(0)->childNodes as $child) {
$children[$child->nodeName] = $child->nodeValue;
}
$this->assertArrayHasKey('ns1:Type', $children, 'Expected element Type not found');
$this->assertEquals('sale', $children['ns1:Type'], 'Type did not match');
$elementPayment = $document->getElementsByTagName('ns1:Payment');
$this->assertEquals(1, $elementPayment->length, 'Expected element Payment not found');
if ($transactionDetails !== null) {
$elementDetails = $document->getElementsByTagName('ns2:TransactionDetails');
$this->assertEquals(1, $elementDetails->length, 'Expected element TransactionDetails not found');
} else {
$elementDetails = $document->getElementsByTagName('ns2:TransactionDetails');
$this->assertEquals(0, $elementDetails->length, 'Unexpected element TransactionDetails was found');
}
}
示例4: mockAuthorizeService
/**
* Mock the authorization service
*
* @param bool $isAllowed
*/
protected function mockAuthorizeService($isAllowed = true)
{
$prophet = new Prophet();
$authorizeService = $prophet->prophesize('\\BjyAuthorize\\Service\\Authorize');
$authorizeService->isAllowed(Argument::cetera())->willReturn($isAllowed);
$this->mockListenerFactory($authorizeService->reveal());
}
示例5: stubMetaData
/**
* @param \Doctrine\Common\Persistence\ObjectManager $objectManager
*/
protected function stubMetaData($objectManager)
{
$prophet = new Prophet();
$meta = $prophet->prophesize('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata');
$meta->getIdentifierFieldNames()->willReturn(['id']);
$meta->getIdentifierValues(Argument::any())->willReturn([1]);
$objectManager->getClassMetadata('stdClass')->willReturn($meta);
}
示例6: Prophet
function it_should_throw_exception_when_buildpath_not_exist()
{
$prophet = new Prophet();
$file = $prophet->prophesize('Illuminate\\Filesystem\\Filesystem');
$file->makeDirectory('dir_bar', 0775, true)->willReturn(false);
$this->beConstructedWith(null, null, $file);
$this->shouldThrow('Devfactory\\Minify\\Exceptions\\DirNotExistException')->duringMake('dir_bar');
}
示例7: addMockDriver
/**
* Add a mock driver
*
* @param string $name
* @return string
*/
protected static function addMockDriver($name)
{
$prophet = new Prophet();
$prophecy = $prophet->prophesize('Jasny\\DB\\Connection');
$class = get_class($prophecy->reveal());
DB::$drivers[$name] = $class;
return $class;
}
示例8: expectingWithoutOptionalParameter
/**
* Calling no optional parameter
*
* @test
* @see https://github.com/php-mock/php-mock-prophecy/issues/1
*/
public function expectingWithoutOptionalParameter()
{
$prophet = new Prophet();
$prophecy = $prophet->prophesize(OptionalParameterHolder::class);
$prophecy->call("arg1")->willReturn("mocked");
$mock = $prophecy->reveal();
$this->assertEquals("mocked", $mock->call("arg1"));
$prophet->checkPredictions();
}
示例9: mockFlashMessenger
/**
* Mock the flashmessenger
*
* @param $flashMessenger
*/
protected function mockFlashMessenger($flashMessenger)
{
$prophet = new Prophet();
$serviceManager = $prophet->prophesize('\\Zend\\ServiceManager\\ServiceManager');
$pluginManager = $prophet->prophesize('\\Zend\\Mvc\\Controller\\PluginManager');
$serviceManager->get('ControllerPluginManager')->willReturn($pluginManager);
$pluginManager->get('flashmessenger')->willReturn($flashMessenger->getWrappedObject());
$this->createService($serviceManager);
}
示例10: mockConfiguration
/**
* @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
*/
protected function mockConfiguration($serviceLocator)
{
$serviceLocator->has('Config')->willReturn(true);
$serviceLocator->get('Config')->willReturn(array('phpro-smartcrud-gateway' => array('custom-gateway' => array('type' => 'smartcrud.base.gateway', 'options' => array('object_manager' => 'ObjectManager')), 'fault-gateway' => array('type' => 'fault-gateway'))));
$prophet = new Prophet();
$objectManager = $prophet->prophesize('Doctrine\\Common\\Persistence\\ObjectManager');
$serviceLocator->has('ObjectManager')->willReturn(true);
$serviceLocator->get('ObjectManager')->willReturn($objectManager);
}
示例11: mockFile
protected function mockFile($name, $isRename = false, $isDelete = false)
{
$prophet = new Prophet();
$file = $prophet->prophesize('Gitonomy\\Git\\Diff\\File');
$file->getName()->willReturn($name);
$file->getNewName()->willReturn($name);
$file->isRename()->willReturn($isRename);
$file->isDeletion()->willReturn($isDelete);
return $file->reveal();
}
示例12: setUp
public function setUp()
{
unset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']);
$prophet = new Prophet();
$this->packageManagerProphecy = $prophet->prophesize(PackageManager::class);
$this->dbProphecy = $prophet->prophesize(\TYPO3\CMS\Core\Database\DatabaseConnection::class);
$GLOBALS['TYPO3_DB'] = $this->dbProphecy->reveal();
$this->updateWizard = new UpdateWizard();
ExtensionManagementUtility::setPackageManager($this->packageManagerProphecy->reveal());
}
示例13: mockFile
protected function mockFile($name, $isRename = false, $isDelete = false)
{
$prophet = new Prophet();
$file = $prophet->prophesize(File::class);
$file->getName()->willReturn($name);
$file->getNewName()->willReturn($name);
$file->isRename()->willReturn($isRename);
$file->isDeletion()->willReturn($isDelete);
return $file->reveal();
}
示例14: it_can_match_repeating_multiple_segments
public function it_can_match_repeating_multiple_segments()
{
$prophet = new Prophet();
$httpProphecy = $prophet->prophesize('Zend\\Uri\\Http');
$httpProphecy->getPath()->willReturn('/a/foo/bar/b/c/bar/bass/d');
$requestProphecy = $prophet->prophesize('Zend\\Http\\PhpEnvironment\\Request');
$requestProphecy->getUri()->willReturn($httpProphecy->reveal());
$this->beConstructedWith('/a[section]/b/c[other_section]/d', ['section' => '/[a-zA-Z][a-zA-Z0-9_-]+', 'other_section' => '/[a-zA-Z][a-zA-Z0-9_-]+'], ['controller' => 'Controller', 'action' => 'create']);
$this->match($requestProphecy->reveal())->shouldReturnAnInstanceOf('Zend\\Mvc\\Router\\Http\\RouteMatch');
}
示例15: getTestPluginService
/**
* Get the service with the stubbed registry
* @return TestPluginService
*/
protected function getTestPluginService()
{
$testPluginService = new TestPluginService();
$prophet = new Prophet();
$prophecy = $prophet->prophesize();
$prophecy->willExtend(PluginRegistry::class);
$prophecy->getMap()->willReturn(self::$pluginData);
$testPluginService->setRegistry($prophecy->reveal());
return $testPluginService;
}