diff --git a/tests/Models/RegencyTest.php b/tests/Models/RegencyTest.php index d165ef7..8e76661 100644 --- a/tests/Models/RegencyTest.php +++ b/tests/Models/RegencyTest.php @@ -79,8 +79,8 @@ public function it_should_belongs_to_province(Collection $regencies): void #[Depends('it_should_has_many_regencies')] public function it_should_has_many_districts(Collection $regencies): void { - $regencies->each(function (Regency $regency) { - $this->assertTrue($regency->districts->every(fn ($dis) => $dis instanceof District)); + $regencies->take(5)->each(function (Regency $regency) { + $this->assertTrue($regency->districts->take(5)->every(fn ($dis) => $dis instanceof District)); }); } @@ -91,8 +91,8 @@ public function it_should_has_many_districts(Collection $regencies): void #[Depends('it_should_has_many_regencies')] public function it_should_has_many_villages(Collection $regencies): void { - $regencies->each(function (Regency $regency) { - $this->assertTrue($regency->villages->every(fn ($vil) => $vil instanceof Village)); + $regencies->take(5)->each(function (Regency $regency) { + $this->assertTrue($regency->villages->take(5)->every(fn ($vil) => $vil instanceof Village)); }); } } diff --git a/tests/TestCase.php b/tests/TestCase.php index d995cb7..3f82054 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -7,10 +7,13 @@ use Creasi\Nusa\ServiceProvider; use Database\Seeders\DatabaseSeeder; use Illuminate\Config\Repository; +use Illuminate\Foundation\Testing\DatabaseMigrations; use Orchestra\Testbench\TestCase as Orchestra; class TestCase extends Orchestra { + use DatabaseMigrations; + private static $shouldMigrate = true; protected function getPackageProviders($app) @@ -51,28 +54,28 @@ protected function getEnvironmentSetUp($app): void $config->set('app.locale', 'id'); $config->set('app.faker_locale', 'id_ID'); - $conn = env('DB_CONNECTION', 'sqlite'); + // $conn = env('DB_CONNECTION', 'sqlite'); - $config->set('database.default', $conn); + // $conn = $config->get('database.default'); - if ($conn === 'sqlite') { - $database = __DIR__.'/test.sqlite'; + // if ($conn === 'sqlite') { + // // $database = __DIR__.'/test.sqlite'; - if (self::$shouldMigrate) { - $this->recreateDatabase($database); - } + // // if (self::$shouldMigrate) { + // // $this->recreateDatabase($database); + // // } - $this->mergeConfig($config, 'database.connections.sqlite', [ - 'database' => $database, - 'foreign_key_constraints' => true, - ]); - } else { - $this->mergeConfig($config, 'database.connections.'.$conn, [ - 'database' => env('DB_DATABASE', 'creasi_test'), - 'username' => env('DB_USERNAME', 'creasico'), - 'password' => env('DB_PASSWORD', 'secret'), - ]); - } + // $this->mergeConfig($config, 'database.connections.sqlite', [ + // 'database' => ':memory:', + // 'foreign_key_constraints' => true, + // ]); + // } else { + // $this->mergeConfig($config, 'database.connections.'.$conn, [ + // 'database' => env('DB_DATABASE', 'creasi_test'), + // 'username' => env('DB_USERNAME', 'creasico'), + // 'password' => env('DB_PASSWORD', 'secret'), + // ]); + // } }); }