Skip to content

Commit

Permalink
Merge pull request #13 from craftzing/chore/upgrade-to-newer-laravel-…
Browse files Browse the repository at this point in the history
…versions

Chore/upgrade to newer laravel versions
  • Loading branch information
ppelgrims authored Jun 6, 2024
2 parents 2797798 + 59c340e commit ae48634
Show file tree
Hide file tree
Showing 60 changed files with 425 additions and 505 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/code-style.yml

This file was deleted.

24 changes: 14 additions & 10 deletions .github/workflows/quality-assurance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.0, 7.4]
laravel: [^8.0, ^7.0]
php: [8.2, 8.3]
laravel: [^10.0, ^11.0]
include:
- laravel: ^8.0
testbench: ^6.0
- laravel: ^7.0
testbench: ^5.0
- laravel: ^11.0
testbench: ^9.0
- laravel: ^10.0
testbench: ^8.0
name: P${{ matrix.php }} - L${{ matrix.laravel }}
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -34,16 +34,20 @@ jobs:
composer update --prefer-dist --no-interaction
- name: Run tests
run: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover
run: vendor/bin/phpunit --coverage-clover=coverage.clover

- name: Publish code coverage
uses: paambaati/codeclimate-action@v2.7.5
uses: paambaati/codeclimate-action@v5.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_TEST_REPORTER_ID }}
with:
coverageCommand: vendor/bin/phpunit --coverage-clover=coverage.clover
coverageLocations: ${{github.workspace}}/*.clover:clover
debug: true

- name: Run PHPStan analysis
run: vendor/bin/phpstan analyse --memory-limit=-1
if: ${{ matrix.php == '7.4' }}
if: ${{ matrix.php == '8.2' }}

- name: Run PHP Coding Standards Fixer
run: vendor/bin/php-cs-fixer fix src --dry-run
4 changes: 4 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
->ignoreVCS(true);

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers())
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
Expand All @@ -30,5 +32,7 @@
'keep_multiple_spaces_after_comma' => true,
],
'void_return' => true,
PhpCsFixerCustomFixers\Fixer\MultilinePromotedPropertiesFixer::name() => true,
PhpCsFixerCustomFixers\Fixer\ConstructorEmptyBracesFixer::name() => true,
])
->setFinder($finder);
17 changes: 10 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@
}
],
"require": {
"php": "^7.4|^8.0",
"php": "^8.2|^8.3",
"ext-json": "*",
"illuminate/support": "^7.0|^8.0",
"mollie/laravel-mollie": "^2.0",
"spatie/laravel-webhook-client": "^2.7.4"
"illuminate/support": "^10.0|^11.0",
"mollie/laravel-mollie": "^3.0",
"spatie/laravel-webhook-client": "^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.54",
"kubawerlos/php-cs-fixer-custom-fixers": "^3.21",
"laravel/legacy-factories": "^1.1",
"orchestra/testbench": "^5.0|^6.5",
"phpstan/phpstan": "^0.12.74",
"phpunit/phpunit": "^9.5"
"orchestra/testbench": "^8.0",
"phpstan/phpstan": "^1.8",
"phpunit/phpunit": "^10.0",
"rector/rector": "^1.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ parameters:
level: 6
paths:
- src
excludes_analyse:
excludePaths:
- ./**/Testing/*
- ./**/*Test.php
- ./**/*TestCase.php
Expand Down
51 changes: 27 additions & 24 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>./src/</directory>
</include>
<exclude>
<directory suffix="Test.php">src/</directory>
<directory suffix="TestCase.php">src/</directory>
<directory>src/Testing/</directory>
</exclude>
</coverage>
<testsuites>
<testsuite name="Laravel Mollie Webhooks">
<directory suffix="Test.php">src/</directory>
</testsuite>
</testsuites>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
<server name="QUEUE_CONNECTION" value="sync"/>
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
colors="true"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
<testsuites>
<testsuite name="Laravel Mollie Webhooks">
<directory suffix="Test.php">src/</directory>
</testsuite>
</testsuites>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
<server name="QUEUE_CONNECTION" value="sync"/>
</php>
<source>
<include>
<directory>./src/</directory>
</include>
<exclude>
<directory suffix="Test.php">src/</directory>
<directory suffix="TestCase.php">src/</directory>
<directory>src/Testing/</directory>
</exclude>
</source>
</phpunit>
20 changes: 20 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
$rectorConfig->paths([
__DIR__ . '/src',
]);

$rectorConfig->sets([
\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_100,
]);

$rectorConfig->skip([
\Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector::class,
]);
};
4 changes: 2 additions & 2 deletions src/Commands/ProcessMollieWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Craftzing\Laravel\MollieWebhooks\Orders\OrderId;
use Craftzing\Laravel\MollieWebhooks\Payments\PaymentId;
use Illuminate\Contracts\Events\Dispatcher;
use Spatie\WebhookClient\ProcessWebhookJob;
use Spatie\WebhookClient\Jobs\ProcessWebhookJob;

final class ProcessMollieWebhook extends ProcessWebhookJob
{
Expand All @@ -36,7 +36,7 @@ public function handle(Dispatcher $events): void
$this->handleOrderEvent(OrderId::fromString($id), $events);

return;
} catch (InvalidResourceId $e) {
} catch (InvalidResourceId) {
// The ID is not an OrderId, moving on to try and use it as a different Mollie resource ID.
}

Expand Down
32 changes: 14 additions & 18 deletions src/Commands/ProcessMollieWebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@
use Craftzing\Laravel\MollieWebhooks\Events\MolliePaymentWasUpdated;
use Craftzing\Laravel\MollieWebhooks\Events\MollieResourceStatusWasUpdated;
use Craftzing\Laravel\MollieWebhooks\Exceptions\UnexpectedWebhookPayload;
use Craftzing\Laravel\MollieWebhooks\Testing\HandleAssertions;
use Craftzing\Laravel\MollieWebhooks\Testing\IntegrationTestCase;
use Craftzing\Laravel\MollieWebhooks\Testing\TruthTest;
use Exception;
use Generator;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Event;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Spatie\WebhookClient\Models\WebhookCall;

use function compact;

final class ProcessMollieWebhookTest extends IntegrationTestCase
{
/**
* @test
*/
#[Test]
public function itShouldBeQueued(): void
{
$webhookCall = new WebhookCall([]);

$this->assertInstanceOf(ShouldQueue::class, new ProcessMollieWebhook($webhookCall));
}

public function invalidWebhookPayloads(): Generator
public static function invalidWebhookPayloads(): Generator
{
yield 'Missing a Mollie object identifier' => [
[],
Expand All @@ -43,10 +43,8 @@ public function invalidWebhookPayloads(): Generator
];
}

/**
* @test
* @dataProvider invalidWebhookPayloads
*/
#[Test]
#[DataProvider('invalidWebhookPayloads')]
public function itFailsWhenTheWebhookPayloadIsInvalid(array $payload, Exception $exception): void
{
$this->expectExceptionObject($exception);
Expand All @@ -56,26 +54,24 @@ public function itFailsWhenTheWebhookPayloadIsInvalid(array $payload, Exception
$this->handle(new ProcessMollieWebhook($webhookCall));
}

public function webhookPayloads(): Generator
public static function webhookPayloads(): Generator
{
yield 'order resource id' => [
fn () => $this->generateOrderId(),
fn (self $test) => $test->generateOrderId(),
MollieOrderWasUpdated::class,
];

yield 'payment resource id' => [
fn () => $this->generatePaymentId(),
fn (self $test) => $test->generatePaymentId(),
MolliePaymentWasUpdated::class,
];
}

/**
* @test
* @dataProvider webhookPayloads
*/
#[Test]
#[DataProvider('webhookPayloads')]
public function itCanHandleIncomingWebhooks(callable $generatesResourceId, string $event): void
{
$resourceId = $generatesResourceId();
$resourceId = $generatesResourceId($this);
$webhookCall = new WebhookCall([
'payload' => [
'id' => $resourceId->value(),
Expand All @@ -86,7 +82,7 @@ public function itCanHandleIncomingWebhooks(callable $generatesResourceId, strin

Event::assertDispatched(
$event,
new TruthTest(function (MollieResourceStatusWasUpdated $event) use ($resourceId, $webhookCall): void {
new HandleAssertions(function (MollieResourceStatusWasUpdated $event) use ($resourceId, $webhookCall): void {
$this->assertSame($event->resourceId()->value(), $resourceId->value());
$this->assertTrue($event->webhookCall()->is($webhookCall));
}),
Expand Down
20 changes: 0 additions & 20 deletions src/Events/ExposesOrderId.php

This file was deleted.

20 changes: 0 additions & 20 deletions src/Events/ExposesPaymentId.php

This file was deleted.

27 changes: 0 additions & 27 deletions src/Events/ExposesRefundId.php

This file was deleted.

6 changes: 5 additions & 1 deletion src/Events/MollieOrderStatusChangedToAuthorized.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

namespace Craftzing\Laravel\MollieWebhooks\Events;

use Craftzing\Laravel\MollieWebhooks\Orders\OrderId;

final class MollieOrderStatusChangedToAuthorized
{
use ExposesOrderId;
public function __construct(
public readonly OrderId $orderId,
) {}
}
Loading

0 comments on commit ae48634

Please sign in to comment.