/** @test */ public function friendship_is_cancelled() { $this->sender->befriend($this->recipient); $this->recipient->acceptFriendRequest($this->sender); Event::shouldReceive('fire')->once()->withArgs(['friendships.cancelled', Mockery::any()]); $this->recipient->unfriend($this->sender); }
public function testFireEvent() { \Event::shouldReceive('fire')->once()->with('randomEvent', 'randomData'); //change visibility of fireEvent from protected to public $controller = $this->getMockForAbstractClass('\\Atrakeur\\Forum\\Controllers\\AbstractForumController'); $reflectionOfController = new \ReflectionClass('\\Atrakeur\\Forum\\Controllers\\AbstractForumController'); $method = $reflectionOfController->getMethod('fireEvent'); $method->setAccessible(true); $method->invoke($controller, 'randomEvent', 'randomData'); }
public function testIndexEmptyEventData() { $local = factory(App\User::class, 200)->make(); $request = m::mock('App\\Http\\Requests\\UserQueryRequest')->makePartial(); $request->shouldReceive('get')->once()->with('q'); $request->shouldReceive('get')->once()->with('noevent'); $request->shouldReceive('get')->once()->with('fields'); $request->shouldReceive('all')->twice()->withNoArgs(); Event::shouldReceive('fire')->once()->with(m::type('App\\Events\\UsersGetAllEvent'), [], false)->andReturn([]); $this->user->shouldReceive('pushCriteria->all')->once()->andReturn($local); $controller = new UsersController($this->user); $return = $controller->index($request); $this->assertEquals($local->toArray(), $return->getData(true)); }
public function testRefreshMessageCacheEvent() { Event::shouldReceive('fire')->once()->with('JsLocalization.registerMessages'); CachingService::refreshMessageCache(); }
public function testCreateCommentLikeIfNotAlreadyLiked() { $idUser = 1; $likableEntityId = 10; $stub = $this->getAbstractGatewayStub(); $comment = $this->mock('MicheleAngioni\\MessageBoard\\Models\\Comment'); $like = $this->mock('MicheleAngioni\\MessageBoard\\Models\\Like'); $this->commentRepo->shouldReceive('findOrFail')->once()->with($likableEntityId)->andReturn($comment); $this->likeRepo->shouldReceive('getUserEntityLike')->once()->with($comment, $idUser)->andReturn(NULL); $likesMock = $this->mock('likesMock'); $likesMock->shouldReceive('create')->once()->andReturn($like); $comment->shouldReceive('likes')->once()->andReturn($likesMock); Event::shouldReceive('fire')->once(); $this->assertInstanceOf('MicheleAngioni\\MessageBoard\\Models\\Like', $stub->createLike($idUser, $likableEntityId, 'comment')); }