Skip to content

Commit

Permalink
replace mock by spy
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Aug 9, 2016
1 parent 263101f commit 78f31c9
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions tests/IfEmptyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,27 @@
namespace Spatie\CollectionMacros\Test;

use Illuminate\Support\Collection;
use Mockery;

class IfEmptyTest extends TestCase
{
/** @test */
public function it_executes_the_callable_if_the_collection_is_empty()
{
$mock = Mockery::mock();
$mock->shouldReceive('someCall')->once();

Collection::make()->ifEmpty(function () use ($mock) {
$mock->someCall();
Collection::make()->ifEmpty(function () {
$this->spy->someCall();
});

$this->spy->shouldHaveReceived('someCall')->once();
}

/** @test */
public function it_doesnt_execute_the_callable_if_the_collection_isnt_empty()
{
$mock = Mockery::mock();
$mock->shouldNotReceive('someCall');

Collection::make(['foo'])->ifEmpty(function () use ($mock) {
$mock->someCall();
Collection::make(['foo'])->ifEmpty(function () {
$this->spy->someCall();
});

$this->spy->shouldNotHaveReceived('someCall');
}

/** @test */
Expand Down

0 comments on commit 78f31c9

Please sign in to comment.