Skip to content

Commit

Permalink
[9.x] Remove assertDeleted (#39661)
Browse files Browse the repository at this point in the history
* Remove assertDeleted

* Correct names
  • Loading branch information
jasonmccreary authored Nov 18, 2021
1 parent cea563d commit 9894c2c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 45 deletions.
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

0 comments on commit 9894c2c

Please sign in to comment.