当前位置: 首页>>代码示例>>PHP>>正文


PHP Event::shouldReceive方法代码示例

本文整理汇总了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();
     });
 }
开发者ID:impleri,项目名称:laravel-toolbox,代码行数:35,代码来源:ProviderTest.php

示例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);
 }
开发者ID:dalabarge,项目名称:validating,代码行数:7,代码来源:ValidatingObserverTest.php

示例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();
 }
开发者ID:chriscook,项目名称:validating,代码行数:9,代码来源:ValidatingObserverTest.php

示例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);
 }
开发者ID:jonjonw,项目名称:inventory,代码行数:9,代码来源:InventoryAssemblyTest.php

示例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);
 }
开发者ID:jonjonw,项目名称:inventory,代码行数:9,代码来源:InventoryStockTest.php

示例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([]);
 }
开发者ID:C4Tech,项目名称:laravel-ray-emitter,代码行数:12,代码来源:StoreTest.php

示例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();
 }
开发者ID:robbytaylor,项目名称:boom-core,代码行数:14,代码来源:DeletePageJobTest.php

示例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]);
 }
开发者ID:adldap2,项目名称:adldap2-laravel,代码行数:15,代码来源:NoDatabaseProviderTest.php

示例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());
 }
开发者ID:jonjonw,项目名称:inventory,代码行数:21,代码来源:InventoryVariantTest.php

示例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);
 }
开发者ID:impleri,项目名称:laravel-toolbox,代码行数:14,代码来源:ToolboxCommandsTest.php


注:本文中的Illuminate\Support\Facades\Event::shouldReceive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。