Skip to content

Commit

Permalink
Merge branch '6.x' into 7.x
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Dec 4, 2023
2 parents 0faff3f + 8a497c2 commit 1297d81
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 6 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG-6.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

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

## 6.40.0

Released: 2023-12-04

### Added

* Added the following attributes:
- `Orchestra\Testbench\Dusk\Attributes\BeforeServing`
- `Orchestra\Testbench\Dusk\Attributes\RestartServer`
* Backport `startServing()` and `reloadServing()` to `Orchestra\Testbench\Dusk\CanServeSite` trait.
* Add `createServingApplicationForDuskServer` method to `Orchestra\Testbench\Dusk\CanServeSite` trait.

### Changes

* Update minimum support for Testbench v6.39.0+. ([v6.38.0...v6.39.0](https://github.com/orchestral/testbench/compare/v6.38.0...v6.39.0))
* Allow passing method name to `Orchestra\Testbench\Dusk\CanServeSite::beforeServingApplication()` method.

## 6.39.0

Released: 2023-11-10
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@
"config": {
"sort-packages": true
},
"minimum-stability": "dev"
"minimum-stability": "stable"
}
2 changes: 1 addition & 1 deletion src/Attributes/BeforeServing.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(string $method)
* @param \Closure(string, array<int, mixed>):void $action
* @return string
*/
public function handle($app, Closure $action)
public function handle($app, Closure $action): string
{
return $this->method;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Bootstrap/LoadConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
use Illuminate\Contracts\Foundation\Application;
use Symfony\Component\Finder\Finder;

/**
* @internal
*/
final class LoadConfiguration
{
/**
Expand Down
26 changes: 25 additions & 1 deletion src/Concerns/CanServeSite.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

use function Orchestra\Testbench\after_resolving;

/**
* @internal
*/
trait CanServeSite
{
/**
Expand Down Expand Up @@ -143,8 +146,10 @@ public function removeApplicationTweaks(): void
*
* @param \Orchestra\Testbench\Dusk\DuskServer $server
* @return \Illuminate\Foundation\Application
*
* @codeCoverageIgnore
*/
public function getFreshApplicationToServe(DuskServer $server)
public function createServingApplicationForDuskServer(DuskServer $server)
{
static::$server = $server;

Expand All @@ -169,6 +174,23 @@ public function getFreshApplicationToServe(DuskServer $server)
return $app;
}

/**
* Build up a fresh application to serve, intended for use when we want to
* replicate the Application state during a Dusk test when we start our
* test server. See the main server file 'server.php'.
*
* @param \Orchestra\Testbench\Dusk\DuskServer $server
* @return \Illuminate\Foundation\Application
*
* @deprecated
*
* @codeCoverageIgnore
*/
public function getFreshApplicationToServe(DuskServer $server)
{
return $this->createServingApplicationForDuskServer($server);
}

/**
* Return the current instance of server.
*
Expand All @@ -185,6 +207,8 @@ public function getServer()
* DB content mid test. Using this method means we can be explicit.
*
* @return void
*
* @codeCoverageIgnore
*/
protected function setUpDuskServer(): void
{
Expand Down
8 changes: 6 additions & 2 deletions src/Concerns/ProvidesBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@

trait ProvidesBrowser
{
use Concern,
SupportsChrome;
use Concern;
use SupportsChrome;

/**
* Setup the browser environment.
*
* @internal
*
* @return void
*
* @throws \Exception
Expand Down Expand Up @@ -50,6 +52,8 @@ protected function setUpTheBrowserEnvironment()
/**
* Ensure the directories we need for dusk exist, and set them for the Browser to use.
*
* @internal
*
* @return void
*
* @throws \Exception
Expand Down
3 changes: 3 additions & 0 deletions src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use Facebook\WebDriver\Chrome\ChromeOptions;

/**
* @api
*/
class Options
{
/**
Expand Down
2 changes: 1 addition & 1 deletion src/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
/** @var class-string<\Orchestra\Testbench\Dusk\TestCase> $originatingTestClass */
$originatingTestClass = $orchestraServer->getStash('class');

$app = (new $originatingTestClass('laravel'))->getFreshApplicationToServe($orchestraServer);
$app = (new $originatingTestClass('laravel'))->createServingApplicationForDuskServer($orchestraServer);

// Emulation of mod_rewrite, but we use the applications set base path
if ($uri !== '/' && file_exists($app->basePath().'/public'.$uri)) {
Expand Down

0 comments on commit 1297d81

Please sign in to comment.