Support the ongoing development of →
Eloquent Architecture Testing
Last updated 8 months ago.

I replaced

$this->attributes = Factory::party(['id' => 1, 'name' => 'MyParty name - test']);

$this->attributes = Factory::create('SebSept\PokerEventRegistry\Models\Party',['id' => 1, 'name' => 'MyParty name - test']);

Now I have the error

There was 1 error:

  1. PartiesTest::testIndexParty Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: (SQL: insert into "parties" ("id", "name", "description_short", "description_long", "created_at", "updated_at") values (1, MyParty name - test, bizz-4675, Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce tortor nulla, cursus eu pellentesque sed, accumsan a risus. Pellentesque et commodo lectus. In ac urna., 2014-03-05 00:51:02, 2014-03-05 00:51:02))

This is because data are inserted in database ...
So mocking fails ...
Last updated 8 months ago.

Ok, I was tired, read the doc then found this code must use Factory::make() Factory::create() uses the database.

This is ok :

	public function setUp()

		$this->mock = m::mock('Eloquent', 'SebSept\PokerEventRegistry\Models\Party');
		$this->collection = m::mock('Illuminate\Database\Eloquent\Collection')->shouldDeferMissing();
		$this->attributes = Factory::make('SebSept\PokerEventRegistry\Models\Party',['id' => 1, 'name' => 'MyParty name - test']);
                $this->app->instance('SebSept\PokerEventRegistry\Models\Party', $this->mock);
Last updated 8 months ago.

Sign in to participate in this thread!


Your banner here too?

SebSept sebsept Joined 20 Feb 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.