Skip to content

Commit

Permalink
Merge pull request #87 from crynobone/workbench
Browse files Browse the repository at this point in the history
Uses latest Testbench features.
  • Loading branch information
simonhamp committed Apr 30, 2024
2 parents 6745f88 + d461468 commit ceed917
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 32 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ coverage
docs
phpunit.xml
phpstan.neon
testbench.yaml
vendor
node_modules
resources/js/*.log
resources/js/*.log
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.9",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^8.0",
"orchestra/testbench": "^8.18",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-arch": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
Expand Down
7 changes: 7 additions & 0 deletions testbench.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
providers:
- Native\Electron\ElectronServiceProvider

migrations: false

workbench:
install: false
24 changes: 8 additions & 16 deletions tests/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
<?php

use Illuminate\Support\Facades\Process;
use Symfony\Component\Process\PhpExecutableFinder;

it('can boot up the app', function () {
$executableFinder = new PhpExecutableFinder();
$php = $executableFinder->find(false);

copy(
from: __DIR__.'/fixtures/artisan',
to: base_path('artisan'),
);
use function Orchestra\Testbench\remote;

$process = Process::path(base_path())
->tty()
->start($php.' artisan native:serve', function ($type, $line) {
echo $line;
});
it('can boot up the app', function () {
$process = remote('native:serve');
$process->setTty(true)->start(function ($type, $line) {
echo $line;
});

try {
retry(12, function () {
Expand All @@ -28,11 +20,11 @@
}
}, 5000);
} catch (Exception $e) {
Process::run('pkill -9 -P '.$process->id());
Process::run('pkill -9 -P '.$process->getPid());
throw $e;
}

Process::run('pkill -9 -P '.$process->id());
Process::run('pkill -9 -P '.$process->getPid());

expect(true)->toBeTrue();
});
18 changes: 5 additions & 13 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,19 @@
namespace Native\Electron\Tests;

use Illuminate\Support\Facades\Artisan;
use Native\Electron\ElectronServiceProvider;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\TestCase as Orchestra;

#[WithConfig('database.default', 'testing')]
class TestCase extends Orchestra
{
use WithWorkbench;

protected function setUp(): void
{
parent::setUp();

Artisan::call('native:install', ['--force' => true]);
}

protected function getPackageProviders($app): array
{
return [
ElectronServiceProvider::class,
];
}

public function getEnvironmentSetUp($app): void
{
config()->set('database.default', 'testing');
}
}

0 comments on commit ceed917

Please sign in to comment.