From a49cb46fdfc1de88e78b17ea73862f85733b4f82 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Fri, 28 Aug 2020 22:26:05 +0200 Subject: [PATCH] Bump Laravel versions (#1022) * Bump Laravel versions * Test Laravel 8 * Update composer.json * Update composer.json * normalize composer.json * Tweak MethodTest for Laravel 8 Co-authored-by: barryvdh --- .github/workflows/run-tests.yml | 6 +++--- composer.json | 16 +++++++++------- tests/MethodTest.php | 30 ++++++++++++++++++++---------- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 889e597..528aeaf 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -20,11 +20,11 @@ jobs: strategy: matrix: php: [7.4, 7.3, 7.2] - laravel: [7.*, 6.*, 5.5.*] + laravel: [8.*, 7.*, 6.*] dependency-version: [prefer-lowest, prefer-stable] exclude: - - laravel: 5.5.* - php: 7.4 + - laravel: 8.* + php: 7.2 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} diff --git a/composer.json b/composer.json index a4f27d0..1223b86 100644 --- a/composer.json +++ b/composer.json @@ -25,16 +25,16 @@ "barryvdh/reflection-docblock": "^2.0.6", "composer/composer": "^1.6 || ^2.0@dev", "doctrine/dbal": "~2.3", - "illuminate/console": "^5.5 || ^6 || ^7", - "illuminate/filesystem": "^5.5 || ^6 || ^7", - "illuminate/support": "^5.5 || ^6 || ^7", + "illuminate/console": "^6 || ^7 || ^8", + "illuminate/filesystem": "^6 || ^7 || ^8", + "illuminate/support": "^6 || ^7 || ^8", "phpdocumentor/type-resolver": "^1.1.0" }, "require-dev": { - "illuminate/config": "^5.5 || ^6 || ^7", - "illuminate/view": "^5.5 || ^6 || ^7", + "illuminate/config": "^6 || ^7 || ^8", + "illuminate/view": "^6 || ^7 || ^8", "mockery/mockery": "^1.3", - "orchestra/testbench": "^3.5 || ^4 || ^5", + "orchestra/testbench": "^4 || ^5 || ^6", "phpro/grumphp": "^0.19.0", "spatie/phpunit-snapshot-assertions": "^1.4 || ^2.2 || ^3", "squizlabs/php_codesniffer": "^3.5", @@ -45,7 +45,7 @@ }, "extra": { "branch-alias": { - "dev-master": "2.7-dev" + "dev-master": "2.8-dev" }, "laravel": { "providers": [ @@ -63,6 +63,8 @@ "Barryvdh\\LaravelIdeHelper\\Tests\\": "tests" } }, + "minimum-stability": "dev", + "prefer-stable": true, "scripts": { "analyze": "psalm", "check-style": "phpcs -p --standard=PSR12 config/ resources/ src/ tests/ '--ignore=*__snapshots_*'", diff --git a/tests/MethodTest.php b/tests/MethodTest.php index 254a3ad..811ef57 100644 --- a/tests/MethodTest.php +++ b/tests/MethodTest.php @@ -4,9 +4,10 @@ namespace Barryvdh\LaravelIdeHelper\Tests; use Barryvdh\LaravelIdeHelper\Method; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Foundation\Application; use PHPUnit\Framework\TestCase; -class ExampleTest extends TestCase +class MethodTest extends TestCase { /** * Test that we can actually instantiate the class @@ -31,14 +32,16 @@ class ExampleTest extends TestCase $method = new Method($reflectionMethod, 'Example', $reflectionClass); - $output = '/** + $output = <<<'DOC' +/** * * * @param string $last * @param string $first * @param string $middle * @static - */'; + */ +DOC; $this->assertSame($output, $method->getDocComment('')); $this->assertSame('setName', $method->getName()); $this->assertSame('\\' . ExampleClass::class, $method->getDeclaringClass()); @@ -54,25 +57,32 @@ class ExampleTest extends TestCase */ public function testEloquentBuilderOutput() { + if ((int) Application::VERSION < 8) { + $this->markTestSkipped('This test requires Laravel 8.0 or higher'); + } + $reflectionClass = new \ReflectionClass(Builder::class); $reflectionMethod = $reflectionClass->getMethod('with'); $method = new Method($reflectionMethod, 'Builder', $reflectionClass); - $output = '/** + $output = <<<'DOC' +/** * Set the relationships that should be eager loaded. * - * @param mixed $relations + * @param string|array $relations + * @param string|\Closure|null $callback * @return \Illuminate\Database\Eloquent\Builder|static * @static - */'; + */ +DOC; $this->assertSame($output, $method->getDocComment('')); $this->assertSame('with', $method->getName()); $this->assertSame('\\' . Builder::class, $method->getDeclaringClass()); - $this->assertSame('$relations', $method->getParams(true)); - $this->assertSame(['$relations'], $method->getParams(false)); - $this->assertSame('$relations', $method->getParamsWithDefault(true)); - $this->assertSame(['$relations'], $method->getParamsWithDefault(false)); + $this->assertSame('$relations, $callback', $method->getParams(true)); + $this->assertSame(['$relations', '$callback'], $method->getParams(false)); + $this->assertSame('$relations, $callback = null', $method->getParamsWithDefault(true)); + $this->assertSame(['$relations', '$callback = null'], $method->getParamsWithDefault(false)); $this->assertSame(true, $method->shouldReturn()); }