Skip to content
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