Skip to content

Commit ea5b2e1

Browse files
Support Laravel 9 (#419)
* Fix tests for Laravel 9 (#421) * Set base path to Laravel application correctly Co-authored-by: Michel Bardelmeijer <[email protected]>
1 parent 9db7e07 commit ea5b2e1

File tree

8 files changed

+33
-70
lines changed

8 files changed

+33
-70
lines changed

.github/workflows/ci.yml

+16-50
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,16 @@ jobs:
1212
fail-fast: true
1313
matrix:
1414
php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]
15-
laravel: [ '5.5', '5.6', '5.7', '5.8', '6', '7', '8' ]
15+
laravel: ['6', '7', '8', '9' ]
1616
exclude:
1717
- php: '7.2'
1818
laravel: '8'
19-
- php: '8.0'
20-
laravel: '5.5'
21-
- php: '8.0'
22-
laravel: '5.6'
23-
- php: '8.0'
24-
laravel: '5.7'
25-
- php: '8.0'
26-
laravel: '5.8'
27-
- php: '8.1'
28-
laravel: '5.5'
29-
- php: '8.1'
30-
laravel: '5.6'
31-
- php: '8.1'
32-
laravel: '5.7'
33-
- php: '8.1'
34-
laravel: '5.8'
19+
- php: '7.2'
20+
laravel: '9'
21+
- php: '7.3'
22+
laravel: '9'
23+
- php: '7.4'
24+
laravel: '9'
3525
- php: '8.1'
3626
laravel: '6'
3727
- php: '8.1'
@@ -53,38 +43,6 @@ jobs:
5343
- name: Setup Problem Matchers
5444
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
5545

56-
- name: Select Laravel 5.5
57-
uses: nick-invision/retry@v1
58-
with:
59-
timeout_minutes: 5
60-
max_attempts: 5
61-
command: composer require "laravel/framework:5.5.*" "phpunit/phpunit:^6.5.14" --no-update --no-interaction
62-
if: "matrix.laravel == '5.5'"
63-
64-
- name: Select Laravel 5.6
65-
uses: nick-invision/retry@v1
66-
with:
67-
timeout_minutes: 5
68-
max_attempts: 5
69-
command: composer require "laravel/framework:5.6.*" "phpunit/phpunit:^7.5.20" --no-update --no-interaction
70-
if: "matrix.laravel == '5.6'"
71-
72-
- name: Select Laravel 5.7
73-
uses: nick-invision/retry@v1
74-
with:
75-
timeout_minutes: 5
76-
max_attempts: 5
77-
command: composer require "laravel/framework:5.7.*" "phpunit/phpunit:^7.5.20" --no-update --no-interaction
78-
if: "matrix.laravel == '5.7'"
79-
80-
- name: Select Laravel 5.8
81-
uses: nick-invision/retry@v1
82-
with:
83-
timeout_minutes: 5
84-
max_attempts: 5
85-
command: composer require "laravel/framework:5.8.*" "phpunit/phpunit:^7.5.20|^8.5.8" --no-update --no-interaction
86-
if: "matrix.laravel == '5.8'"
87-
8846
- name: Select Laravel 6
8947
uses: nick-invision/retry@v1
9048
with:
@@ -108,6 +66,14 @@ jobs:
10866
max_attempts: 5
10967
command: composer require "laravel/framework:8.*" "phpunit/phpunit:^9.3.7" --no-update --no-interaction
11068
if: "matrix.laravel == '8'"
69+
70+
- name: Select Laravel 9
71+
uses: nick-invision/retry@v1
72+
with:
73+
timeout_minutes: 5
74+
max_attempts: 5
75+
command: composer require "laravel/framework:9.*" "phpunit/phpunit:^9.3.7" --no-update --no-interaction
76+
if: "matrix.laravel == '9'"
11177

11278
- name: Install PHP Dependencies
11379
uses: nick-invision/retry@v1
@@ -124,4 +90,4 @@ jobs:
12490

12591
- name: Check code coverage
12692
if: ${{ matrix.php == '8.1' }}
127-
uses: codecov/[email protected]
93+
uses: codecov/[email protected]

composer.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
"require": {
1717
"php": "^7.2.5 || ^8.0",
1818
"twig/twig": "~3.0",
19-
"illuminate/support": "^5.5 || ^6.0 || ^7.0 || ^8.0",
20-
"illuminate/view": "^5.5 || ^6.0 || ^7.0 || ^8.0"
19+
"illuminate/support": "^6|^7|^8|^9",
20+
"illuminate/view": "^6|^7|^8|^9"
2121
},
2222
"require-dev": {
2323
"ext-json": "*",
24-
"laravel/framework": "^5.5 || ^6.0 || ^7.0 || ^8.0",
24+
"laravel/framework": "^6|^7|^8|^9",
2525
"mockery/mockery": "^1.3.1",
2626
"phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.7",
2727
"squizlabs/php_codesniffer": "^3.6"
@@ -49,5 +49,6 @@
4949
}
5050
}
5151
},
52-
"minimum-stability": "dev"
52+
"minimum-stability": "dev",
53+
"prefer-stable": true
5354
}

phpunit.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
>
1312
<testsuites>
1413
<testsuite name="TwigBridge Test Suite">
@@ -41,4 +40,4 @@
4140
<log type="coverage-clover" target="build/logs/clover.xml"/>
4241
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
4342
</logging>
44-
</phpunit>
43+
</phpunit>

src/Command/Lint.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ protected function getFiles($filename, array $files, array $directories)
154154
}
155155

156156
// If no files passed, use the view paths
157-
if (empty($search)) {
157+
if (empty($search) && !empty($paths)) {
158158
foreach ($this->getFinder($paths) as $file) {
159159
$search[] = $file->getRealPath();
160160
}

tests/Command/Lint/FinderTest.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
namespace TwigBridge\Tests\Command\Lint;
44

55
use Mockery as m;
6-
use Symfony\Component\Console\Input\ArrayInput;
7-
use Symfony\Component\Console\Output\StreamOutput;
86
use TwigBridge\Command\Lint;
97

108
class FinderTest extends Base
@@ -19,19 +17,18 @@ public function testGet()
1917

2018
public function testSet()
2119
{
22-
$data = ['fooBar'];
23-
20+
/** @var \Symfony\Component\Finder\Finder|\Mockery\MockInterface $finder */
2421
$finder = m::mock('Symfony\Component\Finder\Finder');
2522
$finder->shouldReceive('files')->andReturn($finder);
2623
$finder->shouldReceive('in')->andReturn($finder);
27-
$finder->shouldReceive('name')->andReturn($data);
24+
$finder->shouldReceive('name')->andReturn($finder);
25+
$finder->shouldReceive('count')->andReturn(1);
2826

2927
$app = $this->getApplication();
3028
$command = new Lint;
3129
$command->setLaravel($app);
3230
$command->setFinder($finder);
33-
$command->setFinder($finder);
3431

35-
$this->assertEquals($data, $command->getFinder([__DIR__]));
32+
$this->assertEquals(1, $command->getFinder([__DIR__])->count());
3633
}
3734
}

tests/Command/Lint/FormatTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function testEmptyJSON()
5959
}
6060

6161
/**
62-
* @expectedException InvalidArgumentException
62+
* @expectedException \InvalidArgumentException
6363
*/
6464
public function testInvalidFormat()
6565
{
@@ -70,13 +70,14 @@ public function testInvalidFormat()
7070

7171
$command->setLaravel($app);
7272

73-
$finder = m::mock('Symfony\Component\Finder\Finder');
73+
/** @var \Symfony\Component\Finder\Finder|\Mockery\MockInterface $finder */
74+
$finder = m::mock('Symfony\Component\Finder\Finder')->makePartial();
7475
$finder->shouldReceive('files')->andReturn($finder);
7576
$finder->shouldReceive('in')->andReturn($finder);
7677
$finder->shouldReceive('name')->andReturn($finder);
7778
$command->setFinder($finder);
7879

79-
$input = new ArrayInput([
80+
$input = new ArrayInput([
8081
'--format' => 'foo'
8182
]);
8283
$output = m::mock('Symfony\Component\Console\Output\NullOutput')->makePartial();

tests/ServiceProvider/Bindings/TwigTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testTwigOptions()
2929

3030
// Make sure that twig.options sets the storage path automatically
3131
$this->assertEmpty($config['cache']);
32-
$this->assertEquals(realpath($options['cache']), realpath(__DIR__.'/../..').'/storage/framework/views/twig');
32+
$this->assertEquals(realpath(__DIR__.'/../..') . '/storage/framework/views/twig', $options['cache']);
3333

3434
// Make sure same config is returned
3535
$options['cache'] = null;

tests/TwigBridgeTestTrait.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ public function tearDown(): void
3232
*/
3333
protected function getApplication(array $customConfig = [])
3434
{
35-
$app = new Application;
36-
$app->instance('path', __DIR__);
35+
$app = new Application(__DIR__);
3736

3837
$app['env'] = 'production';
3938
$app['path.config'] = __DIR__ . '/config';

0 commit comments

Comments
 (0)