From 57891311d19cfe52013c260737e759bb07bdc61a Mon Sep 17 00:00:00 2001 From: Bas Date: Sun, 25 Aug 2024 13:45:40 +0200 Subject: [PATCH] Removed old overrides (QB improvements renders these overrides unnecessary) --- .../Concerns/InteractsWithDatabase.php | 114 ------------------ tests/Testing/InteractsWithDatabaseTest.php | 1 + 2 files changed, 1 insertion(+), 114 deletions(-) diff --git a/src/Testing/Concerns/InteractsWithDatabase.php b/src/Testing/Concerns/InteractsWithDatabase.php index 1049863..2da9780 100644 --- a/src/Testing/Concerns/InteractsWithDatabase.php +++ b/src/Testing/Concerns/InteractsWithDatabase.php @@ -5,122 +5,9 @@ namespace LaravelFreelancerNL\Aranguent\Testing\Concerns; use Illuminate\Support\Facades\DB; -use Illuminate\Testing\Constraints\HasInDatabase; -use Illuminate\Testing\Constraints\NotSoftDeletedInDatabase; -use Illuminate\Testing\Constraints\SoftDeletedInDatabase; -use PHPUnit\Framework\Constraint\LogicalNot as ReverseConstraint; trait InteractsWithDatabase { - /** - * Assert that a given where condition exists in the database. - * - * @param \Illuminate\Database\Eloquent\Model|string $table - * @param array $data - * @param string|null $connection - * @return $this - */ - protected function assertDatabaseHas($table, array $data = [], $connection = null) - { - $this->assertThat( - $this->getTable($table), - new HasInDatabase($this->getConnection($connection), associativeFlatten($data)), - ); - - return $this; - } - - /** - * Assert that a given where condition does not exist in the database. - * - * @param \Illuminate\Database\Eloquent\Model|string $table - * @param array $data - * @param string|null $connection - * @return $this - */ - protected function assertDatabaseMissing($table, array $data = [], $connection = null) - { - $constraint = new ReverseConstraint( - new HasInDatabase($this->getConnection($connection), associativeFlatten($data)), - ); - - $this->assertThat($this->getTable($table), $constraint); - - return $this; - } - - /** - * Assert the given record has been "soft deleted". - * - * @param \Illuminate\Database\Eloquent\Model|string $table - * @param array $data - * @param string|null $connection - * @param string|null $deletedAtColumn - * @return $this - */ - protected function assertSoftDeleted( - $table, - array $data = [], - $connection = null, - $deletedAtColumn = 'deleted_at', - ) { - if ($this->isSoftDeletableModel($table) && !is_string($table)) { - return $this->assertSoftDeleted( - $table->getTable(), - [$table->getKeyName() => $table->getKey()], - $table->getConnectionName(), /** @phpstan-ignore-next-line */ - $table->getDeletedAtColumn(), - ); - } - - $this->assertThat( - $this->getTable($table), - new SoftDeletedInDatabase( - $this->getConnection($connection), - associativeFlatten($data), - (string) $deletedAtColumn, - ), - ); - - return $this; - } - - /** - * Assert the given record has not been "soft deleted". - * - * @param \Illuminate\Database\Eloquent\Model|string $table - * @param array $data - * @param string|null $connection - * @param string|null $deletedAtColumn - * @return $this - */ - protected function assertNotSoftDeleted( - $table, - array $data = [], - $connection = null, - $deletedAtColumn = 'deleted_at', - ) { - if ($this->isSoftDeletableModel($table) && !is_string($table)) { - return $this->assertNotSoftDeleted( - $table->getTable(), - [$table->getKeyName() => $table->getKey()], - $table->getConnectionName(), /** @phpstan-ignore-next-line */ - $table->getDeletedAtColumn(), - ); - } - - $this->assertThat( - $this->getTable($table), - new NotSoftDeletedInDatabase( - $this->getConnection($connection), - associativeFlatten($data), - (string) $deletedAtColumn, - ), - ); - - return $this; - } - /** * Cast a JSON string to a database compatible type. * Supported for backwards compatibility in existing projects. @@ -133,5 +20,4 @@ public function castAsJson($value) { return DB::raw($value); } - } diff --git a/tests/Testing/InteractsWithDatabaseTest.php b/tests/Testing/InteractsWithDatabaseTest.php index a91294f..d32459a 100644 --- a/tests/Testing/InteractsWithDatabaseTest.php +++ b/tests/Testing/InteractsWithDatabaseTest.php @@ -72,6 +72,7 @@ test('assert model exists', function () { $ned = Character::find('NedStark'); + $this->assertModelExists($ned); });