8000 [11.x] Test Improvements by crynobone · Pull Request #55302 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

[11.x] Test Improvements #55302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 10 additions & 21 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ jobs:
fail-fast: true
matrix:
php: [8.2, 8.3, 8.4]
phpunit: ['10.5.35', '11.3.2', '12.0.0']
phpunit: ['10.5.35', '11.3.2', '12.0.0', '12.1.0']
stability: [prefer-lowest, prefer-stable]
exclude:
- php: 8.2
phpunit: '12.0.0'
- php: 8.2
phpunit: '12.1.0'

name: PHP ${{ matrix.php }} - PHPUnit ${{ matrix.phpunit }} - ${{ matrix.stability }}

Expand Down Expand Up @@ -76,19 +78,12 @@ jobs:
shell: bash
if: matrix.php >= 8.4

- name: Set PHPUnit
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: composer require phpunit/phpunit:^${{ matrix.phpunit }} --dev --no-interaction --no-update

- name: Install dependencies
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --with="phpunit/phpunit:~${{ matrix.phpunit }}"

- name: Execute tests
run: vendor/bin/phpunit --display-deprecation ${{ matrix.stability == 'prefer-stable' && '--fail-on-deprecation' || '' }}
Expand All @@ -115,11 +110,13 @@ jobs:
fail-fast: true
matrix:
php: [8.2, 8.3, 8.4]
phpunit: ['10.5', '11.0.1']
phpunit: ['10.5.35', '11.3.2', '12.0.0', '12.1.0']
stability: [prefer-lowest, prefer-stable]
exclude:
- php: 8.4
stability: prefer-lowest
- php: 8.2
phpunit: '12.0.0'
- php: 8.2
phpunit: '12.1.0'

name: PHP ${{ matrix.php }} - PHPUnit ${{ matrix.phpunit }} - ${{ matrix.stability }} - Windows

Expand All @@ -143,20 +140,12 @@ jobs:
- name: Set Framework version
run: composer config version "11.x-dev"

- name: Set PHPUnit
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: composer require phpunit/phpunit:^${{ matrix.phpunit }} --dev --no-interaction --no-update
shell: bash

- name: Install dependencies
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --with="phpunit/phpunit:~${{ matrix.phpunit }}"

- name: Execute tests
run: vendor/bin/phpunit
Expand Down
22 changes: 16 additions & 6 deletions tests/Integration/View/BladeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;

use function Orchestra\Testbench\artisan;
use function Orchestra\Testbench\phpunit_version_compare;

class BladeTest extends TestCase
{
/** {@inheritdoc} */
#[\Override]
protected function tearDown(): void
{
artisan($this, 'view:clear');

parent::tearDown();
}

public function test_rendering_blade_string()
{
$this->assertSame('Hello Taylor', Blade::render('Hello {{ $name }}', ['name' => 'Taylor']));
Expand All @@ -33,8 +45,8 @@ public function test_rendering_blade_long_maxpathlen_string_with_exact_length()
// The PHP_MAXPATHLEN restriction is only active, if
// open_basedir is set and active. Otherwise, the check
// for the PHP_MAXPATHLEN is not active.
if (ini_get('open_basedir') === '') {
$openBaseDir = windows_os() ? explode('\\', __DIR__)[0].'\\'.';'.sys_get_temp_dir() : '/';
if (ini_get('open_basedir') === '' && phpunit_version_compare('12.1.0', '<')) {
$openBaseDir = explode(DIRECTORY_SEPARATOR, __DIR__)[0].DIRECTORY_SEPARATOR.PATH_SEPARATOR.sys_get_temp_dir();
$iniSet = ini_set(
'open_basedir',
$openBaseDir
Expand Down Expand Up @@ -197,19 +209,17 @@ public function test_bound_name_attribute_can_be_used_if_using_short_slot_names_

public function testViewCacheCommandHandlesConfiguredBladeExtensions()
{
$this->artisan('view:clear');

View::addExtension('sh', 'blade');
$this->artisan('view:cache');

$compiledFiles = Finder::create()->in(Config::get('view.compiled'))->files();
$found = collect($compiledFiles)
->contains(fn (SplFileInfo $file) => str_contains($file->getContents(), 'echo "<?php echo e($scriptMessage); ?>" > output.log'));
$this->assertTrue($found);

$this->artisan('view:clear');
}

/** {@inheritdoc} */
#[\Override]
protected function defineEnvironment($app)
{
$app['config']->set('view.paths', [__DIR__.'/templates']);
Expand Down
Loading
0