Skip to content

Commit

Permalink
Merge branch 'develop' into 8.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 Aug 12, 2023
2 parents 1aa6dbe + 3ecc9c1 commit e152606
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 13 deletions.
1 change: 0 additions & 1 deletion .coveralls.yml

This file was deleted.

2 changes: 0 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
/build export-ignore
/docs export-ignore
/tests export-ignore
/.coveralls.yml export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/canvas.yaml export-ignore
/phpstan-baseline.neon export-ignore
/phpstan.neon.dist export-ignore
/phpunit9.xml export-ignore
Expand Down
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.27.1

Released: 2023-08-10

### Changes

* Update minimum support for Testbench v7.26.2+. ([v7.26.0...v7.26.2](https://github.com/orchestral/testbench/compare/v7.26.0...v7.26.2))

## 7.27.0

Released: 2023-08-08
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG-8.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

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

## 8.7.2

Released: 2023-08-10

### Changes

* Update minimum support for Testbench v8.6.3+. ([v8.6.2...v8.6.3](https://github.com/orchestral/testbench/compare/v8.6.2...v8.6.3))

## 8.7.1

Released: 2023-08-10

### Changes

* Update minimum support for Testbench v8.6.2+. ([v8.6.0...v8.6.2](https://github.com/orchestral/testbench/compare/v8.6.0...v8.6.2))

## 8.7.0

Released: 2023-08-08
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"laravel/dusk": "^7.9",
"laravel/serializable-closure": "^1.0",
"orchestra/dusk-updater": "^2.2.1",
"orchestra/testbench": ">=8.6.0 <8.7.0 || 8.x-dev",
"orchestra/testbench": ">=8.7.0 <8.8.0 || 8.x-dev",
"php-webdriver/webdriver": "^1.9"
},
"require-dev": {
Expand Down
13 changes: 11 additions & 2 deletions laravel/bootstrap/app.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

use Illuminate\Support\Env;
use Orchestra\Testbench\Foundation\Application;
use Orchestra\Testbench\Foundation\Config;
use Orchestra\Testbench\Workbench\Bootstrap\StartWorkbench;

/**
* Create Laravel application.
Expand All @@ -10,6 +12,10 @@
* @return \Illuminate\Foundation\Application
*/
$createApp = function (string $workingPath) {
if (! defined('TESTBENCH_WORKING_PATH') && ! is_null(Env::get('TESTBENCH_WORKING_PATH'))) {
define('TESTBENCH_WORKING_PATH', Env::get('TESTBENCH_WORKING_PATH'));
}

$config = Config::loadFromYaml(
defined('TESTBENCH_WORKING_PATH') ? TESTBENCH_WORKING_PATH : $workingPath
);
Expand All @@ -19,16 +25,19 @@
return Application::create(
basePath: $config['laravel'],
options: ['load_environment_variables' => $hasEnvironmentFile, 'extra' => $config->getExtraAttributes()],
resolvingCallback: function ($app) use ($config) {
(new StartWorkbench($config))->bootstrap($app);
},
);
};

$app = $createApp(realpath(__DIR__.'/../'));

unset($createApp);

/** @var \Illuminate\Routing\Router $router */
$router = $app->make('router');

unset($createApp);

collect(glob(__DIR__.'/../routes/testbench-*.php'))
->each(function ($routeFile) use ($app, $router) {
require $routeFile;
Expand Down
10 changes: 9 additions & 1 deletion src/DuskServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,15 @@ protected function startServer(): void
{
$this->guardServerStarting();

$this->process = Process::fromShellCommandline($this->prepareCommand());
$environmentVariables = collect($_ENV)
->when(\defined('TESTBENCH_WORKING_PATH'), function ($collect) {
$collect->put('TESTBENCH_WORKING_PATH', TESTBENCH_WORKING_PATH);

Check failure on line 152 in src/DuskServer.php

View workflow job for this annotation

GitHub Actions / PHP8.1 on ubuntu-latest

Constant TESTBENCH_WORKING_PATH not found.
});

$this->process = Process::fromShellCommandline(
$this->prepareCommand(), null, $environmentVariables->all()

Check failure on line 156 in src/DuskServer.php

View workflow job for this annotation

GitHub Actions / PHP8.1 on ubuntu-latest

Cannot call method all() on Illuminate\Support\Collection<(int|string), mixed>|void.
);

$this->process->setWorkingDirectory($this->laravelPublicPath());
$this->process->start();
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Browser/DatabaseMigrationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\Dusk\TestCase;
use function Orchestra\Testbench\workbench_path;

class DatabaseMigrationsTest extends TestCase
{
Expand All @@ -23,7 +24,7 @@ protected function setUp(): void
*/
protected function defineDatabaseMigrations()
{
$this->loadMigrationsFrom(__DIR__.'/../migrations');
$this->loadMigrationsFrom(workbench_path('database/migrations'));
}

/** @test */
Expand Down
23 changes: 18 additions & 5 deletions tests/Browser/RouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,24 @@
class RouteTest extends TestCase
{
/**
* Define environment setup.
* Define routes setup.
*
* @param Illuminate\Foundation\Application $app
* @param \Illuminate\Routing\Router $router
* @return void
*/
protected function defineEnvironment($app)
protected function defineRoutes($router)
{
$app['router']->get('hello', ['as' => 'hi', 'uses' => function () {
$router->get('hello', ['uses' => function () {
return 'hello world';
}]);

$app['router']->get('config', ['as' => 'hi', 'uses' => function () {
$router->get('config', ['uses' => function () {
return config('new_config_item');
}]);

$router->get('environment', ['uses' => function () {
return config('app.env');
}]);
}

/** @test */
Expand All @@ -33,6 +37,15 @@ public function can_use_dusk()
});
}

/** @test */
public function can_return_correct_application_environment()
{
$this->browse(function (Browser $browser) {
$browser->visit('environment')
->assertSee('testing');
});
}

/** @test */
public function can_use_multiple_browsers()
{
Expand Down
20 changes: 20 additions & 0 deletions tests/Browser/WithFakerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Orchestra\Testbench\Dusk\Tests\Browser;

use Faker\Generator;
use Illuminate\Foundation\Testing\WithFaker;
use Orchestra\Testbench\Dusk\TestCase;

class WithFakerTest extends TestCase
{
use WithFaker;

/** @test */
public function it_can_use_faker()
{
$this->browse(function ($browser) {
$this->assertInstanceOf(Generator::class, $this->faker);
});
}
}

0 comments on commit e152606

Please sign in to comment.