Skip to content

Commit

Permalink
Uses latest Testbench features.
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Mar 9, 2024
1 parent 01d7de7 commit 6197093
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 28 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: 9 additions & 15 deletions tests/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
<?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 = \Illuminate\Support\Facades\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 @@ -27,11 +21,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();
});
17 changes: 7 additions & 10 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,24 @@
namespace Native\Electron\Tests;

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

class TestCase extends Orchestra
{
use WithWorkbench;

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

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

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

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

0 comments on commit 6197093

Please sign in to comment.