Skip to content

Commit

Permalink
Merge branch 'develop' into 9.x
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Jul 13, 2024
2 parents 44d35f6 + 7842114 commit 4d47249
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 19 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG-8.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

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

## 8.26.0

Released: 2024-07-13

### Added

* Added `Orchestra\Testbench\Dusk\Options::using()` method to interacts with `Facebook\WebDriver\Chrome\ChromeOptions`.

### Changes

* Update minimum support for Testbench v8.24.0+. ([v8.23.2...v8.24.0](https://github.com/orchestral/testbench/compare/v8.23.2...v8.24.0))
* Update minimum support for Testbench Core v8.25.0+. ([v8.24.3...v8.25.0](https://github.com/orchestral/testbench/compare/v8.24.3...v8.25.0))

## 8.25.1

Released: 2024-06-02
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG-9.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@

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

## 9.4.0

Released: 2024-07-13

### Added

* Added `Orchestra\Testbench\Dusk\Options::using()` method to interacts with `Facebook\WebDriver\Chrome\ChromeOptions`.

### Changes

* Update minimum support for Testbench v9.2.0+. ([v9.1.2...v9.2.0](https://github.com/orchestral/testbench/compare/v9.1.2...v9.2.0))
* Update minimum support for Testbench Core v9.2.1+. ([v9.1.3...v9.2.1](https://github.com/orchestral/testbench-core/compare/v9.1.3...v9.2.1))

## 9.3.1

Released: 2024-06-28

### Changes

* Update minimum support for Testbench v9.1.2+. ([v9.1.1...v9.1.2](https://github.com/orchestral/testbench/compare/v9.1.1...v9.1.2))
* Update minimum support for Testbench Core v9.1.3+. ([v9.1.2...v9.1.3](https://github.com/orchestral/testbench-core/compare/v9.1.2...v9.1.3))
* Provide Process's `$commandline` as `array` to leverage `proc_open()` on Symfony Process 7.1.

## 9.3.0

Released: 2024-06-02
Expand Down
2 changes: 1 addition & 1 deletion laravel/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database
# APP_MAINTENANCE_STORE=database

BCRYPT_ROUNDS=12

Expand Down
16 changes: 12 additions & 4 deletions src/Concerns/CanServeSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@ public function beforeServingApplication(Closure|string $closure): void
$app = $this->app;

after_resolving($app, 'config', function ($config, $app) use ($closure) {
/**
* @var \Illuminate\Foundation\Application $app
* @var \Illuminate\Contracts\Config\Repository $config
*/
\is_string($closure) && method_exists($this, $closure)
? $this->{$closure}($app, $config)
: value($closure, $app, $config);
? call_user_func([$this, $closure], $app, $config) // @phpstan-ignore argument.type
: value($closure, $app, $config); // @phpstan-ignore argument.type
});

static::$server?->stash([
Expand Down Expand Up @@ -177,9 +181,13 @@ public function createServingApplicationForDuskServer(DuskServer $server)
$closure = \is_string($serializedClosure) ? $serializedClosure : $serializedClosure->getClosure();

after_resolving($app, 'config', function ($config, $app) use ($closure) {
/**
* @var \Illuminate\Foundation\Application $app
* @var \Illuminate\Contracts\Config\Repository $config
*/
\is_string($closure) && method_exists($this, $closure)
? $this->{$closure}($app, $config)
: value($closure, $app, $config);
? call_user_func([$this, $closure], $app, $config) // @phpstan-ignore argument.type
: value($closure, $app, $config); // @phpstan-ignore argument.type
});
}

Expand Down
24 changes: 11 additions & 13 deletions src/DuskServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Orchestra\Testbench\Dusk;

use Illuminate\Support\ProcessUtils;
use Laravel\Dusk\OperatingSystem;
use Orchestra\Testbench\Dusk\Exceptions\UnableToStartServer;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;
Expand Down Expand Up @@ -182,7 +180,7 @@ protected function startServer(): void
{
$this->guardServerStarting();

$this->process = Process::fromShellCommandline(
$this->process = new Process(
command: $this->prepareCommand(),
cwd: join_paths($this->basePath(), 'public'),
env: array_merge(defined_environment_variables(), [
Expand Down Expand Up @@ -224,18 +222,18 @@ protected function guardServerStarting(): void
/**
* Prepare the command for starting the PHP server.
*
* @return string
* @return array
*/
protected function prepareCommand(): string
protected function prepareCommand(): array
{
return sprintf(
((OperatingSystem::onWindows() ? '' : 'exec ').'%s -S %s:%s %s -t %s'),
ProcessUtils::escapeArgument((string) (new PhpExecutableFinder())->find(false)),
$this->host,
$this->port,
ProcessUtils::escapeArgument(join_paths(__DIR__, 'server.php')),
ProcessUtils::escapeArgument(join_paths($this->basePath(), 'public')),
);
return [
(string) (new PhpExecutableFinder())->find(false),
'-S',
sprintf('%s:%s', $this->host, $this->port),
join_paths(__DIR__, 'server.php'),
'-t',
join_paths($this->basePath(), 'public'),
];
}

/**
Expand Down
22 changes: 22 additions & 0 deletions src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ class Options
*/
public static array $arguments = [];

/**
* Apply `ChromeOptions` configuration using a callback.
*
* @var (\Closure(\Facebook\WebDriver\Chrome\ChromeOptions):(void))|null
*/
public static $chromeOptionsCallback = null;

/**
* Reset arguments.
*
Expand All @@ -55,6 +62,19 @@ public static function resetArguments(): void
static::$arguments = [];
}

/**
* Set `ChromeOptions` callback.
*
* @param (\Closure(\Facebook\WebDriver\Chrome\ChromeOptions):(void))|null $callback
* @return static
*/
public static function using($callback)
{
static::$chromeOptionsCallback = $callback;

return new static();
}

/**
* Add a browser option.
*
Expand Down Expand Up @@ -230,6 +250,8 @@ public static function getChromeOptions()
if (static::$w3cCompliant === false) {
$option->setExperimentalOption('w3c', static::$w3cCompliant);
}

value(static::$chromeOptionsCallback);
})->addArguments(static::$arguments);
}
}
3 changes: 2 additions & 1 deletion src/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ protected function registerShutdownFunction()
* @param \Illuminate\Foundation\Application $app
* @return void
*/
private function resolveApplicationResolvingCallback($app): void
#[\Override]
protected function resolveApplicationResolvingCallback($app): void
{
$app->bind(
'Illuminate\Foundation\Bootstrap\LoadConfiguration',
Expand Down

0 comments on commit 4d47249

Please sign in to comment.