Skip to content

Commit 089ef26

Browse files
authored
Add assertion to check model was not soft deleted (#28)
1 parent dd286fb commit 089ef26

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Traits/AdditionalAssertions.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace JMac\Testing\Traits;
44

55
use Illuminate\Support\Facades\Route;
6+
use Illuminate\Database\Eloquent\Model;
67
use PHPUnit\Framework\Assert as PHPUnitAssert;
78
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
89

@@ -178,6 +179,13 @@ public static function assertArrayStructure(array $structure, array $actual)
178179
}
179180
}
180181

182+
public function assertNotSoftDeleted(Model $model)
183+
{
184+
return $this->assertDatabaseHas($model->getTable(), [
185+
$model->getKeyName() => $model->getKey(),
186+
'deleted_at' => null,
187+
]);
188+
}
181189

182190
private function normalizeRules(array $rules)
183191
{

0 commit comments

Comments
 (0)