本文整理汇总了PHP中Mockery::mustBe方法的典型用法代码示例。如果您正苦于以下问题:PHP Mockery::mustBe方法的具体用法?PHP Mockery::mustBe怎么用?PHP Mockery::mustBe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mockery
的用法示例。
在下文中一共展示了Mockery::mustBe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createDirGenTest
protected function createDirGenTest($baseDir, $dir)
{
$this->fs->shouldReceive('exists')->once()->with(m::mustBe(Path::join($baseDir, $dir)))->andReturn(false);
$this->fs->shouldReceive('makeDirectory')->once()->with(m::mustBe(Path::join($baseDir, $dir)), m::mustBe(0755), m::mustBe(true))->andReturn(true);
$generator = $this->generator->generateDirectoryStructure($baseDir, [$dir]);
$this->assertInstanceOf(StubGenerator::class, $generator);
}
示例2: __construct
public function __construct()
{
$this->config = new Conf();
$this->request = new Request();
$this->batchrequest = m::mock("Optimus\\BatchRequest\\BatchRequest");
$this->batchrequest->shouldReceive('request')->with(m::mustBe($this->request->get()))->andReturn(["json" => "data"]);
}
示例3: testFindByCampusIdsOnlyUseUnique
/**
* @covers Ilios\CoreBundle\Service\Directory::findByCampusId
*/
public function testFindByCampusIdsOnlyUseUnique()
{
$ldapManager = m::mock('Ilios\\CoreBundle\\Service\\LdapManager');
$obj = new Directory($ldapManager, 'campusId');
$ldapManager->shouldReceive('search')->with(m::mustBe('(|(campusId=1234)(campusId=1235))'))->andReturn(array(1));
$result = $obj->findByCampusIds([1234, 1235, 1234, 1235]);
$this->assertSame($result, [1]);
}
示例4: testRouterIsFired
public function testRouterIsFired()
{
$batchRequest = m::mock('Optimus\\BatchRequest\\BatchRequest[prepareResults]', [$this->routerMock, $this->configMock, new \Optimus\BatchRequest\ResultFormatter\OptimusResultFormatter(), new \Optimus\BatchRequest\ResponseFormatter\OptimusResponseFormatter(), $this->dbMock]);
$this->dbMock->shouldReceive('beginTransaction')->times(1);
$this->routerMock->shouldReceive('batch')->times(1)->with(m::mustBe([['method' => 'GET', 'action' => 'action1', 'key' => 'request']]));
$batchRequest->shouldReceive('prepareResults')->times(1);
$results = $batchRequest->request([['method' => 'GET', 'action' => 'action1', 'key' => 'request']]);
}
示例5: createFillFixture
/**
* Creates fixture for "Form::fill" method testing.
*
* @param Form $form Form.
* @param string $field_name Field name.
* @param string $field_value Field value.
*
* @return void
*/
protected function createFillFixture(Form $form, $field_name, $field_value)
{
$node_elements = array($this->createNodeElement());
$typified_element = m::mock(self::TYPIFIED_ELEMENT_CLASS);
$form->shouldReceive('getNodeElements')->with($field_name)->once()->andReturn($node_elements);
$form->shouldReceive('typify')->with(m::mustBe($node_elements))->once()->andReturn($typified_element);
$form->shouldReceive('setValue')->with($typified_element, $field_value)->once()->andReturn($form);
}
示例6: testRemove
public function testRemove()
{
$phpunit = $this;
$request = m::mock('jyggen\\Curl\\RequestInterface');
$headerbag = new HeaderBag(array(), $request);
$request->shouldReceive('setOption')->times(1)->with(m::mustBe(CURLOPT_HTTPHEADER), m::type('array'));
$headerbag->remove('foo');
}
示例7: testOk
public function testOk()
{
$context = $this->createContextMock();
$contextResolved = $this->createContextMock();
$result = new \stdClass();
$this->contextResolver->shouldReceive('resolve')->with($context)->once()->andReturn($contextResolved)->ordered();
$this->delegate->shouldReceive('create')->with(\Mockery::mustBe($contextResolved))->once()->andReturn($result)->ordered();
$this->assertSame($result, $this->creator->create($context));
}
示例8: testStatus
public function testStatus()
{
$body = m::mock(\Psr\Http\Message\StreamInterface::class);
$body->shouldReceive('getContents')->once()->andReturn('{"success": "Rolled back"}');
$response = m::mock(\Psr\Http\Message\ResponseInterface::class);
$response->shouldReceive('getBody')->once()->andReturn($body);
$client = m::mock(\GuzzleHttp\Client::class);
$client->shouldReceive('request')->with(m::mustBe('POST'), m::mustBe($this->config['remote_endpoint'] . '?cmd=status'), new PayloadMatcher(['headers', 'form_params']))->once()->andReturn($response);
$this->httpServer->setClient($client);
$this->httpServer->status();
}
示例9: testCustomResultAcknowledgementHandler
public function testCustomResultAcknowledgementHandler()
{
$handler = new ResultAcknowledgementHandler(function ($result) {
return $result === false;
}, $this->handler);
$this->message->shouldReceive('isValid')->once()->withNoArgs()->andReturn(true);
$this->adapter->shouldReceive('acknowledge')->once()->with(m::mustBe([$this->message]));
$handler($this->messages, $this->adapter, function ($msg) {
return false;
});
}
示例10: testOk
public function testOk()
{
$client = $this->createClient();
$userId = '2';
$scope = 'foo';
$scopes = new ScopeCollection([new Scope($scope)]);
$context = new Context($client, $userId, $scopes);
$inputData = ['user_id' => $userId, 'scope' => $scope];
$returnData = new \stdClass();
$this->scopesObtainer->shouldReceive('getScopes')->with($inputData)->once()->andReturn($scopes);
$this->tokenCreator->shouldReceive('create')->with(\Mockery::mustBe($context))->once()->andReturn($returnData);
$this->assertSame($returnData, $this->processor->process($client, $inputData));
}
示例11: testHandleWorkerWithThrownException
public function testHandleWorkerWithThrownException()
{
$handler = $this->handler;
$this->messageA->shouldReceive('isValid')->once()->withNoArgs()->andReturn(true);
$this->messageB->shouldReceive('isValid')->once()->withNoArgs()->andReturn(true);
// @see https://github.com/padraic/mockery/issues/331
$this->adapter->shouldReceive('acknowledge')->once()->with(m::mustBe([$this->messageA]));
$this->setExpectedException('RuntimeException', 'foo');
$handler($this->messages, $this->adapter, function ($msg) {
if ($msg === $this->messageB) {
throw new RuntimeException('foo');
}
});
}
示例12: testMakeStack
public function testMakeStack()
{
/**
* @var \Radic\BladeExtensions\Helpers\EmbedStack $stack
*/
$stack = $this->stack->start();
$this->assertEquals($stack, $this->stack);
// little trick to set the include($path) to the file we want in stack::end
$stack->setData(['path' => __DIR__ . '/embed_stack_include.php', 'sf' => 'mmo']);
$content = <<<EOT
@section("one", "oneval")
@section("two", "twoval")
EOT;
$contentCompiled = <<<'EOT'
<?php $__env->startSection("one", "oneval"); ?>
<?php $__env->startSection("two", "twoval"); ?>
EOT;
$viewContent = <<<'EOT'
1:@yield('one')
2:@yield('two')
EOT;
$viewContentCompiled = <<<'EOT'
1:oneval
2:twoval
EOT;
$stack->setContent($content);
$this->bc->shouldReceive('compileString')->with(m::mustBe($content))->andReturn($contentCompiled);
$this->vf->shouldReceive('getFinder')->andReturn($finder = m::mock('Illuminate\\View\\ViewFinderInterface'));
$absoluteViewPath = realpath(__DIR__ . '/../views/embed.blade.php');
$finder->shouldReceive('find')->andReturn($absoluteViewPath);
$this->fs->shouldReceive('get')->with(m::mustBe($absoluteViewPath))->andReturn($viewContent);
$this->bc->shouldReceive('compileString')->with(m::mustBe($viewContent))->andReturn($viewContentCompiled);
$this->fs->shouldReceive('exists')->andReturn(true);
$this->fs->shouldReceive('put')->andReturn();
//->andSet()andReturn(['name', __DIR__ . '/embed_stack_include.php']);
$this->fs->shouldReceive('delete')->andReturn();
$this->stack->end();
$output = 'thisispath
';
$this->expectOutputString($output);
//fwrite(STDERR, print_r($end, TRUE));
}
示例13: shouldSearchAccount
protected function shouldSearchAccount(AccountOwner $owner, Account $account = null)
{
$this->accountRepository()->shouldReceive('search')->once()->with(m::mustBe($owner))->andReturn($account);
}
示例14: __call
/**
* Intercept all calls on the subject, and use the call details to create
* a new expectation. The actual return value is then returned after being
* recorded.
*
* @param string $method
* @param array $args
* @return mixed
*/
public function __call($method, array $args)
{
$return = call_user_func_array(array($this->_subject, $method), $args);
$expectation = $this->_mock->shouldReceive($method)->andReturn($return);
if ($this->_strict) {
$exactArgs = array();
foreach ($args as $arg) {
$exactArgs[] = \Mockery::mustBe($arg);
}
$expectation->once()->ordered();
call_user_func_array(array($expectation, 'with'), $exactArgs);
} else {
call_user_func_array(array($expectation, 'with'), $args);
}
return $return;
}
示例15: shouldHandleEvent
protected function shouldHandleEvent(Message $event)
{
$this->eventBus()->shouldReceive('handle')->once()->with(m::mustBe($event))->andReturnNull();
}