Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Sep 21, 2023
1 parent 51de26b commit b592c8b
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 23 deletions.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@
"@php vendor/bin/pint",
"@php vendor/bin/phpstan analyse"
],
"test": "@php vendor/bin/phpunit -c ./ --color",
"test": [
"@build",
"@php vendor/bin/phpunit -c ./ --color"
],
"ci": [
"@prepare",
"@dusk:install-chromedriver",
Expand Down
6 changes: 6 additions & 0 deletions src/Concerns/CanServeSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ public function getFreshApplicationToServe(DuskServer $server)
after_resolving($app, 'config', static function ($config, $app) use ($closure) {
$closure($app, $config);
});

$app['config'];
}

return $app;
Expand All @@ -183,6 +185,10 @@ public function getServer()
*/
protected function setUpDuskServer(): void
{
if (! static::$cachedConfigurationForWorkbench) {
static::setupBeforeClassUsingWorkbench();
}

if (! $this->app) {
$this->refreshApplication();
}
Expand Down
7 changes: 7 additions & 0 deletions testbench.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
providers:
- Workbench\App\Providers\RouteServiceProvider

migrations:
- workbench/database/migrations

workbench:
start: '/'
build:
- drop-sqlite-db
- create-sqlite-db
- migrate:refresh
13 changes: 4 additions & 9 deletions tests/Browser/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@

namespace Orchestra\Testbench\Dusk\Tests\Browser;

use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Dusk\Browser;
use Orchestra\Testbench\Concerns\WithLaravelMigrations;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\Dusk\TestCase;
use Orchestra\Testbench\Factories\UserFactory;

class AuthTest extends TestCase
{
/**
* Define database migrations.
*
* @return void
*/
protected function defineDatabaseMigrations()
{
$this->loadLaravelMigrations(config('database.default'));
}
use DatabaseMigrations, WithLaravelMigrations, WithWorkbench;

/** @test */
public function can_authenticate_user()
Expand Down
15 changes: 4 additions & 11 deletions tests/Browser/DatabaseMigrationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

namespace Orchestra\Testbench\Dusk\Tests\Browser;

use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\Dusk\TestCase;

use function Orchestra\Testbench\workbench_path;

class DatabaseMigrationsTest extends TestCase
{
use DatabaseMigrations, WithWorkbench;

protected function setUp(): void
{
$this->beforeApplicationDestroyed(function () {
Expand All @@ -18,16 +21,6 @@ protected function setUp(): void
parent::setUp();
}

/**
* Define database migrations.
*
* @return void
*/
protected function defineDatabaseMigrations()
{
$this->loadMigrationsFrom(workbench_path('database/migrations'));
}

/** @test */
public function it_can_migrate_and_reset_the_database()
{
Expand Down
4 changes: 3 additions & 1 deletion tests/Browser/RouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@

use Illuminate\Support\Env;
use Laravel\Dusk\Browser;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\Dusk\TestCase;

use function Orchestra\Testbench\package_path;

class RouteTest extends TestCase
{
use WithWorkbench;

/**
* Define routes setup.
*
Expand Down
3 changes: 2 additions & 1 deletion tests/Browser/WithFakerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use Faker\Generator;
use Illuminate\Foundation\Testing\WithFaker;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\Dusk\TestCase;

class WithFakerTest extends TestCase
{
use WithFaker;
use WithFaker, WithWorkbench;

/** @test */
public function it_can_use_faker()
Expand Down
20 changes: 20 additions & 0 deletions tests/Browser/WorkbenchTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Orchestra\Testbench\Dusk\Tests\Browser;

use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\Dusk\TestCase;

class WorkbenchTest extends TestCase
{
use WithWorkbench;

/** @test */
public function it_can_use_faker()
{
$this->browse(function ($browser) {
$browser->visit('welcome')
->assertSee('Documentation');
});
}
}
Empty file removed workbench/app/.gitkeep
Empty file.
29 changes: 29 additions & 0 deletions workbench/app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Workbench\App\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;

class RouteServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
//
}

/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
Route::view('welcome', 'welcome');
}
}

0 comments on commit b592c8b

Please sign in to comment.