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 6c1c8d6 commit 263101f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
17 changes: 2 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@

All Notable changes to `laravel-collection-macros` will be documented in this file

## NEXT - YYYY-MM-DD
## 1.0.0 - 2016-08-09

### Added
- Nothing

### Deprecated
- Nothing

### Fixed
- Nothing

### Removed
- Nothing

### Security
- Nothing
- initial release
19 changes: 8 additions & 11 deletions tests/IfAnyTest.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 IfAnyTest extends TestCase
{
/** @test */
public function it_executes_the_callable_if_the_collection_isnt_empty()
{
$mock = Mockery::mock();
$mock->shouldReceive('someCall')->once();

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

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

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

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

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

/** @test */
Expand Down
5 changes: 5 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
use Mockery;
use Orchestra\Testbench\TestCase as BaseTestCase;

/**
* @property \Mockery\MockInterface spy
*/
abstract class TestCase extends BaseTestCase
{
public function setUp()
{
parent::setUp();

require_once __DIR__.'/../src/macros.php';

$this->spy = Mockery::spy();
}

public function tearDown()
Expand Down

0 comments on commit 263101f

Please sign in to comment.