Skip to content

Commit

Permalink
Merge branch '9.x' into 10.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 Oct 6, 2024
2 parents 4036777 + 60dd2ad commit 0a31521
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 12 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/parallel-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- "^7.3"
phpunit:
- "^10.5"
- "~11.0.0"
- "^11.0"
dependencies:
- "highest"
experimental:
Expand All @@ -42,13 +42,13 @@ jobs:

- name: Install Paratest
run: |
composer require "nunomaduro/collision:${{ matrix.collision }}" "brianium/paratest:${{ matrix.paratest }}" "phpunit/phpunit:${{ matrix.phpunit }}" --dev --no-interaction --no-update
composer require "nunomaduro/collision:${{ matrix.collision }}" "brianium/paratest:${{ matrix.paratest }}" --dev --no-interaction --no-update
- name: Install dependencies
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--prefer-dist --prefer-stable --no-cache"
composer-options: "--prefer-dist --prefer-stable --no-cache --with=phpunit/phpunit:${{ matrix.phpunit }}"

- name: Installed dependencies
run: |
Expand All @@ -58,3 +58,10 @@ jobs:
run: ./testbench package:test --parallel --exclude-group commander,without-parallel,database,session --no-coverage
env:
RAY_ENABLED: false
if: matrix.phpunit == '^10.5'

- name: Execute tests (with deprecations)
run: ./testbench package:test --parallel --exclude-group commander --exclude-group without-parallel --exclude-group database --exclude-group session --no-coverage
env:
RAY_ENABLED: false
if: matrix.phpunit != '^10.5'
1 change: 1 addition & 0 deletions .github/workflows/strict-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
- "~11.1.0"
- "~11.2.0"
- "~11.3.0"
- "~11.4.0"
dependencies:
- "highest"
experimental:
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ jobs:
- "~11.0.0"
- "~11.2.0"
- "~11.3.0"
- "~11.4.0"
dependencies:
- "highest"
- "lowest"
exclude:
- phpunit: "~11.1.0"
dependencies: "lowest"
- phpunit: "~11.2.0"
dependencies: "lowest"
- phpunit: "~11.3.0"
dependencies: "lowest"
experimental:
- false

Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG-8.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

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

## 8.28.3

Released: 2024-10-06

### Fixes

* Prevent seeder from being executed when `shouldSeed()` exists and return `false`.

## 8.28.2

Released: 2024-10-05

### Changes

* Listen to `SIGHUP`, `SIGUSR1`, and `SIGUSR2` signals via Testbench CLI.

### Fixes

* Fixes Testbench CLI signals via `serve` command to reset published `.env` and `testbench.yaml`.

## 8.28.1

Released: 2024-09-24
Expand Down
28 changes: 28 additions & 0 deletions CHANGELOG-9.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@

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

## 9.5.3

Released: 2024-10-06

### Fixes

* Prevent seeder from being executed when `shouldSeed()` exists and return `false`.

## 9.5.2

Released: 2024-10-05

### Changes

* Listen to `SIGHUP`, `SIGUSR1`, and `SIGUSR2` signals via Testbench CLI.

### Fixes

* Fixes Testbench CLI signals via `serve` command to reset published `.env` and `testbench.yaml`.

## 9.5.1

Released: 2025-09-25

### Changes

* Update `config/concurrency.php` configuration file.

## 9.5.0

Released: 2024-09-23
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"laravel/framework": "<12.0.0 || >=13.0.0",
"laravel/serializable-closure": "<1.3.0 || >=2.0.0",
"nunomaduro/collision": "<8.0.0 || >=9.0.0",
"phpunit/phpunit": "<10.5.0 || 11.0.0 || >=11.4.0"
"phpunit/phpunit": "<10.5.0 || 11.0.0 || >=11.5.0"
},
"suggest": {
"ext-pcntl": "Required to use all features of the console signal trapping.",
Expand Down
2 changes: 1 addition & 1 deletion laravel/config/concurrency.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
|
*/

'driver' => env('CONCURRENCY_DRIVER', 'process'),
'default' => env('CONCURRENCY_DRIVER', 'process'),

];
2 changes: 1 addition & 1 deletion src/Attributes/RequiresDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function handle($app, Closure $action): void
}

if (
is_string($this->driver)
\is_string($this->driver)
&& ! \is_null($this->versionRequirement)
&& preg_match('/(?P<operator>[<>=!]{0,2})\s*(?P<version>[\d\.-]+(dev|(RC|alpha|beta)[\d\.])?)[ \t]*\r?$/m', $this->versionRequirement, $matches)
) {
Expand Down
19 changes: 19 additions & 0 deletions src/Concerns/InteractsWithMigrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ protected function loadMigrationsFrom(array|string $paths): void
return;
}

if (\is_null($this->app)) {
throw ApplicationNotAvailableException::make(__METHOD__);
}

/** @var array<string, mixed>|string $paths */
$migrator = new MigrateProcessor($this, $this->resolvePackageMigrationsOptions($paths));
$migrator->up();
Expand Down Expand Up @@ -141,6 +145,21 @@ protected function loadLaravelMigrations(array|string $database = []): void
$this->resetApplicationArtisanCommands($this->app);
}

/**
* Migrate Laravel's default migrations without rollback.
*
* @api
*
* @param array<string, mixed>|string $database
* @return void
*
* @deprecated
*/
protected function loadLaravelMigrationsWithoutRollback(array|string $database = []): void
{
$this->loadLaravelMigrations($database);
}

/**
* Migrate all Laravel's migrations.
*
Expand Down
10 changes: 9 additions & 1 deletion src/Concerns/WithWorkbench.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

namespace Orchestra\Testbench\Concerns;

use Illuminate\Foundation\Testing\Traits\CanConfigureMigrationCommands;
use Orchestra\Testbench\Foundation\Bootstrap\LoadMigrationsFromArray;
use Orchestra\Testbench\Workbench\Workbench;

trait WithWorkbench
{
use InteractsWithPHPUnit;
use InteractsWithWorkbench;

/**
Expand All @@ -26,8 +28,14 @@ protected function setUpWithWorkbench(): void

Workbench::start($app, $config);

$seeders = $config['seeders'] ?? false;

if (static::usesTestingConcern(CanConfigureMigrationCommands::class) && $this->shouldSeed() === false) {
$seeders = false;
}

(new LoadMigrationsFromArray(
$config['migrations'] ?? [], $config['seeders'] ?? false,
$config['migrations'] ?? [], $seeders,
))->bootstrap($app);
}

Expand Down
6 changes: 5 additions & 1 deletion src/Console/Commander.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ protected function prepareCommandSignals(): void
Signals::whenAvailable(function () {
$this->signals ??= new Signals(new SignalRegistry);

Collection::make(Arr::wrap([SIGINT, SIGTERM, SIGQUIT]))
Collection::make(Arr::wrap([SIGTERM, SIGINT, SIGHUP, SIGUSR1, SIGUSR2, SIGQUIT]))
->each(
fn ($signal) => $this->signals->register($signal, function () use ($signal) {
$this->handleTerminatingConsole();
Expand All @@ -251,6 +251,10 @@ protected function prepareCommandSignals(): void

$this->untrap();

if (\in_array($status, [130])) {
exit;
}

exit($status);
})
);
Expand Down
21 changes: 21 additions & 0 deletions src/Foundation/Console/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Orchestra\Testbench\Foundation\Events\ServeCommandStarted;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Process\Process;

use function Orchestra\Testbench\package_path;

Expand Down Expand Up @@ -41,6 +42,26 @@ class_exists(ComposerConfig::class, false)
});
}

/**
* Start a new server process.
*
* @param bool $hasEnvironment
* @return \Symfony\Component\Process\Process
*/
#[\Override]
protected function startProcess($hasEnvironment)
{
return tap(parent::startProcess($hasEnvironment), function (Process $process) {
$this->untrap();

$this->trap(fn () => [SIGTERM, SIGINT, SIGHUP, SIGUSR1, SIGUSR2, SIGQUIT], function ($signal) use ($process) {
if ($process->isRunning()) {
$process->stop(10, $signal);
}
});
});
}

/**
* Get the value of a command option.
*
Expand Down
3 changes: 1 addition & 2 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Orchestra\Testbench\Foundation\Env;
use PHPUnit\Runner\Version;
use RuntimeException;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;

/**
Expand Down Expand Up @@ -78,7 +77,7 @@ function artisan(Contracts\TestCase|ApplicationContract $context, string $comman
function remote(array|string $command, array|string $env = []): Process
{
$phpBinary = transform(
\defined('PHP_BINARY') ? PHP_BINARY : (new PhpExecutableFinder)->find(),
\defined('PHP_BINARY') ? PHP_BINARY : \Illuminate\Support\php_binary(),
static fn ($phpBinary) => ProcessUtils::escapeArgument((string) $phpBinary)
);

Expand Down
4 changes: 2 additions & 2 deletions tests/Integrations/ArtisanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Test;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\Process;

use function Illuminate\Support\php_binary;
use function Orchestra\Testbench\package_path;
use function Orchestra\Testbench\remote;

Expand All @@ -17,7 +17,7 @@ class ArtisanTest extends TestCase
#[Group('core')]
public function it_can_generate_the_same_output()
{
$phpBinary = \defined('PHP_BINARY') ? PHP_BINARY : (new PhpExecutableFinder)->find();
$phpBinary = \defined('PHP_BINARY') ? PHP_BINARY : php_binary();

$remote = remote('--version --no-ansi')->mustRun();

Expand Down

0 comments on commit 0a31521

Please sign in to comment.