Skip to content

Commit

Permalink
Merge branch '7.x' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
crynobone committed Aug 23, 2023
2 parents 2f928cb + 9dae2d4 commit 9210117
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG-7.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

This changelog references the relevant changes (bug and security fixes) done to `orchestra/testbench-dusk`.

## 7.30.1

Released: 2023-08-23

### Fixes

* Fixes usage with `Orchestra\Testbench\Concerns\WithWorkbench`.

## 7.30.0

Released: 2023-08-22
Expand Down
8 changes: 4 additions & 4 deletions src/DuskServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;

use function Orchestra\Testbench\package_path;

class DuskServer
{
/**
Expand Down Expand Up @@ -150,10 +152,8 @@ protected function startServer(): void

/** @var array<string, mixed> $environmentVariables */
$environmentVariables = Collection::make($_ENV)
->when(\defined('TESTBENCH_WORKING_PATH'), function ($collect) {
/** @phpstan-ignore-next-line */
return $collect->put('TESTBENCH_WORKING_PATH', TESTBENCH_WORKING_PATH);
})->all();
->put('TESTBENCH_WORKING_PATH', package_path())
->all();

$this->process = Process::fromShellCommandline(
$this->prepareCommand(), null, $environmentVariables
Expand Down
37 changes: 37 additions & 0 deletions tests/Browser/RouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

namespace Orchestra\Testbench\Dusk\Tests\Browser;

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

use function Orchestra\Testbench\package_path;

class RouteTest extends TestCase
{
/**
Expand All @@ -26,6 +29,10 @@ protected function defineRoutes($router)
$router->get('environment', ['uses' => function () {
return config('app.env');
}]);

$router->get('testbench-environment-value', ['uses' => function () {
return Env::get('TESTBENCH_WORKING_PATH');
}]);
}

/** @test */
Expand Down Expand Up @@ -74,4 +81,34 @@ public function can_tweak_the_application_within_a_test()

$this->removeApplicationTweaks();
}

/** @test */
public function can_use_multiple_browsers_can_persist_testbench_working_path_environment_variables()
{
$this->browse(function (Browser $browser, Browser $browserTwo) {
$browser->visit('testbench-environment-value')
->assertSee(package_path())
->visit('testbench-environment-value')
->assertSee(package_path());

$browserTwo->visit('testbench-environment-value')
->assertSee(package_path())
->visit('testbench-environment-value')
->assertSee(package_path());
});

static::reloadServing();

$this->browse(function (Browser $browser, Browser $browserTwo) {
$browser->visit('testbench-environment-value')
->assertSee(package_path())
->visit('testbench-environment-value')
->assertSee(package_path());

$browserTwo->visit('testbench-environment-value')
->assertSee(package_path())
->visit('testbench-environment-value')
->assertSee(package_path());
});
}
}

0 comments on commit 9210117

Please sign in to comment.