Skip to content

Commit

Permalink
Symfony 6 support (#8)
Browse files Browse the repository at this point in the history
* Symfony 6 support

* Symfony 6 support

* Symfony 6 support

* Symfony 6 support

* update tests

* Symfony 6 support

* update tests to support php versions >=7.1

* GitHub action workflow (#1)
  • Loading branch information
pidhorodetskyi authored Mar 18, 2024
1 parent e08c690 commit f8ababf
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 53 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/symfony.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Symfony

on:
push:
branches: ['master']
tags: ['*']
pull_request:
branches: ['*']

permissions:
contents: read

jobs:
symfony-tests:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ 'ubuntu-latest' ]
php-versions: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
phpunit-versions: [ 'latest' ]
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl
ini-values: post_max_size=256M, max_execution_time=180
coverage: xdebug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout repository
uses: actions/checkout@v3
- name: Composer update on php ${{ matrix.php }} and symfony
run: composer update --prefer-dist --no-progress
- name: Execute tests (Unit and Feature tests) via PHPUnit
run: vendor/bin/phpunit

Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public function __construct(NameConverterInterface $nameConverter)
/**
* {@inheritdoc}
*/
public function normalize($propertyName)
public function normalize($propertyName): string
{
return $propertyName;
}

/**
* {@inheritdoc}
*/
public function denormalize($propertyName)
public function denormalize($propertyName): string
{
return $this->nameConverter->denormalize($propertyName);
}
Expand Down
4 changes: 2 additions & 2 deletions Service/Serializer/Encoder/JsonEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class JsonEncoder extends \Symfony\Component\Serializer\Encoder\JsonEncoder
{
const FORMAT_JSON_PATCH = 'json-patch';

public function supportsEncoding($format)
public function supportsEncoding($format): bool
{
return static::FORMAT_JSON_PATCH === $format || parent::supportsEncoding($format);
}

public function supportsDecoding($format)
public function supportsDecoding($format): bool
{
return static::FORMAT_JSON_PATCH === $format || parent::supportsDecoding($format);
}
Expand Down
4 changes: 2 additions & 2 deletions Service/Serializer/Encoder/UrlEncode.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class UrlEncode implements EncoderInterface
*
* {@inheritdoc}
*/
public function encode($data, $format, array $context = [])
public function encode($data, $format, array $context = []): string
{
$data = $this->convertCamelCaseToSnakeCase($data);
$encoded = http_build_query($data);
Expand All @@ -22,7 +22,7 @@ public function encode($data, $format, array $context = [])
/**
* {@inheritdoc}
*/
public function supportsEncoding($format)
public function supportsEncoding($format): bool
{
return UrlEncoder::FORMAT === $format;
}
Expand Down
4 changes: 2 additions & 2 deletions Service/Serializer/Encoder/UrlEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ public function __construct(UrlEncode $encodingImpl = null)
/**
* {@inheritdoc}
*/
public function encode($data, $format, array $context = array())
public function encode($data, $format, array $context = array()): string
{
return $this->encodingImpl->encode($data, self::FORMAT, $context);
}

/**
* {@inheritdoc}
*/
public function supportsEncoding($format)
public function supportsEncoding($format): bool
{
return self::FORMAT === $format;
}
Expand Down
4 changes: 2 additions & 2 deletions Service/Serializer/Encoder/VoidEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class VoidEncoder implements EncoderInterface
/**
* {@inheritdoc}
*/
public function encode($data, $format, array $context = array())
public function encode($data, $format, array $context = array()): string
{
return '';
}

/**
* {@inheritdoc}
*/
public function supportsEncoding($format)
public function supportsEncoding($format): bool
{
return self::FORMAT === $format;
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/Service/Endpoint/EndpointsConfigurationLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*/
class EndpointsConfigurationLoaderTest extends TestCase
{
public function testConstructor()
public function testConstructor(): void
{
$endpointsConfigurationLoader = new EndpointsConfigurationLoader('configFilePathString');
self::assertInstanceOf(EndpointsConfigurationLoader::class, $endpointsConfigurationLoader);
}
}
}
8 changes: 4 additions & 4 deletions Tests/Service/Serializer/Encoder/UrlEncodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class UrlEncodeTest extends TestCase
*/
private $encode;

protected function setUp()
protected function setUp(): void
{
$this->encode = new UrlEncode();
}

public function testSupportsEncoding()
public function testSupportsEncoding(): void
{
$this->assertTrue($this->encode->supportsEncoding(UrlEncoder::FORMAT));
$this->assertFalse($this->encode->supportsEncoding('foobar'));
Expand All @@ -30,7 +30,7 @@ public function testSupportsEncoding()
* @param array $toEncode
* @param string $expected
*/
public function testEncode(array $toEncode, string $expected)
public function testEncode(array $toEncode, string $expected): void
{
$this->assertEquals(
$expected,
Expand All @@ -41,7 +41,7 @@ public function testEncode(array $toEncode, string $expected)
/**
* @return array
*/
public function encodeProvider()
public static function encodeProvider(): array
{
return [
'empty' => [
Expand Down
10 changes: 5 additions & 5 deletions Tests/Service/Serializer/Encoder/UrlEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class UrlEncoderTest extends TestCase
/**
* @return void
*/
protected function setUp()
protected function setUp(): void
{
$this->encoder = new UrlEncoder();
$this->serializer = new Serializer(array(new CustomNormalizer()), array('url' => new UrlEncoder()));
}

public function testEncodeSimple()
public function testEncodeSimple(): void
{
$obj = new \stdClass();
$obj->foo = 'foo';
Expand All @@ -38,7 +38,7 @@ public function testEncodeSimple()
self::assertEquals($expected, $this->encoder->encode($obj, 'url'));
}

public function testEncodeCamelToSnakeCaseNames()
public function testEncodeCamelToSnakeCaseNames(): void
{
$obj = $this->getObject();

Expand All @@ -50,15 +50,15 @@ public function testEncodeCamelToSnakeCaseNames()
/**
* @return string
*/
protected function getUrlSource()
protected function getUrlSource(): string
{
return 'foo=foo&foo_bar=fooBar';
}

/**
* @return \stdClass
*/
protected function getObject()
protected function getObject(): \stdClass
{
$obj = new \stdClass();
$obj->foo = 'foo';
Expand Down
23 changes: 11 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@
],
"require": {
"php": ">=7.1.3",
"symfony/serializer" : "~4.2|~5.0",
"symfony/monolog-bridge": "~4.0|~5.0",
"symfony/dependency-injection": "~4.0|~5.0",
"symfony/config": "~4.0|~5.0",
"symfony/http-kernel": "~4.0|~5.0",
"symfony/property-info": "~4.0|~5.0",
"symfony/property-access": "~4.0|~5.0",
"symfony/yaml": "~4.0|~5.0",
"symfony/serializer": "~4.2|~5.0|~6.0",
"symfony/monolog-bridge": "~4.0|~5.0|~6.0",
"symfony/dependency-injection": "~4.0|~5.0|~6.0",
"symfony/config": "~4.0|~5.0|~6.0",
"symfony/http-kernel": "~4.0|~5.0|~6.0",
"symfony/property-info": "~4.0|~5.0|~6.0",
"symfony/property-access": "~4.0|~5.0|~6.0",
"symfony/yaml": "~4.0|~5.0|~6.0",
"monolog/monolog": "~1.22",
"fig/http-message-util": "^1.1.2",
"auto1-oss/service-api-request": "^1.0"
},
"require-dev": {
"symfony/console": "~3.0|~4.0|~5.0",
"phpunit/phpunit": "^5.7",
"symfony/phpunit-bridge": "^3.3.8",
"phpspec/prophecy": "^1.7.2"
"symfony/console": "~3.0|~4.0|~5.0|~6.0",
"phpunit/phpunit": "^7.5|^8.0|^9.0",
"phpspec/prophecy-phpunit": "^1.1"
},
"autoload": {
"psr-4": { "Auto1\\ServiceAPIComponentsBundle\\": "" }
Expand Down
40 changes: 20 additions & 20 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@
colors="true"
bootstrap="vendor/autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_CLASS" value="AppKernel" />
</php>
<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_CLASS" value="AppKernel" />
</php>

<testsuites>
<testsuite name="Auto1 ServiceApiComponentsBundle Test Suite">
<directory>./Tests</directory>
</testsuite>
</testsuites>
<testsuites>
<testsuite name="Auto1 ServiceApiComponentsBundle Test Suite">
<directory>./Tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>.</directory>
<exclude>
<directory>./_code_coverage</directory>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
<filter>
<whitelist>
<directory>.</directory>
<exclude>
<directory>./_code_coverage</directory>
<directory>./Resources</directory>
<directory>./Tests</directory>
<directory>./vendor</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

0 comments on commit f8ababf

Please sign in to comment.