diff --git a/tests/Foundation/FoundationInteractsWithDatabaseTest.php b/tests/Foundation/FoundationInteractsWithDatabaseTest.php index 6edccb58ac32..caae5edf7bb7 100644 --- a/tests/Foundation/FoundationInteractsWithDatabaseTest.php +++ b/tests/Foundation/FoundationInteractsWithDatabaseTest.php @@ -17,7 +17,10 @@ class FoundationInteractsWithDatabaseTest extends TestCase protected $table = 'products'; - protected $data = ['title' => 'Spark']; + protected $data = [ + 'title' => 'Spark', + 'name' => 'Laravel', + ]; protected $connection; @@ -54,7 +57,7 @@ public function testSeeInDatabaseFindsNotMatchingResults() { $this->expectException(ExpectationFailedException::class); - $this->expectExceptionMessage('Found: '.json_encode([['title' => 'Forge']], JSON_PRETTY_PRINT)); + $this->expectExceptionMessage('Found similar results: '.json_encode([['title' => 'Forge']], JSON_PRETTY_PRINT)); $builder = $this->mockCountBuilder(0); @@ -68,7 +71,7 @@ public function testSeeInDatabaseFindsManyNotMatchingResults() { $this->expectException(ExpectationFailedException::class); - $this->expectExceptionMessage('Found: '.json_encode(['data', 'data', 'data'], JSON_PRETTY_PRINT).' and 2 others.'); + $this->expectExceptionMessage('Found similar results: '.json_encode(['data', 'data', 'data'], JSON_PRETTY_PRINT).' and 2 others.'); $builder = $this->mockCountBuilder(0); $builder->shouldReceive('count')->andReturn(0, 5); @@ -193,6 +196,11 @@ protected function mockCountBuilder($countResult, $deletedAtColumn = 'deleted_at { $builder = m::mock(Builder::class); + $key = array_key_first($this->data); + $value = $this->data[$key]; + + $builder->shouldReceive('where')->with($key, $value)->andReturnSelf(); + $builder->shouldReceive('limit')->andReturnSelf(); $builder->shouldReceive('where')->with($this->data)->andReturnSelf();