-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from lara-zeus/testing-tests
add test
- Loading branch information
Showing
7 changed files
with
115 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ Homestead.json | |
Homestead.yaml | ||
npm-debug.log | ||
yarn-error.log | ||
/database/database.sqlite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
<?php | ||
|
||
use LaraZeus\Bolt\Filament\Resources\FormResource; | ||
use LaraZeus\Bolt\Tests\Models\User; | ||
use function Pest\Laravel\{actingAs}; | ||
use function Pest\Laravel\{get}; | ||
|
||
it('can test', function () { | ||
expect(true)->toBeTrue(); | ||
}); | ||
|
||
/*it('can render FormResource', function () { | ||
actingAs(User::create(['email' => '[email protected]', 'name' => 'Admin'])) | ||
->get(FormResource::getUrl('index')) | ||
->assertSuccessful(); | ||
});*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace LaraZeus\Bolt\Tests\Models; | ||
|
||
use Filament\Models\Contracts\FilamentUser; | ||
use Illuminate\Foundation\Auth\User as Authenticatable; | ||
|
||
/** | ||
* @property string $email | ||
* @property string $name | ||
*/ | ||
class User extends Authenticatable implements FilamentUser | ||
{ | ||
protected $guarded = []; | ||
|
||
public $timestamps = false; | ||
|
||
protected $table = 'users'; | ||
|
||
public function canAccessFilament(): bool | ||
{ | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,39 +2,71 @@ | |
|
||
namespace LaraZeus\Bolt\Tests; | ||
|
||
use BladeUI\Heroicons\BladeHeroiconsServiceProvider; | ||
use BladeUI\Icons\BladeIconsServiceProvider; | ||
use Filament\FilamentServiceProvider; | ||
use Filament\Forms\FormsServiceProvider; | ||
use Filament\Support\SupportServiceProvider; | ||
use Filament\Tables\TablesServiceProvider; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use LaraZeus\Bolt\BoltServiceProvider; | ||
use LaraZeus\Bolt\Tests\Models\User; | ||
use Livewire\LivewireServiceProvider; | ||
use Orchestra\Testbench\TestCase as Orchestra; | ||
|
||
class TestCase extends Orchestra | ||
{ | ||
protected User $adminUser; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
Factory::guessFactoryNamesUsing( | ||
fn (string $modelName) => 'LaraZeus\Bolt\\Database\\Factories\\' . class_basename($modelName) . 'Factory' | ||
); | ||
|
||
$this->actingAs( | ||
User::create(['email' => '[email protected]', 'name' => 'Admin']) | ||
); | ||
} | ||
|
||
protected function getPackageProviders($app) | ||
protected function getPackageProviders($app): array | ||
{ | ||
return [ | ||
LivewireServiceProvider::class, | ||
BladeHeroiconsServiceProvider::class, | ||
BladeIconsServiceProvider::class, | ||
FilamentServiceProvider::class, | ||
FormsServiceProvider::class, | ||
LivewireServiceProvider::class, | ||
SupportServiceProvider::class, | ||
TablesServiceProvider::class, | ||
|
||
BoltServiceProvider::class, | ||
]; | ||
} | ||
|
||
public function getEnvironmentSetUp($app) | ||
public function getEnvironmentSetUp($app): void | ||
{ | ||
config()->set('database.default', 'testing'); | ||
|
||
$app['db']->connection()->getSchemaBuilder()->create('users', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->string('email'); | ||
$table->string('name'); | ||
}); | ||
/* | ||
$migration = include __DIR__.'/../database/migrations/create_Bolt_table.php.stub'; | ||
$migration->up(); | ||
*/ | ||
} | ||
|
||
protected function setUpDatabase($app): void | ||
{ | ||
$app['db']->connection()->getSchemaBuilder()->create('users', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->string('email'); | ||
$table->string('name'); | ||
}); | ||
} | ||
} |