當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。