Skip to content

Commit c1c6194

Browse files
authored
[12.x] Test Improvements (#55306)
Signed-off-by: Mior Muhammad Zaki <[email protected]>
1 parent e150f37 commit c1c6194

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

.github/workflows/tests.yml

Lines changed: 10 additions & 6 deletions
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.5.3', '12.0.0']
43+
phpunit: ['10.5.35', '11.5.3', '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

@@ -72,7 +74,7 @@ jobs:
7274
with:
7375
timeout_minutes: 5
7476
max_attempts: 5
75-
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --with="phpunit/phpunit:^${{ matrix.phpunit }}"
77+
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --with="phpunit/phpunit:~${{ matrix.phpunit }}"
7678

7779
- name: Execute tests
7880
run: vendor/bin/phpunit --display-deprecation ${{ matrix.stability == 'prefer-stable' && '--fail-on-deprecation' || '' }}
@@ -99,11 +101,13 @@ jobs:
99101
fail-fast: true
100102
matrix:
101103
php: [8.2, 8.3, 8.4]
102-
phpunit: ['11.5.3']
104+
phpunit: ['10.5.35', '11.5.3', '12.0.0', '12.1.0']
103105
stability: [prefer-lowest, prefer-stable]
104106
exclude:
105-
- php: 8.4
106-
stability: prefer-lowest
107+
- php: 8.2
108+
phpunit: '12.0.0'
109+
- php: 8.2
110+
phpunit: '12.1.0'
107111

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

@@ -132,7 +136,7 @@ jobs:
132136
with:
133137
timeout_minutes: 5
134138
max_attempts: 5
135-
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --with="phpunit/phpunit:^${{ matrix.phpunit }}"
139+
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --with="phpunit/phpunit:~${{ matrix.phpunit }}"
136140

137141
- name: Execute tests
138142
run: vendor/bin/phpunit

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"pda/pheanstalk": "^5.0.6",
116116
"php-http/discovery": "^1.15",
117117
"phpstan/phpstan": "^2.0",
118-
"phpunit/phpunit": "^10.5.35|^11.5.3|~12.0.1",
118+
"phpunit/phpunit": "^10.5.35|^11.5.3|^12.0.1",
119119
"predis/predis": "^2.3",
120120
"resend/resend-php": "^0.10.0",
121121
"symfony/cache": "^7.2.0",

tests/Integration/View/BladeTest.php

Lines changed: 16 additions & 6 deletions
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)