Skip to content

Commit

Permalink
Merge pull request #4 from answear/update-to-symfony-7
Browse files Browse the repository at this point in the history
Update to symfony 7
  • Loading branch information
Wiktor6 authored Oct 1, 2024
2 parents 0187de5 + 9d2377c commit c827b3c
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 95 deletions.
1 change: 0 additions & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
deps:
- "normal"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
steps:
- name: "Checkout"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
composer.lock
/.idea
/.env*
/.phpunit.cache
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
'strict_param' => false,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'phpdoc_align' => [],
'phpdoc_align' => ['align' => 'left'],
'phpdoc_summary' => false,
'void_return' => false,
'phpdoc_var_without_name' => false,
Expand Down
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
"type": "symfony-bundle",
"license": "MIT",
"require": {
"php": ">=8.1",
"php": "^8.2",
"ext-json": "*",
"guzzlehttp/guzzle": "^6.0 || ^7.0",
"psr/log": "^1.1",
"symfony/http-kernel": "^6.1",
"symfony/property-info": "^6.1",
"symfony/serializer": "^6.1",
"symfony/http-kernel": "^6.1|^7.0",
"symfony/property-info": "^6.1|^7.0",
"symfony/serializer": "^6.1|^7.0",
"symfony/serializer-pack": "^1.3",
"webmozart/assert": "^1.3"
"webmozart/assert": "^1.11"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.4",
"matthiasnoback/symfony-config-test": "^4.3",
"phpro/grumphp": "^1.5.0",
"phpstan/phpstan": "^1.4",
"friendsofphp/php-cs-fixer": "^3.64",
"phpro/grumphp": "^2.8",
"phpstan/phpstan": "^1.12",
"matthiasnoback/symfony-config-test": "^5.2",
"phpstan/phpstan-webmozart-assert": "^1.2",
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^10.5",
"roave/security-advisories": "dev-master",
"symfony/phpunit-bridge": "6.2.*"
"symfony/phpunit-bridge": "6.2.*|^7.0"
},
"autoload": {
"psr-4": {
Expand Down
16 changes: 3 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/8.4/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="./vendor/autoload.php"
backupGlobals="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
verbose="true"
>
cacheDirectory=".phpunit.cache"
beStrictAboutCoverageMetadata="true">
<php>
<ini name="error_reporting" value="-1"/>
</php>

<testsuites>
<testsuite name="Answear.com BoxNowBundle Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
</phpunit>
6 changes: 3 additions & 3 deletions src/Client/RequestTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\RequestInterface as PsrRequestInterface;

class RequestTransformer implements RequestTransformerInterface
readonly class RequestTransformer implements RequestTransformerInterface
{
public function __construct(
private readonly Serializer $serializer,
private readonly ConfigProvider $configProvider,
private Serializer $serializer,
private ConfigProvider $configProvider,
) {
}

Expand Down
30 changes: 15 additions & 15 deletions src/DTO/PickupPointDTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

namespace Answear\BoxNowBundle\DTO;

class PickupPointDTO
readonly class PickupPointDTO
{
public function __construct(
public readonly string $id,
public readonly string $type,
public readonly string $name,
public readonly string $address,
public readonly ?string $title = null,
public readonly ?string $image = null,
public readonly ?float $latitude = null,
public readonly ?float $longitude = null,
public readonly ?string $postalCode = null,
public readonly ?string $country = null,
public readonly ?string $note = null,
public readonly ?string $additionalAddress = null,
public readonly ?string $expectedDeliveryTime = null,
public readonly ?string $region = null,
public string $id,
public string $type,
public string $name,
public string $address,
public ?string $title = null,
public ?string $image = null,
public ?float $latitude = null,
public ?float $longitude = null,
public ?string $postalCode = null,
public ?string $country = null,
public ?string $note = null,
public ?string $additionalAddress = null,
public ?string $expectedDeliveryTime = null,
public ?string $region = null,
) {
}

Expand Down
8 changes: 4 additions & 4 deletions src/Service/AuthorizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
use Answear\BoxNowBundle\Response\AuthorizationResponse;
use Answear\BoxNowBundle\Serializer\Serializer;

class AuthorizationService
readonly class AuthorizationService
{
public function __construct(
private readonly ConfigProvider $configProvider,
private readonly Serializer $serializer,
private readonly Client $client,
private ConfigProvider $configProvider,
private Serializer $serializer,
private Client $client,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Service/PickupPointService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
use Answear\BoxNowBundle\Response\GetPickupPointsResponse;
use Answear\BoxNowBundle\Serializer\Serializer;

class PickupPointService
readonly class PickupPointService
{
public function __construct(
private readonly Client $client,
private readonly Serializer $serializer,
private Client $client,
private Serializer $serializer,
) {
}

Expand Down
31 changes: 12 additions & 19 deletions tests/Acceptance/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use Answear\BoxNowBundle\DependencyInjection\AnswearBoxNowExtension;
use Answear\BoxNowBundle\DependencyInjection\Configuration;
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
Expand All @@ -16,11 +18,8 @@ class ConfigurationTest extends TestCase
{
use ConfigurationTestCaseTrait;

/**
* @test
*
* @dataProvider provideValidConfig
*/
#[Test]
#[DataProvider('provideValidConfig')]
public function validTest(array $configs): void
{
$this->assertConfigurationIsValid($configs);
Expand All @@ -40,24 +39,18 @@ public function validTest(array $configs): void
}
}

/**
* @test
*
* @dataProvider provideInvalidConfig
*/
public function invalidConfig(array $config, string|null $expectedMessage = null): void
#[Test]
#[DataProvider('provideInvalidConfig')]
public function invalidConfig(array $config, ?string $expectedMessage = null): void
{
$this->assertConfigurationIsInvalid(
$config,
$expectedMessage
);
}

/**
* @test
*
* @dataProvider provideInvalidLogger
*/
#[Test]
#[DataProvider('provideInvalidLogger')]
public function invalidLogger(array $configs, \Throwable $expectedException): void
{
$this->expectException(get_class($expectedException));
Expand All @@ -71,7 +64,7 @@ public function invalidLogger(array $configs, \Throwable $expectedException): vo
$extension->load($configs, $builder);
}

public function provideInvalidConfig(): iterable
public static function provideInvalidConfig(): iterable
{
yield [
[
Expand Down Expand Up @@ -99,7 +92,7 @@ public function provideInvalidConfig(): iterable
];
}

public function provideInvalidLogger(): iterable
public static function provideInvalidLogger(): iterable
{
yield [
[
Expand All @@ -113,7 +106,7 @@ public function provideInvalidLogger(): iterable
];
}

public function provideValidConfig(): iterable
public static function provideValidConfig(): iterable
{
yield [
[
Expand Down
16 changes: 4 additions & 12 deletions tests/Integration/Service/AuthorizationServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
namespace Answear\BoxNowBundle\Tests\Integration\Service;

use Answear\BoxNowBundle\Exception\RequestException;
use Answear\BoxNowBundle\Response\AuthorizationResponse;
use Answear\BoxNowBundle\Service\AuthorizationService;
use Answear\BoxNowBundle\Tests\Util\FileTestUtil;
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\Attributes\Test;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;

class AuthorizationServiceTest extends ServiceTestCase
{
/**
* @test
*/
#[Test]
public function successfulAuthorization(): void
{
$this->setClient(withLogger: true);
Expand All @@ -30,16 +28,12 @@ public function successfulAuthorization(): void

$response = $service->authorize();

$this->assertInstanceOf(AuthorizationResponse::class, $response);

$this->assertSame('--access-token--', $response->getAccessToken());
$this->assertSame('Bearer', $response->getTokenType());
$this->assertSame(3600, $response->getExpiresIn());
}

/**
* @test
*/
#[Test]
public function wrongCredentialsAuthorization(): void
{
$this->expectException(RequestException::class);
Expand All @@ -57,9 +51,7 @@ public function wrongCredentialsAuthorization(): void
$service->authorize();
}

/**
* @test
*/
#[Test]
public function invalidBodyAuthorization(): void
{
$this->expectException(RequestException::class);
Expand Down
17 changes: 5 additions & 12 deletions tests/Integration/Service/PickupPointServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
use Answear\BoxNowBundle\Service\PickupPointService;
use Answear\BoxNowBundle\Tests\Util\FileTestUtil;
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\Attributes\Test;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
use Webmozart\Assert\InvalidArgumentException;

class PickupPointServiceTest extends ServiceTestCase
{
/**
* @test
*/
#[Test]
public function successfulListAllPickupPoints(): void
{
$this->setClient(withLogger: true);
Expand Down Expand Up @@ -60,9 +59,7 @@ public function successfulListAllPickupPoints(): void
);
}

/**
* @test
*/
#[Test]
public function invalidPickupPointIdFieldValue(): void
{
$this->expectException(InvalidArgumentException::class);
Expand All @@ -81,9 +78,7 @@ public function invalidPickupPointIdFieldValue(): void
$service->getAll('token');
}

/**
* @test
*/
#[Test]
public function invalidPickupPointNameFieldValue(): void
{
$this->expectException(InvalidArgumentException::class);
Expand All @@ -102,9 +97,7 @@ public function invalidPickupPointNameFieldValue(): void
$service->getAll('token');
}

/**
* @test
*/
#[Test]
public function invalidPickupPointAddressFieldValue(): void
{
$this->expectException(InvalidArgumentException::class);
Expand Down

0 comments on commit c827b3c

Please sign in to comment.