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 22, 2024
2 parents 0a31521 + d33d7b8 commit 00ad6d8
Show file tree
Hide file tree
Showing 19 changed files with 89 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: crynobone
liberapay: # crynobone
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # ["https://paypal.me/crynobone"]
7 changes: 5 additions & 2 deletions .github/workflows/analyse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
os:
- "ubuntu-latest"
php:
- 8.2
- 8.3
dependencies:
- "highest"
experimental:
Expand All @@ -39,8 +39,11 @@ jobs:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "--prefer-dist --no-cache"

- name: Execute Code Style
run: vendor/bin/pint --test

- name: Execute Static Code Analysis
run: vendor/bin/phpstan analyse
run: vendor/bin/phpstan analyse --verbose

lint:
runs-on: ${{ matrix.os }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/collision-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
os:
- "ubuntu-latest"
php:
- 8.2
- 8.3
dependencies:
- "highest"
experimental:
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
os:
- "ubuntu-latest"
php:
- 8.2
- 8.3
dependencies:
- "highest"
experimental:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coveralls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
os:
- "ubuntu-latest"
php:
- 8.2
- 8.3
phpunit:
- "^11.0"
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/parallel-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
os:
- "ubuntu-latest"
php:
- 8.2
- 8.3
collision:
- "^8.0"
paratest:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/strict-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ jobs:
- 8.3
phpunit:
- "~10.5.0"
- "~11.0.0"
- "~11.1.0"
- "~11.2.0"
- "~11.3.0"
- "~11.4.0"
dependencies:
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,11 @@ jobs:
- 8.4
phpunit:
- "~10.5.0"
- "~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
2 changes: 1 addition & 1 deletion .github/workflows/update-skeleton.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.3
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, mysql, mysqli, pdo_mysql, bcmath, intl, fileinfo, :php-psr
coverage: none

Expand Down
1 change: 1 addition & 0 deletions bin/sync
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ transform([
PHP_EOL.'DB_USERNAME=' => PHP_EOL.'# DB_USERNAME=',
PHP_EOL.'DB_PASSWORD=' => PHP_EOL.'# DB_PASSWORD=',
PHP_EOL.'SESSION_DRIVER=database' => PHP_EOL.'SESSION_DRIVER=cookie',
PHP_EOL.'PHP_CLI_SERVER_WORKERS=' => PHP_EOL.'# PHP_CLI_SERVER_WORKERS=',
], fn ($changes) => $files->replaceInFile(array_keys($changes), array_values($changes), "{$workingPath}/laravel/.env.example"));

Illuminate\Support\Collection::make([
Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,26 @@
"require": {
"php": "^8.2",
"composer-runtime-api": "^2.2",
"symfony/polyfill-php83": "^1.28"
"symfony/polyfill-php83": "^1.31",
"symfony/polyfill-php84": "^1.31"
},
"require-dev": {
"fakerphp/faker": "^1.23",
"laravel/framework": "^12.0",
"laravel/pint": "^1.17",
"mockery/mockery": "^1.6",
"mockery/mockery": "^1.6.10",
"phpstan/phpstan": "^1.11",
"phpunit/phpunit": "^10.5 || ^11.0.1",
"symfony/process": "^7.0",
"symfony/yaml": "^7.0",
"vlucas/phpdotenv": "^5.4.1"
"phpunit/phpunit": "^10.5.35 || ^11.3.6",
"symfony/process": "^7.0.3",
"symfony/yaml": "^7.0.3",
"vlucas/phpdotenv": "^5.6.1"
},
"conflict": {
"brianium/paratest": "<7.3.0 || >=8.0.0",
"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.5.0"
"phpunit/phpunit": "<10.5.35 || >=11.0.0 <11.3.6 || >=11.5.0"
},
"suggest": {
"ext-pcntl": "Required to use all features of the console signal trapping.",
Expand Down
2 changes: 2 additions & 0 deletions laravel/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ APP_FAKER_LOCALE=en_US
APP_MAINTENANCE_DRIVER=file
# APP_MAINTENANCE_STORE=database

# PHP_CLI_SERVER_WORKERS=4

BCRYPT_ROUNDS=12

LOG_CHANNEL=stack
Expand Down
18 changes: 11 additions & 7 deletions laravel/resources/views/welcome.blade.php

Large diffs are not rendered by default.

15 changes: 0 additions & 15 deletions src/Concerns/InteractsWithMigrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,6 @@ 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
21 changes: 20 additions & 1 deletion src/Console/Commander.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Orchestra\Testbench\Console;

use Illuminate\Console\Concerns\InteractsWithSignals;
use Illuminate\Console\Signals;
use Illuminate\Contracts\Console\Kernel as ConsoleKernel;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Filesystem\Filesystem;
Expand All @@ -14,6 +13,7 @@
use Orchestra\Testbench\Foundation\Bootstrap\LoadMigrationsFromArray;
use Orchestra\Testbench\Foundation\Config;
use Orchestra\Testbench\Foundation\Console\Concerns\CopyTestbenchFiles;
use Orchestra\Testbench\Foundation\Console\Signals;
use Orchestra\Testbench\Foundation\TestbenchServiceProvider;
use Orchestra\Testbench\Workbench\Workbench;
use Symfony\Component\Console\Application as ConsoleApplication;
Expand Down Expand Up @@ -258,6 +258,25 @@ protected function prepareCommandSignals(): void
exit($status);
})
);
}, function () {
if (windows_os() && PHP_SAPI === 'cli' && \function_exists('sapi_windows_set_ctrl_handler')) {
sapi_windows_set_ctrl_handler(function ($event) {
$this->handleTerminatingConsole();
Workbench::flush();

$status = match ($event) {
PHP_WINDOWS_EVENT_CTRL_C => 572,
PHP_WINDOWS_EVENT_CTRL_BREAK => 572,
default => 0,
};

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

exit($status);
});
}
});
}
}
2 changes: 2 additions & 0 deletions src/Foundation/Console/Concerns/HandleTerminatingConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ protected function handleTerminatingConsole(): void
->each(static function ($callback) {
\call_user_func($callback);
});

$this->beforeTerminatingCallbacks = [];
}
}
27 changes: 27 additions & 0 deletions src/Foundation/Console/Signals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Orchestra\Testbench\Foundation\Console;

class Signals extends \Illuminate\Console\Signals
{
/**
* Execute the given callback if "signals" should be used and are available.
*
* @param callable $callback
* @param callable|null $default
* @return void
*/
#[\Override]
public static function whenAvailable($callback, $default = null)
{
if (\is_null($resolver = static::$availabilityResolver)) {
return;
}

if ($resolver()) {
$callback();
} elseif (\is_callable($default)) {
$default();
}
}
}
1 change: 1 addition & 0 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ function workbench_path(array|string $path = ''): string
*
* @deprecated
*/
#[\Deprecated(message: 'Use `Orchestra\Testbench\default_migration_path()` instead', since: '9.5.1')]
function laravel_migration_path(?string $type = null): string
{
return default_migration_path($type);
Expand Down
1 change: 1 addition & 0 deletions tests/Integrations/ArtisanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function it_can_generate_the_same_output()
$artisan = (new Process(
command: [$phpBinary, 'artisan', '--version', '--no-ansi'],
cwd: package_path('laravel'),
env: ['TESTBENCH_WORKING_PATH' => package_path()],
))->mustRun();

$this->assertSame(json_decode($artisan->getOutput(), true), json_decode($remote->getOutput(), true));
Expand Down
5 changes: 5 additions & 0 deletions tests/TestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public function it_can_create_the_testcase()
$this->assertInstanceOf(TestCaseContract::class, $testbench);
$this->assertTrue($testbench->isRunningTestCase());
$this->assertFalse($testbench->isRunningTestCaseUsingPest());

$app->terminate();
}

#[Test]
Expand All @@ -65,5 +67,8 @@ public function it_can_create_a_container()
$this->assertInstanceOf(ConfigRepository::class, $app['config']);

$this->assertFalse($container->isRunningTestCase());
$this->assertFalse($container->isRunningTestCaseUsingPest());

$app->terminate();
}
}

0 comments on commit 00ad6d8

Please sign in to comment.