8000 [11.x] Test Improvements · laravel/framework@49cc445 · GitHub
[go: up one dir, main page]

Skip to content

Commit 49cc445

Browse files
committed
[11.x] Test Improvements
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
1 parent 5eb8a7c commit 49cc445

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

.github/workflows/tests.yml

+5-18
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ jobs:
4040
fail-fast: true
4141
matrix:
4242
php: [8.2, 8.3, 8.4]
43-
phpunit: ['10.5.35', '11.3.2', '12.0.0']
43+
phpunit: ['10.5.35', '11.3.2', '12.0.0', '12.1.0']
4444
stability: [prefer-lowest, prefer-stable]
4545
exclude:
4646
- php: 8.2
4747
phpunit: '12.0.0'
48+
- php: 8.2
49+
phpunit: '12.1.0'
4850

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

@@ -76,19 +78,12 @@ jobs:
7678
shell: bash
7779
if: matrix.php >= 8.4
7880

79-
- name: Set PHPUnit
80-
uses: nick-fields/retry@v3
81-
with:
82-
timeout_minutes: 5
83-
max_attempts: 5
84-
command: composer require phpunit/phpunit:^${{ matrix.phpunit }} --dev --no-interaction --no-update
85-
8681
- name: Install dependencies
8782
uses: nick-fields/retry@v3
8883
with:
8984
timeout_minutes: 5
9085
max_attempts: 5
91-
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
86+
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --with="phpunit/phpunit:~${{ matrix.phpunit }}"
9287

9388
- name: Execute tests
9489
run: vendor/bin/phpunit --display-deprecation ${{ matrix.stability == 'prefer-stable' && '--fail-on-deprecation' || '' }}
@@ -143,20 +138,12 @@ jobs:
143138
- name: Set Framework version
144139
run: composer config version "11.x-dev"
145140

146-
- name: Set PHPUnit
147-
uses: nick-fields/retry@v3
148-
with:
149-
timeout_minutes: 5
150-
max_attempts: 5
151-
command: composer require phpunit/phpunit:^${{ matrix.phpunit }} --dev --no-interaction --no-update
152-
shell: bash
153-
154141
- name: Install dependencies
155142
uses: nick-fields/retry@v3
156143
with:
157144
timeout_minutes: 5
158145
max_attempts: 5
159-
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
146+
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --with="phpunit/phpunit:~${{ matrix.phpunit }}"
160147

161148
- name: Execute tests
162149
run: vendor/bin/phpunit

tests/Integration/View/BladeTest.php

+16-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,20 @@
1111
use Symfony\Component\Finder\Finder;
1212
use Symfony\Component\Finder\SplFileInfo;
1313

14+
use function Orchestra\Testbench\artisan;
15+
use function Orchestra\Testbench\phpunit_version_compare;
16+
1417
class BladeTest extends TestCase
1518
{
19+
/** {@inheritdoc} */
20+
#[\Override]
21+
protected function tearDown(): void
22+
{
23+
artisan($this, 'view:clear');
24+
25+
parent::tearDown();
26+
}
27+
1628
public function test_rendering_blade_string()
1729
{
1830
$this->assertSame('Hello Taylor', Blade::render('Hello {{ $name }}', ['name' => 'Taylor']));
@@ -33,8 +45,8 @@ public function test_rendering_blade_long_maxpathlen_string_with_exact_length()
3345
// The PHP_MAXPATHLEN restriction is only active, if
3446
// open_basedir is set and active. Otherwise, the check
3547
// for the PHP_MAXPATHLEN is not active.
36-
if (ini_get('open_basedir') === '') {
37-
$openBaseDir = windows_os() ? explode('\\', __DIR__)[0].'\\'.';'.sys_get_temp_dir() : '/';
48+
if (ini_get('open_basedir') === '' && phpunit_version_compare('12.1.0', '<')) {
49+
$openBaseDir = explode(DIRECTORY_SEPARATOR, __DIR__)[0].DIRECTORY_SEPARATOR.PATH_SEPARATOR.sys_get_temp_dir();
3850
$iniSet = ini_set(
3951
'open_basedir',
4052
$openBaseDir
@@ -197,19 +209,17 @@ public function test_bound_name_attribute_can_be_used_if_using_short_slot_names_
197209

198210
public function testViewCacheCommandHandlesConfiguredBladeExtensions()
199211
{
200-
$this->artisan('view:clear');
201-
202212
View::addExtension('sh', 'blade');
203213
$this->artisan('view:cache');
204214

205215
$compiledFiles = Finder::create()->in(Config::get('view.compiled'))->files();
206216
$found = collect($compiledFiles)
207217
->contains(fn (SplFileInfo $file) => str_contains($file->getContents(), 'echo "<?php echo e($scriptMessage); ?>" > output.log'));
208218
$this->assertTrue($found);
209-
210-
$this->artisan('view:clear');
211219
}
212220

221+
/** {@inheritdoc} */
222+
#[\Override]
213223
protected function defineEnvironment($app)
214224
{
215225
$app['config']->set('view.paths', [__DIR__.'/templates']);

0 commit comments

Comments
 (0)
0