本文整理汇总了PHP中Illuminate\Support\Facades\Event::shouldReceive方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::shouldReceive方法的具体用法?PHP Event::shouldReceive怎么用?PHP Event::shouldReceive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Event
的用法示例。
在下文中一共展示了Event::shouldReceive方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCommands
/**
* Do the Artisan commands fire?
*/
public function testCommands()
{
$self = $this;
$this->prepareSpecify();
$this->specify('Boots', function () use($self) {
$target = $self->getProvider(['package']);
$target->shouldReceive('package');
$target->boot();
});
$this->prepareSpecify();
$this->specify('Identifies provisions', function () use($self) {
$target = $self->getProvider();
verify($target->provides())->notEmpty();
});
$this->prepareSpecify();
$this->specify('Binds to application', function () use($self) {
App::shouldReceive('bind')->with('/^toolbox\\.commands\\./', Mockery::on(function ($closure) {
$command = $closure();
verify_that('is a command', is_a($command, 'Illuminate\\Console\\Command'));
return true;
}));
Event::shouldReceive('listen')->with('toolbox.build', Mockery::on(function ($closure) {
$app = Mockery::mock('Illuminate\\Console\\Application[call]');
$app->shouldReceive('call');
$command = $closure($app);
return true;
}));
$target = $self->getProvider(['commands']);
$target->shouldReceive('commands')->with(Mockery::type('array'));
$target->register();
});
}
示例2: testPerformValidation
public function testPerformValidation()
{
$this->model->shouldReceive('isValid')->once()->andReturn(true);
Event::shouldReceive('fire')->once();
$response = $this->observer->creating($this->model);
$this->assertNotFalse($response);
}
示例3: setUp
public function setUp()
{
$this->model = Mockery::mock('Illuminate\\Database\\Eloquent\\Model');
$this->observer = new ValidatingObserver();
// Enable validation on mock
$this->model->shouldReceive('getValidating')->andReturn(true);
Event::shouldReceive('until')->once();
Event::shouldReceive('fire')->once();
}
示例4: testMakeAssembly
public function testMakeAssembly()
{
$item = $this->newInventory();
DB::shouldReceive('beginTransaction')->once()->andReturn(true);
DB::shouldReceive('commit')->once()->andReturn(true);
Event::shouldReceive('fire')->once()->andReturn(true);
$item->makeAssembly();
$this->assertTrue($item->is_assembly);
}
示例5: testStockMove
public function testStockMove()
{
$stock = $this->newInventoryStock();
$newLocation = Location::create(['name' => 'New Location']);
DB::shouldReceive('beginTransaction')->once()->shouldReceive('commit')->once();
Event::shouldReceive('fire')->once();
$stock->moveTo($newLocation);
$this->assertEquals(2, $stock->location_id);
}
示例6: testPublishQueue
public function testPublishQueue()
{
$store = Mockery::mock(EventStore::class)->makePartial();
$payload = [Mockery::mock('stdClass')];
$event_name = 'testEvent';
$event = ['event' => $event_name, 'payload' => $payload];
EventBus::shouldReceive('fire')->with('publish:' . $event_name, $payload)->once();
$this->setPropertyValue($store, 'queue', [$event]);
expect_not($store->publishQueue());
$queue = $this->getPropertyValue($store, 'queue');
expect($queue)->equals([]);
}
示例7: testChildrenAreReparented
public function testChildrenAreReparented()
{
$page = $this->validPage();
$newParent = $this->validPage(2);
$child = m::mock(PageModel::class);
$child->shouldReceive('setParent')->with($newParent);
$job = new Jobs\DeletePage($page, ['reparentChildrenTo' => $newParent->getId()]);
Page::shouldReceive('delete')->zeroOrMoreTimes();
Event::shouldReceive('fire')->zeroOrMoreTimes();
Page::shouldReceive('find')->with($newParent->getId())->andReturn($newParent);
Page::shouldReceive('findByParentId')->with($page->getId())->andReturn([$child]);
Page::shouldReceive('save')->with($child);
$job->handle();
}
示例8: test_auth_passes
public function test_auth_passes($credentials = null)
{
$credentials = $credentials ?: ['email' => 'jdoe@email.com', 'password' => '12345'];
$user = $this->getMockUser(['cn' => '', 'mail' => 'jdoe@email.com', 'samaccountname' => 'jdoe', 'objectsid' => 'S-1-5-32-544']);
$connection = $this->getMockConnection();
$connection->expects($this->exactly(1))->method('isBound')->willReturn(true);
$connection->expects($this->exactly(1))->method('search')->willReturn('resource');
$connection->expects($this->exactly(1))->method('getEntries')->willReturn(['count' => 1, $user->getAttributes()]);
$connection->expects($this->exactly(2))->method('bind')->with($this->logicalOr($this->equalTo('jdoe'), $this->equalTo('admin')))->willReturn(true);
Event::shouldReceive('fire')->atLeast()->times(4)->withAnyArgs();
$this->assertTrue(Auth::attempt($credentials));
$user = Auth::user();
$this->assertInstanceOf(User::class, $user);
$this->assertEquals($credentials['email'], $user->mail[0]);
}
示例9: testGetTotalVariantStock
public function testGetTotalVariantStock()
{
$this->newCategory();
$this->newMetric();
$coke = Inventory::create(['name' => 'Coke', 'description' => 'Delicious Pop', 'metric_id' => 1, 'category_id' => 1]);
$cherryCoke = $coke->createVariant('Cherry Coke');
$cherryCoke->makeVariantOf($coke);
$vanillaCherryCoke = $cherryCoke->createVariant('Vanilla Cherry Coke');
$vanillaCherryCoke->makeVariantOf($cherryCoke);
DB::shouldReceive('beginTransaction')->once()->andReturn(true);
DB::shouldReceive('commit')->once()->andReturn(true);
Event::shouldReceive('fire')->once()->andReturn(true);
$location = $this->newLocation();
// Allow duplicate movements configuration option
Config::shouldReceive('get')->twice()->andReturn(true);
// Stock change reasons (one for create, one for put, for both items)
Lang::shouldReceive('get')->times(4)->andReturn('Default Reason');
$cherryCoke->createStockOnLocation(20, $location);
$vanillaCherryCoke->createStockOnLocation(20, $location);
$this->assertEquals(40, $coke->getTotalVariantStock());
}
示例10: runEvent
/**
* Run Event
*
* Common method to set Event facade to listen for an event before triggering
* an Artisan command.
* @param string $event Name of Event to listen for
* @param string $commandName Class name of the command to instantiate
*/
public function runEvent($event, $commandName)
{
$command = $this->getCommand($commandName);
Event::shouldReceive('fire')->once()->with($event)->andReturn([1]);
$this->runCommand($command);
}