From d5a6cc14ae6c4fdb9f70580d296650419ba23b30 Mon Sep 17 00:00:00 2001 From: Jason McCreary Date: Wed, 17 Nov 2021 12:11:30 -0500 Subject: [PATCH 1/2] Remove assertDeleted --- .../Concerns/InteractsWithDatabase.php | 19 --------------- .../FoundationInteractsWithDatabaseTest.php | 24 ------------------- 2 files changed, 43 deletions(-) diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php index 80d2f063778e..13800ba26cd7 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php @@ -68,25 +68,6 @@ protected function assertDatabaseCount($table, int $count, $connection = null) return $this; } - /** - * Assert the given record has been deleted. - * - * @param \Illuminate\Database\Eloquent\Model|string $table - * @param array $data - * @param string|null $connection - * @return $this - */ - protected function assertDeleted($table, array $data = [], $connection = null) - { - if ($table instanceof Model) { - return $this->assertDatabaseMissing($table->getTable(), [$table->getKeyName() => $table->getKey()], $table->getConnectionName()); - } - - $this->assertDatabaseMissing($this->getTable($table), $data, $connection); - - return $this; - } - /** * Assert the given record has been "soft deleted". * diff --git a/tests/Foundation/FoundationInteractsWithDatabaseTest.php b/tests/Foundation/FoundationInteractsWithDatabaseTest.php index 259e819d08d3..e235fdf03ca3 100644 --- a/tests/Foundation/FoundationInteractsWithDatabaseTest.php +++ b/tests/Foundation/FoundationInteractsWithDatabaseTest.php @@ -161,17 +161,6 @@ public function testAssertDeletedFailsWhenFindsResults() $this->assertDatabaseMissing($this->table, $this->data); } - public function testAssertDeletedPassesWhenDoesNotFindModelResults() - { - $this->data = ['id' => 1]; - - $builder = $this->mockCountBuilder(0); - - $builder->shouldReceive('get')->andReturn(collect()); - - $this->assertDeleted(new ProductStub($this->data)); - } - public function testAssertModelMissingPassesWhenDoesNotFindModelResults() { $this->data = ['id' => 1]; @@ -183,19 +172,6 @@ public function testAssertModelMissingPassesWhenDoesNotFindModelResults() $this->assertModelMissing(new ProductStub($this->data)); } - public function testAssertDeletedFailsWhenFindsModelResults() - { - $this->expectException(ExpectationFailedException::class); - - $this->data = ['id' => 1]; - - $builder = $this->mockCountBuilder(1); - - $builder->shouldReceive('get')->andReturn(collect([$this->data])); - - $this->assertDeleted(new ProductStub($this->data)); - } - public function testAssertSoftDeletedInDatabaseFindsResults() { $this->mockCountBuilder(1); From bec7c971c9f1c12bacff574a07ca8b6129a37678 Mon Sep 17 00:00:00 2001 From: Jason McCreary Date: Wed, 17 Nov 2021 12:13:33 -0500 Subject: [PATCH 2/2] Correct names --- tests/Foundation/FoundationInteractsWithDatabaseTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Foundation/FoundationInteractsWithDatabaseTest.php b/tests/Foundation/FoundationInteractsWithDatabaseTest.php index e235fdf03ca3..bcb685e6e3ec 100644 --- a/tests/Foundation/FoundationInteractsWithDatabaseTest.php +++ b/tests/Foundation/FoundationInteractsWithDatabaseTest.php @@ -143,14 +143,14 @@ public function testAssertTableEntriesCountWrong() $this->assertDatabaseCount($this->table, 3); } - public function testAssertDeletedPassesWhenDoesNotFindResults() + public function testAssertDatabaseMissingPassesWhenDoesNotFindResults() { $this->mockCountBuilder(0); $this->assertDatabaseMissing($this->table, $this->data); } - public function testAssertDeletedFailsWhenFindsResults() + public function testAssertDatabaseMissingFailsWhenFindsResults() { $this->expectException(ExpectationFailedException::class);