本文整理汇总了PHP中Mockery::type方法的典型用法代码示例。如果您正苦于以下问题:PHP Mockery::type方法的具体用法?PHP Mockery::type怎么用?PHP Mockery::type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mockery
的用法示例。
在下文中一共展示了Mockery::type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testNoFirewall
public function testNoFirewall()
{
$this->tokenStorage->shouldReceive('getToken')->andReturnNull();
$this->authorizationChecker->shouldNotReceive('isGranted');
$this->accessDecisionManager->shouldReceive('decide')->once()->with(\Mockery::type('Symfony\\Component\\Security\\Core\\Authentication\\Token\\AnonymousToken'), array(PublishWorkflowChecker::VIEW_ATTRIBUTE), $this->document)->andReturn(true);
$this->assertTrue($this->publishWorkflowChecker->isGranted(PublishWorkflowChecker::VIEW_ATTRIBUTE, $this->document));
}
示例2: canWriteToOutput
/**
* @test
*
* @dataProvider logDataProvider
*
* @covers ::log
*
* @covers ::interpolate
*
* @param string $level
* @param string $message
* @param array $context [optional]
*/
public function canWriteToOutput($level, $message, array $context = [])
{
$output = $this->makeOutputMock();
$output->shouldReceive('writeln')->once()->with(m::type('string'));
$writer = $this->makeConsoleWriter($output);
$writer->log($level, $message, $context);
}
示例3: testMakePassingConfig
public function testMakePassingConfig()
{
$config = ['Reports' => ['permissions' => ['isStaff'], 'url' => 'reports']];
$menu = m::mock('App\\Http\\Composers\\NavMenuComposer[build,filter]', [$this->app['menu'], $this->config, $this->auth, $this->gate]);
$menu->shouldReceive('build')->once()->with($config, m::type('Caffeinated\\Menus\\Builder'));
$menu->make('Profile', $config);
}
示例4: it_should_write_events_to_eventstore_on_flush
/**
* @test
* @covers ::commit
* @covers ::push
*/
public function it_should_write_events_to_eventstore_on_flush()
{
$expectedEvents = [new WritableEvent(new UUID(), '123', [])];
$this->eventstore->shouldReceive('writeToStream')->once()->with('streamUri', m::type(WritableEventCollection::class));
$this->transaction->push('streamUri', $expectedEvents);
$this->transaction->commit();
}
示例5: testSend
public function testSend()
{
$user = m::mock();
$user->shouldReceive('getActivationCode')->once()->andReturn('secretC0d3');
Mail::shouldReceive('queue')->once()->with(m::type('array'), array('user' => $user, 'code' => 'secretC0d3'), m::type('closure'));
$this->activation->send($user);
}
示例6: testUpMigrationCanBePretended
public function testUpMigrationCanBePretended()
{
list($migrator, $repository, $filesystem, $resolver) = $this->getMocks();
$filesystem->shouldReceive('glob')->once()->with(__DIR__ . '/*_*.php')->andReturn(array(__DIR__ . '/2_bar.php', __DIR__ . '/1_foo.php', __DIR__ . '/3_baz.php'));
$filesystem->shouldReceive('requireOnce')->with(__DIR__ . '/2_bar.php');
$filesystem->shouldReceive('requireOnce')->with(__DIR__ . '/1_foo.php');
$filesystem->shouldReceive('requireOnce')->with(__DIR__ . '/3_baz.php');
$repository->shouldReceive('getRan')->once()->andReturn(array('1_foo'));
$repository->shouldReceive('getNextBatchNumber')->once()->andReturn(1);
$barMock = M::mock('stdClass');
$barMock->shouldReceive('getConnection')->once()->andReturn(null);
$barMock->shouldReceive('up')->once();
$bazMock = M::mock('stdClass');
$bazMock->shouldReceive('getConnection')->once()->andReturn(null);
$bazMock->shouldReceive('up')->once();
$migrator->expects($this->at(0))->method('resolve')->with($this->equalTo('2_bar'))->will($this->returnValue($barMock));
$migrator->expects($this->at(1))->method('resolve')->with($this->equalTo('3_baz'))->will($this->returnValue($bazMock));
$connection = M::mock('stdClass');
$connection->shouldReceive('pretend')->with(M::type('Closure'))->andReturnUsing(function ($closure) {
$closure();
return array(array('query' => 'foo'));
}, function ($closure) {
$closure();
return array(array('query' => 'bar'));
});
$resolver->shouldReceive('connection')->with(null)->andReturn($connection);
$migrator->run(__DIR__, true);
}
示例7: testCompilerPassesAreRegistered
public function testCompilerPassesAreRegistered()
{
$container = m::mock('Symfony\\Component\\DependencyInjection\\ContainerBuilder');
$container->shouldReceive('addCompilerPass')->once()->with(m::type('Dpn\\XmlSitemapBundle\\DependencyInjection\\Compiler\\GeneratorCompilerPass'));
$bundle = new DpnXmlSitemapBundle();
$bundle->build($container);
}
示例8: testAddFilterFromValidator
public function testAddFilterFromValidator()
{
$router = m::mock('Illuminate\\Routing\\Router');
$router->shouldReceive('addFilter')->once()->with('validator.login', m::type('Closure'));
$factory = new Factory($this->request, m::mock('Illuminate\\Validation\\Factory'), $router);
$factory->add('login', 'ValidatorStub2');
}
示例9: testLoadsServiceProvider
public function testLoadsServiceProvider()
{
$container = Mockery::mock('League\\Container\\Container');
$container->shouldReceive('delegate')->once();
$container->shouldReceive('addServiceProvider')->once()->with(Mockery::type('Jenssegers\\Lean\\SlimServiceProvider'));
$app = new App($container);
}
示例10: testDestroySuccessReturnsOkResponse
public function testDestroySuccessReturnsOkResponse()
{
$this->mockService->shouldReceive('remove')->once()->with(m::type('integer'))->andReturn(true);
$this->mockResponse->shouldReceive('create')->once()->with(m::type('array'))->andReturn($this->mockResponse);
$response = $this->controller->destroy(1000);
$this->assertInstanceOf('Illuminate\\Http\\JsonResponse', $response);
}
示例11: testHandle
/**
* A basic test example.
*
* @return void
*/
public function testHandle()
{
// $this->expectsEvents(App\Events\ActionCreatedEvent::class, App\Events\TicketCreatedEvent::class);
// $fetch = m::mock('App\Jobs\FetchEmailJob[getServer,getMessages,anonymousUser,createTicket,buildActions,processEmail]', [$this->email]);
$piper = m::mock('App\\Services\\Piper\\Piper');
$piper->shouldReceive('fetch')->once()->with(m::type('App\\Email'));
$fetch = new FetchEmailJob($this->email);
$fetch->handle($piper);
// $messages = [m::mock('Fetch\Message'), m::mock('Fetch\Message'), m::mock('Fetch\Message')];
// $server = m::mock();
// $server->shouldReceive('getMessages')->once()->andReturn($messages);
// $server->shouldReceive('getServerString')->once();
// $server->shouldReceive('numMessages')->once();
// Log::shouldReceive('debug')->once();
// $fetch->shouldReceive('getServer')->once()->andReturn($server);
// $fetch->shouldReceive('anonymousUser')->times(3)->andReturn(collect());
// // $fetch->shouldReceive('getAssigned')->times(3)->andReturn(collect());
// $fetch->shouldReceive('createTicket')->times(3)->andReturn(collect(['ticket' => m::mock('App\Ticket')]), collect());
// $fetch->shouldReceive('buildActions')->times(3)->andReturn(collect());
// $fetch->shouldReceive('processEmail')->times(3);
// $parser = m::mock('App\Services\EmailParser');
// $parser->shouldReceive('parse')->times(3)->andReturn(collect());
// $user = m::mock('App\Contracts\Repositories\UserInterface');
// $fetch->handle($parser, $user);
}
示例12: testRollbackCommandCanBePretended
public function testRollbackCommandCanBePretended()
{
$command = new RollbackCommand($migrator = m::mock('Illuminate\\Database\\Migrations\\Migrator'));
$migrator->shouldReceive('setConnection')->once()->with('foo');
$migrator->shouldReceive('rollback')->once()->with(m::type('Symfony\\Component\\Console\\Output\\OutputInterface'), true);
$this->runCommand($command, array('--pretend' => true, '--database' => 'foo'));
}
示例13: testServiceCreateNewArticleCreateArticleRepoCalled
/**
* Tests if the createArticle method
* on the repo is called.
**/
public function testServiceCreateNewArticleCreateArticleRepoCalled()
{
$fakeArticle = m::mock('Eloquent', 'App\\Models\\Article');
$articleTitle = 'testing title';
$this->fakeRepo->shouldReceive('createArticle')->once()->with(m::type('App\\Models\\User'), $articleTitle)->andReturn($fakeArticle);
$this->service->createNewArticle($this->getMockUser(), $articleTitle);
}
示例14: testSetsHttpClient
public function testSetsHttpClient()
{
$serviceFactory = Mockery::mock('OAuth\\ServiceFactory');
$serviceFactory->shouldReceive('setHttpClient')->with(Mockery::type('OAuth\\Common\\Http\\Client\\CurlClient'))->times(1);
$oauth = new OAuth($serviceFactory, new Memory());
$oauth->setHttpClient('CurlClient');
}
示例15: testFireWithEmptyHostsArrayCallsError
public function testFireWithEmptyHostsArrayCallsError()
{
list($arguments, $options) = $this->createArgumentsAndOptions();
$this->setMockAwsExpectations($arguments, array());
$this->mockCommand->shouldReceive('error')->with(m::type('string'))->once();
$this->controller->fire($arguments, $options);
}