92 - Dealing with Out of Sync Mocks

This commit is contained in:
Adam Wathan
2017-04-01 14:00:59 -04:00
parent 084d1999a9
commit 6023eb3c8f
5 changed files with 218 additions and 192 deletions

View File

@@ -27,7 +27,7 @@ class Ticket extends Model
public function claimFor($order) public function claimFor($order)
{ {
$this->code = TicketCode::generate(); $this->code = TicketCode::generateFor($this);
$order->tickets()->save($this); $order->tickets()->save($this);
} }

View File

@@ -14,7 +14,7 @@
}, },
"require-dev": { "require-dev": {
"fzaninotto/faker": "~1.4", "fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*", "mockery/mockery": "1.0.0-alpha1",
"phpunit/phpunit": "~5.0", "phpunit/phpunit": "~5.0",
"symfony/css-selector": "3.1.*", "symfony/css-selector": "3.1.*",
"symfony/dom-crawler": "3.1.*", "symfony/dom-crawler": "3.1.*",

398
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -12,6 +12,12 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
*/ */
protected $baseUrl = 'http://localhost'; protected $baseUrl = 'http://localhost';
protected function setUp()
{
parent::setUp();
Mockery::getConfiguration()->allowMockingNonExistentMethods(false);
}
/** /**
* Creates the application. * Creates the application.
* *

View File

@@ -40,7 +40,7 @@ class TicketTest extends TestCase
{ {
$order = factory(Order::class)->create(); $order = factory(Order::class)->create();
$ticket = factory(Ticket::class)->create(['code' => null]); $ticket = factory(Ticket::class)->create(['code' => null]);
TicketCode::shouldReceive('generate')->andReturn('TICKETCODE1'); TicketCode::shouldReceive('generateFor')->with($ticket)->andReturn('TICKETCODE1');
$ticket->claimFor($order); $ticket->claimFor($order);