Skip to content

Commit

Permalink
Fixed: feature test case error
Browse files Browse the repository at this point in the history
  • Loading branch information
kpscyber committed Aug 15, 2024
1 parent d5ba7b1 commit 32103fc
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 130 deletions.
2 changes: 1 addition & 1 deletion tests/src/Feature/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Soap\ThaiAddresses\Models\Subdistrict;
use Soap\ThaiAddresses\Tests\Models\User;

it('user can have address', function () {
test('user can have address', function () {
$user = User::factory()->create();
$subdistrict = Subdistrict::where('name_th', '=', 'กระบี่ใหญ่')->first();
$address = new Address;
Expand Down
2 changes: 0 additions & 2 deletions tests/src/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Soap\ThaiAddresses\Tests\Database\Factories\UserFactory;
use Soap\ThaiAddresses\Traits\HasAddress;

class User extends Authenticatable
Expand All @@ -18,5 +17,4 @@ class User extends Authenticatable
'password',
'remember_token',
];

}
79 changes: 0 additions & 79 deletions tests/src/SeedDatabase.php

This file was deleted.

27 changes: 0 additions & 27 deletions tests/src/SeedDatabaseState.php

This file was deleted.

29 changes: 8 additions & 21 deletions tests/src/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,22 @@ protected function setUp(): void

$this->artisan('migrate:fresh', [
'--force' => true,
'--seed' => true,
'--seeder' => DatabaseSeeder::class,
'--path' => __DIR__.'/../../database/migrations',
'--seed' => false,
'--path' => __DIR__.'/../../database/migrations', //package migration path
'--realpath' => true,
])->run();
/*

$this->artisan('migrate', [
'--force' => true,
'--path' => __DIR__ . '/../database/migrations',
'--seed' => false,
'--path' => __DIR__.'/../database/migrations', //test migration path
'--realpath' => true,
])->run();
*/
/*
SeedDatabaseState::$seeded = false;
SeedDatabaseState::$seedOnce = true;
SeedDatabaseState::$seeders = [
DatabaseSeeder::class,
];

$this->seedDatabase();
*/
$this->seed(DatabaseSeeder::class);

Factory::guessFactoryNamesUsing(
fn (string $modelName) => 'Soap\\ThaiAddresses\\Database\\Factories\\'.class_basename($modelName).'Factory'
fn (string $modelName) => 'Soap\\ThaiAddresses\\Tests\\Database\\Factories\\'.class_basename($modelName).'Factory'
);
}

Expand All @@ -56,12 +49,6 @@ public function getEnvironmentSetUp($app)
config()->set('auth.providers.users.model', User::class);
config()->set('database.default', 'testing');

$app['config']->set('database.connections.testing', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]);

config()->set('database.connections.mysql', [
'driver' => 'mysql',
'database' => 'thai_addresses_package_test',
Expand Down

0 comments on commit 32103fc

Please sign in to comment.