From 33e0ec17d3bc45bef0661d44687e22f7150e0d43 Mon Sep 17 00:00:00 2001 From: Kjell Knapen Date: Wed, 2 Mar 2022 11:08:40 +0100 Subject: [PATCH 01/14] Uncomment build and test if it can be called --- src/RenderedEmailTemplateMail.php | 8 ++++---- src/TemplatesChannelTest.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/RenderedEmailTemplateMail.php b/src/RenderedEmailTemplateMail.php index d0f926c..6a2deae 100644 --- a/src/RenderedEmailTemplateMail.php +++ b/src/RenderedEmailTemplateMail.php @@ -16,8 +16,8 @@ public static function fromRenderedContent(string $subject, string $html, string ->text($text); } -// public function build(): self -// { -// return $this; -// } + public function build(): self + { + return $this; + } } diff --git a/src/TemplatesChannelTest.php b/src/TemplatesChannelTest.php index 9708aed..5722da6 100644 --- a/src/TemplatesChannelTest.php +++ b/src/TemplatesChannelTest.php @@ -271,4 +271,32 @@ public function itCanSendEmailTemplateMessagesViaTheMailChannel( return true; }); } + + /** + * @test + * @dataProvider templateMessages + * @param callable(TemplateMessage, MailRoutingNotifiable, Sender): TemplateMessage $expectMessage + */ + public function itCanBuildTheTemplateMessagesViaTheMailChannel( + TemplateNotification $notification, + callable $expectMessage + ): void { + $this->enableSendingViaMailChannel(); + $notifiable = new MailRoutingNotifiable(); + $expectedMessage = $expectMessage( + $notification->toPostmarkTemplate(), + $notifiable, + $this->config->defaultSender(), + ); + + $this->channel->send($notifiable, $notification); + + TemplatesApi::assertValidated($expectedMessage); + TemplatesApi::assertNothingSent(); + Mail::assertSent(RenderedEmailTemplateMail::class, function (RenderedEmailTemplateMail $mail): bool { + $this->assertInstanceOf(RenderedEmailTemplateMail::class, $mail->build()); + + return true; + }); + } } From d0157a999b07b005c328166995a998892b48f9e8 Mon Sep 17 00:00:00 2001 From: Kjell Knapen Date: Wed, 2 Mar 2022 11:32:46 +0100 Subject: [PATCH 02/14] Add testcase for RenderdEmailTemplate --- src/RenderedEmailTemplateMailTest.php | 37 +++++++++++++++++++++++++++ src/TemplatesChannelTest.php | 28 -------------------- 2 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 src/RenderedEmailTemplateMailTest.php diff --git a/src/RenderedEmailTemplateMailTest.php b/src/RenderedEmailTemplateMailTest.php new file mode 100644 index 0000000..aa5d350 --- /dev/null +++ b/src/RenderedEmailTemplateMailTest.php @@ -0,0 +1,37 @@ +assertSame($subject, $mail->subject); + $this->assertSame($textBody, $mail->textView); + } + + /** @test */ + public function itCanBuildRenderdEmailTemplate(): void + { + $subject = 'Some Content Here'; + $htmlBody = 'Some HTML Content Here'; + $textBody = 'Some Text Content Here'; + $mail = RenderedEmailTemplateMail::fromRenderedContent($subject, $htmlBody, $textBody); + + $build = $mail->build(); + + $this->assertSame($subject, $build->subject); + $this->assertSame($textBody, $build->textView); + } +} diff --git a/src/TemplatesChannelTest.php b/src/TemplatesChannelTest.php index 5722da6..9708aed 100644 --- a/src/TemplatesChannelTest.php +++ b/src/TemplatesChannelTest.php @@ -271,32 +271,4 @@ public function itCanSendEmailTemplateMessagesViaTheMailChannel( return true; }); } - - /** - * @test - * @dataProvider templateMessages - * @param callable(TemplateMessage, MailRoutingNotifiable, Sender): TemplateMessage $expectMessage - */ - public function itCanBuildTheTemplateMessagesViaTheMailChannel( - TemplateNotification $notification, - callable $expectMessage - ): void { - $this->enableSendingViaMailChannel(); - $notifiable = new MailRoutingNotifiable(); - $expectedMessage = $expectMessage( - $notification->toPostmarkTemplate(), - $notifiable, - $this->config->defaultSender(), - ); - - $this->channel->send($notifiable, $notification); - - TemplatesApi::assertValidated($expectedMessage); - TemplatesApi::assertNothingSent(); - Mail::assertSent(RenderedEmailTemplateMail::class, function (RenderedEmailTemplateMail $mail): bool { - $this->assertInstanceOf(RenderedEmailTemplateMail::class, $mail->build()); - - return true; - }); - } } From 7678e776df3b910f516ac8b39e81a0165617163a Mon Sep 17 00:00:00 2001 From: Kjell Knapen Date: Wed, 2 Mar 2022 12:42:34 +0100 Subject: [PATCH 03/14] Add htmlBody function to render template and add it to testcase --- src/RenderedEmailTemplateMail.php | 5 +++++ src/RenderedEmailTemplateMailTest.php | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/RenderedEmailTemplateMail.php b/src/RenderedEmailTemplateMail.php index 6a2deae..5a8f64b 100644 --- a/src/RenderedEmailTemplateMail.php +++ b/src/RenderedEmailTemplateMail.php @@ -20,4 +20,9 @@ public function build(): self { return $this; } + + public function htmlBody(): string + { + return $this->html; + } } diff --git a/src/RenderedEmailTemplateMailTest.php b/src/RenderedEmailTemplateMailTest.php index aa5d350..e32a1b4 100644 --- a/src/RenderedEmailTemplateMailTest.php +++ b/src/RenderedEmailTemplateMailTest.php @@ -9,7 +9,7 @@ final class RenderedEmailTemplateMailTest extends TestCase { /** @test */ - public function itCanCreateRenderdEmailTemplate(): void + public function itCanBeConstructedFromRenderedContent(): void { $subject = 'Some Content Here'; $htmlBody = 'Some HTML Content Here'; @@ -18,6 +18,7 @@ public function itCanCreateRenderdEmailTemplate(): void $mail = RenderedEmailTemplateMail::fromRenderedContent($subject, $htmlBody, $textBody); $this->assertSame($subject, $mail->subject); + $this->assertSame($htmlBody, $mail->htmlBody()); $this->assertSame($textBody, $mail->textView); } @@ -29,9 +30,12 @@ public function itCanBuildRenderdEmailTemplate(): void $textBody = 'Some Text Content Here'; $mail = RenderedEmailTemplateMail::fromRenderedContent($subject, $htmlBody, $textBody); + // Laravel needs the build method on the mailable but doesn't use it when faking Mail. + // For that reason we test it here since it isn't picked up in any other test case. $build = $mail->build(); $this->assertSame($subject, $build->subject); + $this->assertSame($htmlBody, $build->htmlBody()); $this->assertSame($textBody, $build->textView); } } From d1ada9ce969d1de2bdeca99313da624e843fad7e Mon Sep 17 00:00:00 2001 From: Kjell Knapen Date: Wed, 2 Mar 2022 14:24:46 +0100 Subject: [PATCH 04/14] Fix issue with autodiscover for Laravel --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 203dcea..e89235d 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "extra": { "laravel": { "providers": [ - "Craftzing\\Laravel\\NotificationChannels\\NotificationChannels\\ServiceProvider" + "Craftzing\\Laravel\\NotificationChannels\\Postmark\\ServiceProvider" ] } } From ce1561e449b013ac611e97136af691a7a00abd0d Mon Sep 17 00:00:00 2001 From: Kjell Knapen Date: Mon, 8 May 2023 14:08:22 +0200 Subject: [PATCH 05/14] Update package for laravel 10 --- .github/workflows/quality-assurance.yml | 8 ++++++-- composer.json | 7 ++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/quality-assurance.yml b/.github/workflows/quality-assurance.yml index ad8934c..2d6b495 100644 --- a/.github/workflows/quality-assurance.yml +++ b/.github/workflows/quality-assurance.yml @@ -9,8 +9,8 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.0.2, 8.0, 7.4] - laravel: [^8.0, ^7.0, ^9.0] + php: [8.2, 8.1, 8.0.2, 8.0, 7.4] + laravel: [^8.0, ^7.0, ^9.0, ^10.0] dependency-version: [prefer-lowest, prefer-stable] include: - laravel: ^9.0 @@ -24,6 +24,10 @@ jobs: php: 7.4 - laravel: ^9.0 php: 8.0 + - laravel: ^10.0 + php: 7.4 + - laravel: ^10.0 + php: 8.0 name: PHP ${{ matrix.php }} with Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }} steps: - name: "Checkout code" diff --git a/composer.json b/composer.json index e89235d..c0c6767 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ "notifications", "laravel-7-package", "laravel-8-package", - "laravel-9-package" + "laravel-9-package", + "laravel-10-package" ], "type": "library", "license": "MIT", @@ -25,7 +26,7 @@ "php": "^7.4|^8.0", "ext-json": "*", "guzzlehttp/guzzle": "^6.3|^7.0", - "illuminate/support": "^7.0|^8.0|^9.0", + "illuminate/support": "^7.0|^8.0|^9.0|^10.0", "myclabs/php-enum": "^1.8", "wildbit/postmark-php": "^4.0" }, @@ -33,7 +34,7 @@ "fakerphp/faker": "^1.17", "orchestra/testbench": "^5.20|^6.6|^7.0", "phpstan/phpstan": "^1.4", - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^9.5|^10" }, "autoload": { "psr-4": { From 84644567acc22cb76ebd68fb87669a9671dcfd74 Mon Sep 17 00:00:00 2001 From: Kjell Knapen Date: Mon, 8 May 2023 14:35:09 +0200 Subject: [PATCH 06/14] Fix phpstan issues --- .github/workflows/quality-assurance.yml | 19 +++-------- composer.json | 2 +- phpstan.neon.dist | 4 --- phpunit.xml.dist | 33 ++++++++++--------- phpunit.xml.dist.bak | 18 ++++++++++ .../InteractsWithPostmarkTemplatesApi.php | 2 +- .../InteractsWithPostmarkTemplatesApiTest.php | 2 +- .../IsSendableAsPostmarkTemplate.php | 2 ++ 8 files changed, 44 insertions(+), 38 deletions(-) create mode 100644 phpunit.xml.dist.bak diff --git a/.github/workflows/quality-assurance.yml b/.github/workflows/quality-assurance.yml index 2d6b495..6d36d47 100644 --- a/.github/workflows/quality-assurance.yml +++ b/.github/workflows/quality-assurance.yml @@ -9,25 +9,14 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.2, 8.1, 8.0.2, 8.0, 7.4] - laravel: [^8.0, ^7.0, ^9.0, ^10.0] + php: [8.2, 8.1] + laravel: [^9.0, ^10.0] dependency-version: [prefer-lowest, prefer-stable] include: + - laravel: ^10.0 + testbench: ^8.0 - laravel: ^9.0 testbench: ^7.0 - - laravel: ^8.0 - testbench: ^6.6 - - laravel: ^7.0 - testbench: ^5.20 - exclude: - - laravel: ^9.0 - php: 7.4 - - laravel: ^9.0 - php: 8.0 - - laravel: ^10.0 - php: 7.4 - - laravel: ^10.0 - php: 8.0 name: PHP ${{ matrix.php }} with Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }} steps: - name: "Checkout code" diff --git a/composer.json b/composer.json index c0c6767..170c412 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ }, "require-dev": { "fakerphp/faker": "^1.17", - "orchestra/testbench": "^5.20|^6.6|^7.0", + "orchestra/testbench": "^5.20|^6.6|^7.0|^8.0", "phpstan/phpstan": "^1.4", "phpunit/phpunit": "^9.5|^10" }, diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 1e7016d..d42daec 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -7,8 +7,4 @@ parameters: - ./**/*Test.php - ./**/*TestCase.php - ./**/Fake*.php - ignoreErrors: - - '#Method [a-zA-Z0-9\\_]+::[a-zA-Z0-9_]+\(\) has parameter \$[a-zA-Z0-9]+ with no value type specified in iterable type Postmark\\Models\\DynamicResponseModel.#' - - '#Method [a-zA-Z0-9\\_]+::[a-zA-Z0-9_]+\(\) return type has no value type specified in iterable type Postmark\\Models\\DynamicResponseModel.#' - - '#Property [a-zA-Z0-9\\_]+::\$[a-zA-Z0-9]+ type has no value type specified in iterable type Postmark\\Models\\DynamicResponseModel.#' checkGenericClassInNonGenericObjectType: false diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b27af5a..8f7f243 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,18 +1,19 @@ - - - - ./src/ - - - src/ - src/ - src/Testing/ - - - - - src/ - - + + + + + src/ + + + + + ./src/ + + + src/ + src/ + src/Testing/ + + diff --git a/phpunit.xml.dist.bak b/phpunit.xml.dist.bak new file mode 100644 index 0000000..b27af5a --- /dev/null +++ b/phpunit.xml.dist.bak @@ -0,0 +1,18 @@ + + + + + ./src/ + + + src/ + src/ + src/Testing/ + + + + + src/ + + + diff --git a/src/Extensions/Laravel/Testing/InteractsWithPostmarkTemplatesApi.php b/src/Extensions/Laravel/Testing/InteractsWithPostmarkTemplatesApi.php index ce12ab9..79fe8c5 100644 --- a/src/Extensions/Laravel/Testing/InteractsWithPostmarkTemplatesApi.php +++ b/src/Extensions/Laravel/Testing/InteractsWithPostmarkTemplatesApi.php @@ -11,6 +11,6 @@ trait InteractsWithPostmarkTemplatesApi { private function assertNotificationIsSendableAsPostmarkTemplate(Notification $notification): void { - $this->assertThat($notification, $this->app[IsSendableAsPostmarkTemplate::class]); + $this->assertThatPostmark($notification, $this->app[IsSendableAsPostmarkTemplate::class]); } } diff --git a/src/Extensions/Laravel/Testing/InteractsWithPostmarkTemplatesApiTest.php b/src/Extensions/Laravel/Testing/InteractsWithPostmarkTemplatesApiTest.php index e4dacbe..6fed511 100644 --- a/src/Extensions/Laravel/Testing/InteractsWithPostmarkTemplatesApiTest.php +++ b/src/Extensions/Laravel/Testing/InteractsWithPostmarkTemplatesApiTest.php @@ -20,7 +20,7 @@ final class InteractsWithPostmarkTemplatesApiTest extends IntegrationTestCase /** * {@inheritdoc} */ - public static function assertThat($value, Constraint $constraint, string $message = ''): void + public static function assertThatPostmark($value, Constraint $constraint, string $message = ''): void { // Note that should overwrite this method in order to spy on the parameters it receives when calling // the `assertNotificationIsSendableAsPostmarkTemplate()` method of the trait we're testing... diff --git a/src/Extensions/PhpUnit/Constraints/IsSendableAsPostmarkTemplate.php b/src/Extensions/PhpUnit/Constraints/IsSendableAsPostmarkTemplate.php index 8ada254..370aee9 100644 --- a/src/Extensions/PhpUnit/Constraints/IsSendableAsPostmarkTemplate.php +++ b/src/Extensions/PhpUnit/Constraints/IsSendableAsPostmarkTemplate.php @@ -26,6 +26,7 @@ public function __construct(TemplatesApi $templatesApi) /** * {@inheritdoc} + * @param mixed $other */ public function matches($other): bool { @@ -83,6 +84,7 @@ private function postmarkTemplateMessage($other): TemplateMessage /** * {@inheritdoc} + * @param mixed $other */ protected function failureDescription($other): string { From 53534449935814be247e5213a4bf02a177ea5d9d Mon Sep 17 00:00:00 2001 From: Kjell Knapen Date: Mon, 8 May 2023 14:37:45 +0200 Subject: [PATCH 07/14] Readd old checks --- .github/workflows/quality-assurance.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/quality-assurance.yml b/.github/workflows/quality-assurance.yml index 6d36d47..8921b5a 100644 --- a/.github/workflows/quality-assurance.yml +++ b/.github/workflows/quality-assurance.yml @@ -9,14 +9,27 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.2, 8.1] - laravel: [^9.0, ^10.0] + php: [8.2, 8.1, 8.0.2, 8.0, 7.4] + laravel: [^8.0, ^7.0, ^9.0, ^10.0] dependency-version: [prefer-lowest, prefer-stable] include: - laravel: ^10.0 testbench: ^8.0 - laravel: ^9.0 testbench: ^7.0 + - laravel: ^8.0 + testbench: ^6.6 + - laravel: ^7.0 + testbench: ^5.20 + exclude: + - laravel: ^9.0 + php: 7.4 + - laravel: ^9.0 + php: 8.0 + - laravel: ^10.0 + php: 7.4 + - laravel: ^10.0 + php: 8.0 name: PHP ${{ matrix.php }} with Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }} steps: - name: "Checkout code" From 883bd2fc42877248456a6a220d7f1333218307d6 Mon Sep 17 00:00:00 2001 From: Kjell Knapen Date: Mon, 8 May 2023 14:46:34 +0200 Subject: [PATCH 08/14] Try working with newer version --- .github/workflows/quality-assurance.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/quality-assurance.yml b/.github/workflows/quality-assurance.yml index 8921b5a..2b8caf6 100644 --- a/.github/workflows/quality-assurance.yml +++ b/.github/workflows/quality-assurance.yml @@ -56,7 +56,7 @@ jobs: run: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover - name: "Run tests & publish code coverage" - uses: paambaati/codeclimate-action@v2.7.5 + uses: paambaati/codeclimate-action@v4.0.0 env: CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_TEST_REPORTER_ID }} with: From 16c4b48154d56f72f6607aae6a23e3aa94b37423 Mon Sep 17 00:00:00 2001 From: Kjell Knapen Date: Mon, 8 May 2023 15:32:05 +0200 Subject: [PATCH 09/14] Use specific version --- .github/workflows/quality-assurance.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/quality-assurance.yml b/.github/workflows/quality-assurance.yml index 2b8caf6..2afddac 100644 --- a/.github/workflows/quality-assurance.yml +++ b/.github/workflows/quality-assurance.yml @@ -26,10 +26,14 @@ jobs: php: 7.4 - laravel: ^9.0 php: 8.0 + - laravel: ^9.0 + php: 8.0.2 - laravel: ^10.0 php: 7.4 - laravel: ^10.0 php: 8.0 + - laravel: ^10.0 + php: 8.0.2 name: PHP ${{ matrix.php }} with Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }} steps: - name: "Checkout code" @@ -56,7 +60,7 @@ jobs: run: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover - name: "Run tests & publish code coverage" - uses: paambaati/codeclimate-action@v4.0.0 + uses: paambaati/codeclimate-action@v3.2.0 env: CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_TEST_REPORTER_ID }} with: From af8a87a979512fe18c54ba1cf3d59d3e0789d39c Mon Sep 17 00:00:00 2001 From: Kjell Knapen Date: Mon, 8 May 2023 15:34:21 +0200 Subject: [PATCH 10/14] Fix issue with phpunit config --- phpunit.xml.dist | 33 ++++++++++++++++----------------- phpunit.xml.dist.bak | 18 ------------------ 2 files changed, 16 insertions(+), 35 deletions(-) delete mode 100644 phpunit.xml.dist.bak diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8f7f243..b27af5a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,19 +1,18 @@ - - - - - src/ - - - - - ./src/ - - - src/ - src/ - src/Testing/ - - + + + + ./src/ + + + src/ + src/ + src/Testing/ + + + + + src/ + + diff --git a/phpunit.xml.dist.bak b/phpunit.xml.dist.bak deleted file mode 100644 index b27af5a..0000000 --- a/phpunit.xml.dist.bak +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ./src/ - - - src/ - src/ - src/Testing/ - - - - - src/ - - - From 318cfc449fa434e56c8ddcef55c803a807d50fd6 Mon Sep 17 00:00:00 2001 From: Kjell Knapen Date: Mon, 8 May 2023 15:38:48 +0200 Subject: [PATCH 11/14] Update exclude for older versions --- .github/workflows/quality-assurance.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/quality-assurance.yml b/.github/workflows/quality-assurance.yml index 2afddac..9a594f4 100644 --- a/.github/workflows/quality-assurance.yml +++ b/.github/workflows/quality-assurance.yml @@ -22,6 +22,14 @@ jobs: - laravel: ^7.0 testbench: ^5.20 exclude: + - laravel: ^7.0 + php: 8.1 + - laravel: ^7.0 + php: 8.2 + - laravel: ^8.0 + php: 8.1 + - laravel: ^8.0 + php: 8.2 - laravel: ^9.0 php: 7.4 - laravel: ^9.0 From 0ade900d0a5f68dc3dbe07281635ec8c0d62c83d Mon Sep 17 00:00:00 2001 From: Kjell Knapen Date: Mon, 8 May 2023 15:49:42 +0200 Subject: [PATCH 12/14] Add some extra types to fix phpstan issues --- .github/workflows/quality-assurance.yml | 4 ++-- src/SdkTemplatesApi.php | 4 ++++ src/ValidatedTemplateMessage.php | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/workflows/quality-assurance.yml b/.github/workflows/quality-assurance.yml index 9a594f4..2ddf7b7 100644 --- a/.github/workflows/quality-assurance.yml +++ b/.github/workflows/quality-assurance.yml @@ -65,14 +65,14 @@ jobs: echo "POSTMARK_TOKEN=${{ secrets.POSTMARK_TOKEN }}" > .env - name: "Run tests" - run: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover + run: vendor/bin/phpunit --coverage-clover=coverage.clover - name: "Run tests & publish code coverage" uses: paambaati/codeclimate-action@v3.2.0 env: CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_TEST_REPORTER_ID }} with: - coverageCommand: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover + coverageCommand: vendor/bin/phpunit --coverage-clover=coverage.clover coverageLocations: | ${{github.workspace}}/*.clover:clover debug: true diff --git a/src/SdkTemplatesApi.php b/src/SdkTemplatesApi.php index 2554f74..0b69882 100644 --- a/src/SdkTemplatesApi.php +++ b/src/SdkTemplatesApi.php @@ -73,7 +73,11 @@ public function validate(TemplateMessage $message): ValidatedTemplateMessage } /** + * @param DynamicResponseModel $template * @param array $model + * @param bool $inlineCss + * + * @return DynamicResponseModel */ private function validateTemplate( DynamicResponseModel $template, diff --git a/src/ValidatedTemplateMessage.php b/src/ValidatedTemplateMessage.php index 6208016..3a36462 100644 --- a/src/ValidatedTemplateMessage.php +++ b/src/ValidatedTemplateMessage.php @@ -45,8 +45,16 @@ final class ValidatedTemplateMessage */ public array $invalidVariables = []; + /** + * @var DynamicResponseModel $renderedTemplate + */ private DynamicResponseModel $renderedTemplate; + /** + * @param DynamicResponseModel $renderedTemplate + * @param DynamicResponseModel $model + * @param DynamicResponseModel $suggestedModel + */ private function __construct( DynamicResponseModel $renderedTemplate, DynamicResponseModel $model, @@ -60,6 +68,13 @@ private function __construct( $this->parseForValidationErrors($model, $suggestedModel); } + /** + * @param DynamicResponseModel $renderedTemplate + * @param TemplateModel $model + * @param DynamicResponseModel $suggestedModel + * + * @return self + */ public static function validate( DynamicResponseModel $renderedTemplate, TemplateModel $model, @@ -71,6 +86,10 @@ public static function validate( return new self($renderedTemplate, new DynamicResponseModel($model->variables()), $suggestedModel); } + /** + * @param DynamicResponseModel $model + * @param DynamicResponseModel $suggestedModel + */ private function parseForValidationErrors(DynamicResponseModel $model, DynamicResponseModel $suggestedModel): void { foreach ($suggestedModel as $key => $suggestedValue) { @@ -92,7 +111,10 @@ private function parseForValidationErrors(DynamicResponseModel $model, DynamicRe /** * @param string|int $key + * @param DynamicResponseModel $model * @param string|array $suggestedValue + * + * @return bool */ private function isMarkedAsMissing($key, DynamicResponseModel $model, $suggestedValue): bool { From 2088eff9d68d54a3ff8756614f4d5272a5b35368 Mon Sep 17 00:00:00 2001 From: kjellknapen Date: Mon, 8 May 2023 13:50:11 +0000 Subject: [PATCH 13/14] Fix code style violations --- src/ValidatedTemplateMessage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ValidatedTemplateMessage.php b/src/ValidatedTemplateMessage.php index 3a36462..da4aa95 100644 --- a/src/ValidatedTemplateMessage.php +++ b/src/ValidatedTemplateMessage.php @@ -46,7 +46,7 @@ final class ValidatedTemplateMessage public array $invalidVariables = []; /** - * @var DynamicResponseModel $renderedTemplate + * @var DynamicResponseModel */ private DynamicResponseModel $renderedTemplate; From f53d772cbed9dfc6ad2c2ccbce338d3de9814602 Mon Sep 17 00:00:00 2001 From: Kjell Knapen Date: Mon, 8 May 2023 15:52:12 +0200 Subject: [PATCH 14/14] Update checkout to v3 for github actions --- .github/workflows/code-style.yml | 2 +- .github/workflows/quality-assurance.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index 47cb58f..3d91139 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: ${{ github.head_ref }} diff --git a/.github/workflows/quality-assurance.yml b/.github/workflows/quality-assurance.yml index 2ddf7b7..dc7bb0e 100644 --- a/.github/workflows/quality-assurance.yml +++ b/.github/workflows/quality-assurance.yml @@ -45,7 +45,7 @@ jobs: name: PHP ${{ matrix.php }} with Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }} steps: - name: "Checkout code" - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: "Setup PHP" uses: shivammathur/setup-php@v2