Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Remove assertDeleted #39661

Merged
merged 2 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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".
*
Expand Down
28 changes: 2 additions & 26 deletions tests/Foundation/FoundationInteractsWithDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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];
Expand All @@ -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);
Expand Down