public function testUpdateListHasNothingToUpdate() { $userStubs = [['id' => 1], ['id' => 2]]; $localCollectionStub = Test::double('PullAutomaticallyGalleries\\Database\\Eloquent\\Collection', ['diffByKey' => &$localCollectionStub, 'isEmpty' => true])->make(); $remoteCollectionStub = Test::double('PullAutomaticallyGalleries\\Support\\Collection', ['diffByKey' => &$remoteCollectionStub, 'isEmpty' => true])->make(); Gallery::shouldReceive('getByUsers')->with([1, 2])->once()->andReturn($localCollectionStub)->getMock(); RemoteGallery::shouldReceive('getByUsers')->with($userStubs)->once()->andReturn($remoteCollectionStub); $this->call('POST', 'galleries', ['users' => $userStubs]); $this->assertRedirectedTo('users'); $this->assertSessionHas('message', 'Has been removed 0 galleries and created 0 galleries'); }
public function testGetByUsersFail() { $mock = Test::double('RemoteGallery'); $galleries = RemoteGallery::getByUsers([]); $mock->verifyNeverInvoked('newModel'); $mock->verifyNeverInvoked('modifyAttributes'); $mock->verifyInvoked('newCollection'); assertThat($galleries, is(emptyTraversable())); }