Skip to content

Commit

Permalink
Merge pull request #49 from lara-zeus/testing-tests
Browse files Browse the repository at this point in the history
add test
  • Loading branch information
atmonshi authored Jun 8, 2023
2 parents f03ea15 + a5822da commit 2b35f61
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 41 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
/database/database.sqlite
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"orchestra/testbench": "^6.0 || ^7.0",
"laravel/pint": "^1.0",
"nunomaduro/larastan": "^2.6",
"pestphp/pest": "^1.21",
"pestphp/pest-plugin-laravel": "^1.1",
"pestphp/pest": "^1.23",
"pestphp/pest-plugin-laravel": "^1.4",
"pestphp/pest-plugin-livewire": "^1.0",
"pestphp/pest-plugin-parallel": "^0.3",
"phpstan/extension-installer": "^1.3",
Expand Down
66 changes: 33 additions & 33 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
verbose="true"
>
<testsuites>
<testsuite name="LaraZeus\Artemis Test Suite">
<testsuite name="LaraZeus Bolt Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand All @@ -36,4 +36,10 @@
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
</phpunit>
<php>
<env name="APP_KEY" value="base64:ZHphOWJpbmF4Nmo5M3c4YmdyZWh1aGg4aWRhZ3o4NGM="/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value="/absolute/path/to/database.sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
</php>
</phpunit>
11 changes: 11 additions & 0 deletions tests/ExampleTest.php
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();
});*/
24 changes: 24 additions & 0 deletions tests/Models/User.php
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;
}
}
40 changes: 36 additions & 4 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
}
}

0 comments on commit 2b35f61

Please sign in to comment.