Skip to content

Commit

Permalink
Support Laravel 9 (#419)
Browse files Browse the repository at this point in the history
* Fix tests for Laravel 9 (#421)

* Set base path to Laravel application correctly

Co-authored-by: Michel Bardelmeijer <m.bardelmeijer@gmail.com>
  • Loading branch information
barryvdh and mbardelmeijer committed Feb 10, 2022
1 parent 9db7e07 commit ea5b2e1
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 70 deletions.
66 changes: 16 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,16 @@ jobs:
fail-fast: true
matrix:
php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]
laravel: [ '5.5', '5.6', '5.7', '5.8', '6', '7', '8' ]
laravel: ['6', '7', '8', '9' ]
exclude:
- php: '7.2'
laravel: '8'
- php: '8.0'
laravel: '5.5'
- php: '8.0'
laravel: '5.6'
- php: '8.0'
laravel: '5.7'
- php: '8.0'
laravel: '5.8'
- php: '8.1'
laravel: '5.5'
- php: '8.1'
laravel: '5.6'
- php: '8.1'
laravel: '5.7'
- php: '8.1'
laravel: '5.8'
- php: '7.2'
laravel: '9'
- php: '7.3'
laravel: '9'
- php: '7.4'
laravel: '9'
- php: '8.1'
laravel: '6'
- php: '8.1'
Expand All @@ -53,38 +43,6 @@ jobs:
- name: Setup Problem Matchers
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Select Laravel 5.5
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer require "laravel/framework:5.5.*" "phpunit/phpunit:^6.5.14" --no-update --no-interaction
if: "matrix.laravel == '5.5'"

- name: Select Laravel 5.6
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer require "laravel/framework:5.6.*" "phpunit/phpunit:^7.5.20" --no-update --no-interaction
if: "matrix.laravel == '5.6'"

- name: Select Laravel 5.7
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer require "laravel/framework:5.7.*" "phpunit/phpunit:^7.5.20" --no-update --no-interaction
if: "matrix.laravel == '5.7'"

- name: Select Laravel 5.8
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer require "laravel/framework:5.8.*" "phpunit/phpunit:^7.5.20|^8.5.8" --no-update --no-interaction
if: "matrix.laravel == '5.8'"

- name: Select Laravel 6
uses: nick-invision/retry@v1
with:
Expand All @@ -108,6 +66,14 @@ jobs:
max_attempts: 5
command: composer require "laravel/framework:8.*" "phpunit/phpunit:^9.3.7" --no-update --no-interaction
if: "matrix.laravel == '8'"

- name: Select Laravel 9
uses: nick-invision/retry@v1
with:
timeout_minutes: 5
max_attempts: 5
command: composer require "laravel/framework:9.*" "phpunit/phpunit:^9.3.7" --no-update --no-interaction
if: "matrix.laravel == '9'"

- name: Install PHP Dependencies
uses: nick-invision/retry@v1
Expand All @@ -124,4 +90,4 @@ jobs:

- name: Check code coverage
if: ${{ matrix.php == '8.1' }}
uses: codecov/codecov-action@v2.1.0
uses: codecov/codecov-action@v2.1.0
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
"require": {
"php": "^7.2.5 || ^8.0",
"twig/twig": "~3.0",
"illuminate/support": "^5.5 || ^6.0 || ^7.0 || ^8.0",
"illuminate/view": "^5.5 || ^6.0 || ^7.0 || ^8.0"
"illuminate/support": "^6|^7|^8|^9",
"illuminate/view": "^6|^7|^8|^9"
},
"require-dev": {
"ext-json": "*",
"laravel/framework": "^5.5 || ^6.0 || ^7.0 || ^8.0",
"laravel/framework": "^6|^7|^8|^9",
"mockery/mockery": "^1.3.1",
"phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.7",
"squizlabs/php_codesniffer": "^3.6"
Expand Down Expand Up @@ -49,5 +49,6 @@
}
}
},
"minimum-stability": "dev"
"minimum-stability": "dev",
"prefer-stable": true
}
3 changes: 1 addition & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="TwigBridge Test Suite">
Expand Down Expand Up @@ -41,4 +40,4 @@
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
</phpunit>
</phpunit>
2 changes: 1 addition & 1 deletion src/Command/Lint.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected function getFiles($filename, array $files, array $directories)
}

// If no files passed, use the view paths
if (empty($search)) {
if (empty($search) && !empty($paths)) {
foreach ($this->getFinder($paths) as $file) {
$search[] = $file->getRealPath();
}
Expand Down
11 changes: 4 additions & 7 deletions tests/Command/Lint/FinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace TwigBridge\Tests\Command\Lint;

use Mockery as m;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\StreamOutput;
use TwigBridge\Command\Lint;

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

public function testSet()
{
$data = ['fooBar'];

/** @var \Symfony\Component\Finder\Finder|\Mockery\MockInterface $finder */
$finder = m::mock('Symfony\Component\Finder\Finder');
$finder->shouldReceive('files')->andReturn($finder);
$finder->shouldReceive('in')->andReturn($finder);
$finder->shouldReceive('name')->andReturn($data);
$finder->shouldReceive('name')->andReturn($finder);
$finder->shouldReceive('count')->andReturn(1);

$app = $this->getApplication();
$command = new Lint;
$command->setLaravel($app);
$command->setFinder($finder);
$command->setFinder($finder);

$this->assertEquals($data, $command->getFinder([__DIR__]));
$this->assertEquals(1, $command->getFinder([__DIR__])->count());
}
}
7 changes: 4 additions & 3 deletions tests/Command/Lint/FormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function testEmptyJSON()
}

/**
* @expectedException InvalidArgumentException
* @expectedException \InvalidArgumentException
*/
public function testInvalidFormat()
{
Expand All @@ -70,13 +70,14 @@ public function testInvalidFormat()

$command->setLaravel($app);

$finder = m::mock('Symfony\Component\Finder\Finder');
/** @var \Symfony\Component\Finder\Finder|\Mockery\MockInterface $finder */
$finder = m::mock('Symfony\Component\Finder\Finder')->makePartial();
$finder->shouldReceive('files')->andReturn($finder);
$finder->shouldReceive('in')->andReturn($finder);
$finder->shouldReceive('name')->andReturn($finder);
$command->setFinder($finder);

$input = new ArrayInput([
$input = new ArrayInput([
'--format' => 'foo'
]);
$output = m::mock('Symfony\Component\Console\Output\NullOutput')->makePartial();
Expand Down
2 changes: 1 addition & 1 deletion tests/ServiceProvider/Bindings/TwigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testTwigOptions()

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

// Make sure same config is returned
$options['cache'] = null;
Expand Down
3 changes: 1 addition & 2 deletions tests/TwigBridgeTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public function tearDown(): void
*/
protected function getApplication(array $customConfig = [])
{
$app = new Application;
$app->instance('path', __DIR__);
$app = new Application(__DIR__);

$app['env'] = 'production';
$app['path.config'] = __DIR__ . '/config';
Expand Down

0 comments on commit ea5b2e1

Please sign in to comment.