From c2d0a69a11f13c0862915a60be5bd06431486d7b Mon Sep 17 00:00:00 2001 From: prisis Date: Tue, 4 Feb 2020 21:23:00 +0100 Subject: [PATCH] feat : added space to http header line feat : upgraded php to 7.4.2 --- .github/workflows/code-coverage.yml | 2 +- .github/workflows/coding-standard.yml | 9 ++++++--- .../workflows/continuous-integration-linux.yml | 2 +- .../continuous-integration-windows.yml | 2 +- .github/workflows/php-audit.yml | 2 +- .github/workflows/static-analyze.yml | 2 +- src/Viserio/Component/Http/AbstractMessage.php | 2 +- .../Http/Tests/AbstractMessageTest.php | 17 +++++++++++++---- .../Component/Http/Tests/RequestTest.php | 2 +- .../Component/Http/Tests/ResponseTest.php | 8 ++++---- 10 files changed, 30 insertions(+), 18 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index f892676e8..9a356e5c2 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -22,7 +22,7 @@ jobs: - name: "Setup PHP" uses: shivammathur/setup-php@1.8.2 with: - php-version: "7.4" + php-version: "7.4.2" extensions: mbstring, xml, ctype, iconv, zip, dom, fileinfo, intl, sodium, curl, pdo, pdo_sqlite, inotify, pcntl, posix, xdebug ini-values: pcov.directory=api, date.timezone=Europe/Berlin, opcache.enable_cli=1, serialize_precision=14 coverage: none diff --git a/.github/workflows/coding-standard.yml b/.github/workflows/coding-standard.yml index 8072a8eea..4006ffed1 100644 --- a/.github/workflows/coding-standard.yml +++ b/.github/workflows/coding-standard.yml @@ -22,14 +22,17 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@1.8.2 with: - php-version: 7.4 + php-version: "7.4.2" extensions: mbstring, xml, ctype, iconv, zip, dom, fileinfo tools: composer, composer-prefetcher, cs2pr - name: "Install Narrowspark coding standard" - run: composer global require narrowspark/coding-standard:3.4.0 --no-interaction --no-progress --profile --no-suggest --optimize-autoloader + run: | + composer global require narrowspark/coding-standard:3.4.0 --no-interaction --no-progress --profile --no-suggest --optimize-autoloader + # can be removed if bug with ClassAttributesSeparationFixer is fixed in newer version + composer global require friendsofphp/php-cs-fixer:2.16.x-dev - name: "lint php code" run: | cd $GITHUB_WORKSPACE - /home/runner/.composer/vendor/bin/php-cs-fixer fix --config=$GITHUB_WORKSPACE/.php_cs -v --dry-run --stop-on-violation --format=checkstyle | cs2pr + /home/runner/.composer/vendor/bin/php-cs-fixer fix --config=$GITHUB_WORKSPACE/.php_cs -v --dry-run --format=checkstyle | cs2pr diff --git a/.github/workflows/continuous-integration-linux.yml b/.github/workflows/continuous-integration-linux.yml index 1bc2a4795..532d1561d 100644 --- a/.github/workflows/continuous-integration-linux.yml +++ b/.github/workflows/continuous-integration-linux.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: operating-system: [ubuntu-latest] - php-versions: ["7.4"] + php-versions: ["7.4.2"] dependencies: ["highest", "lowest"] name: "PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} OS and with ${{ matrix.dependencies }} dependencies" diff --git a/.github/workflows/continuous-integration-windows.yml b/.github/workflows/continuous-integration-windows.yml index 392da542f..3eb4b0028 100644 --- a/.github/workflows/continuous-integration-windows.yml +++ b/.github/workflows/continuous-integration-windows.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: operating-system: [windows-latest] - php-versions: ["7.4"] + php-versions: ["7.4.2"] dependencies: ["highest", "lowest"] name: "PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} OS and with ${{ matrix.dependencies }} dependencies" diff --git a/.github/workflows/php-audit.yml b/.github/workflows/php-audit.yml index 30bb7e9f5..cc6d33ed1 100644 --- a/.github/workflows/php-audit.yml +++ b/.github/workflows/php-audit.yml @@ -17,7 +17,7 @@ jobs: max-parallel: 2 matrix: operating-system: [ubuntu-latest] - php-versions: ["7.4"] + php-versions: ["7.4.2"] dependencies: ["highest", "lowest"] name: "Audit on PHP ${{ matrix.php-versions }} and ${{ matrix.operating-system }} OS" diff --git a/.github/workflows/static-analyze.yml b/.github/workflows/static-analyze.yml index 0790f964f..449c81d5d 100644 --- a/.github/workflows/static-analyze.yml +++ b/.github/workflows/static-analyze.yml @@ -67,7 +67,7 @@ jobs: - name: "Setup PHP" uses: shivammathur/setup-php@1.8.2 with: - php-version: 7.4 + php-version: "7.4.2" extensions: mbstring, xml, ctype, iconv, zip, dom, fileinfo, intl, inotify, pcntl, posix pecl: true tools: composer, composer-prefetcher, cs2pr diff --git a/src/Viserio/Component/Http/AbstractMessage.php b/src/Viserio/Component/Http/AbstractMessage.php index 2128b4367..02d8062dc 100644 --- a/src/Viserio/Component/Http/AbstractMessage.php +++ b/src/Viserio/Component/Http/AbstractMessage.php @@ -165,7 +165,7 @@ public function getHeaderLine($name): string return ''; } - return \implode(',', $value); + return \implode(', ', $value); } /** diff --git a/src/Viserio/Component/Http/Tests/AbstractMessageTest.php b/src/Viserio/Component/Http/Tests/AbstractMessageTest.php index 6ae067415..2682fabbe 100644 --- a/src/Viserio/Component/Http/Tests/AbstractMessageTest.php +++ b/src/Viserio/Component/Http/Tests/AbstractMessageTest.php @@ -275,9 +275,9 @@ public static function provideValidHeaderCases(): iterable // Description => [header name, header value, getHeader(), getHeaderLine()], 'Basic: value' => ['Basic', 'value', ['value'], 'value'], 'array value' => ['Basic', ['value'], ['value'], 'value'], - 'two value' => ['Basic', ['value1', 'value2'], ['value1', 'value2'], 'value1,value2'], + 'two value' => ['Basic', ['value1', 'value2'], ['value1', 'value2'], 'value1, value2'], 'empty header value' => ['Bar', '', [''], ''], - 'array value with key' => ['foo', ['foo' => 'text/plain', 'bar' => 'application/json'], ['text/plain', 'application/json'], 'text/plain,application/json'], + 'array value with key' => ['foo', ['foo' => 'text/plain', 'bar' => 'application/json'], ['text/plain', 'application/json'], 'text/plain, application/json'], 'Header with int' => ['HTTP__1', 'test', ['test'], 'test'], 'Int header' => [1, 'test', ['test'], 'test'], ['key', 'allowed key', ['allowed key'], 'allowed key'], @@ -326,9 +326,18 @@ public function testContainsNotAllowedCharsOnHeaderField($header): void $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage(\sprintf('[%s] is not a valid HTTP header field name.', $header)); - $request = $this->classToTest; + $message = $this->classToTest; + + $message->withHeader($header, 'value'); + } + + public function testWithAddedHeaderArrayValueAndKeys(): void + { + $message = $this->classToTest->withAddedHeader('list', ['foo' => 'one']); + $message = $message->withAddedHeader('list', ['foo' => 'two', 'bar' => 'three']); - $request->withHeader($header, 'value'); + $headerLine = $message->getHeaderLine('list'); + self::assertSame('one, two, three', $headerLine); } public static function provideContainsNotAllowedCharsOnHeaderFieldCases(): iterable diff --git a/src/Viserio/Component/Http/Tests/RequestTest.php b/src/Viserio/Component/Http/Tests/RequestTest.php index 9bf626162..4679fa982 100644 --- a/src/Viserio/Component/Http/Tests/RequestTest.php +++ b/src/Viserio/Component/Http/Tests/RequestTest.php @@ -557,7 +557,7 @@ public function testCanGetHeaderAsCsv(): void 'Foo' => ['a', 'b', 'c'], ]); - self::assertEquals('a,b,c', $request->getHeaderLine('Foo')); + self::assertEquals('a, b, c', $request->getHeaderLine('Foo')); self::assertEquals('', $request->getHeaderLine('Bar')); } diff --git a/src/Viserio/Component/Http/Tests/ResponseTest.php b/src/Viserio/Component/Http/Tests/ResponseTest.php index c9f569ecb..724e8b0a9 100644 --- a/src/Viserio/Component/Http/Tests/ResponseTest.php +++ b/src/Viserio/Component/Http/Tests/ResponseTest.php @@ -209,7 +209,7 @@ public function testCanConstructWithHeadersAsArray(): void ]); self::assertSame(['Foo' => ['baz', 'bar']], $response->getHeaders()); - self::assertSame('baz,bar', $response->getHeaderLine('Foo')); + self::assertSame('baz, bar', $response->getHeaderLine('Foo')); self::assertSame(['baz', 'bar'], $response->getHeader('Foo')); } @@ -315,7 +315,7 @@ public function testWithHeaderAsArray(): void self::assertSame(['Foo' => ['Bar']], $response->getHeaders()); self::assertSame(['Foo' => ['Bar'], 'baZ' => ['Bam', 'Bar']], $response2->getHeaders()); - self::assertSame('Bam,Bar', $response2->getHeaderLine('baz')); + self::assertSame('Bam, Bar', $response2->getHeaderLine('baz')); self::assertSame(['Bam', 'Bar'], $response2->getHeader('baz')); } @@ -337,7 +337,7 @@ public function testWithAddedHeader(): void self::assertSame(['Foo' => ['Bar']], $response->getHeaders()); self::assertSame(['Foo' => ['Bar', 'Baz']], $response2->getHeaders()); - self::assertSame('Bar,Baz', $response2->getHeaderLine('foo')); + self::assertSame('Bar, Baz', $response2->getHeaderLine('foo')); self::assertSame(['Bar', 'Baz'], $response2->getHeader('foo')); } @@ -348,7 +348,7 @@ public function testWithAddedHeaderAsArray(): void self::assertSame(['Foo' => ['Bar']], $response->getHeaders()); self::assertSame(['Foo' => ['Bar', 'Baz', 'Bam']], $response2->getHeaders()); - self::assertSame('Bar,Baz,Bam', $response2->getHeaderLine('foo')); + self::assertSame('Bar, Baz, Bam', $response2->getHeaderLine('foo')); self::assertSame(['Bar', 'Baz', 'Bam'], $response2->getHeader('foo')); }