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

Skip to content

Commit e1c9eab

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

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

.github/workflows/tests.yml

+2-17
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,12 @@ jobs:
7676
shell: bash
7777
if: matrix.php >= 8.4
7878

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-
8679
- name: Install dependencies
8780
uses: nick-fields/retry@v3
8881
with:
8982
timeout_minutes: 5
9083
max_attempts: 5
91-
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
84+
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --with="phpunit/phpunit:~${{ matrix.phpunit }}"
9285

9386
- name: Execute tests
9487
run: vendor/bin/phpunit --display-deprecation ${{ matrix.stability == 'prefer-stable' && '--fail-on-deprecation' || '' }}
@@ -143,20 +136,12 @@ jobs:
143136
- name: Set Framework version
144137
run: composer config version "11.x-dev"
145138

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-
154139
- name: Install dependencies
155140
uses: nick-fields/retry@v3
156141
with:
157142
timeout_minutes: 5
158143
max_attempts: 5
159-
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
144+
command: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --with="phpunit/phpunit:~${{ matrix.phpunit }}"
160145

161146
- name: Execute tests
162147
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