Skip to content

Commit

Permalink
✅ fix tests with new fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanti committed Aug 19, 2024
1 parent 08389ef commit 6f3e450
Show file tree
Hide file tree
Showing 24 changed files with 99 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.php }}-composer-
- run: composer require typo3/minimal="^${{ matrix.typo3 }}" --dev
- run: composer require typo3/cms-frontend="^${{ matrix.typo3 }}" --dev
- run: composer install --no-interaction --no-progress
- run: ./vendor/bin/grumphp run --ansi
- run: composer test
Expand Down
3 changes: 2 additions & 1 deletion Classes/Domain/Model/MailLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class MailLog extends AbstractModel

protected string $result = 'Not send until now';

protected int $status = MailStatus::UNKNOWN->value;
//protected int $status = MailStatus::UNKNOWN->value; // if PHP 8.2 is lowest PHP version
protected int $status = 0;

protected string $debug = '';

Expand Down
12 changes: 6 additions & 6 deletions Classes/Dto/SendResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
use Throwable;
use TYPO3\CMS\Core\Core\Environment;

final readonly class SendResult
final class SendResult
{
public function __construct(
public string $result,
public MailStatus $status,
public string $debug = '',
public ?SentMessage $sentMessage = null,
public ?Throwable $throwable = null,
public readonly string $result,
public readonly MailStatus $status,
public readonly string $debug = '',
public readonly ?SentMessage $sentMessage = null,
public readonly ?Throwable $throwable = null,
) {
}

Expand Down
6 changes: 4 additions & 2 deletions Classes/Logging/LoggingTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Pluswerk\MailLogger\Logging;

use Stringable;
use Throwable;
use Pluswerk\MailLogger\Domain\Model\MailLog;
use Pluswerk\MailLogger\Domain\Model\TemplateBasedMailMessage;
use Pluswerk\MailLogger\Domain\Repository\MailLogRepository;
Expand All @@ -26,7 +28,7 @@
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
use TYPO3\CMS\Extbase\Utility\DebuggerUtility;

class LoggingTransport implements TransportInterface, \Stringable
class LoggingTransport implements TransportInterface, Stringable
{
public function __construct(protected TransportInterface $originalTransport)
{
Expand Down Expand Up @@ -87,7 +89,7 @@ private function originalSend(RawMessage $message, Envelope $envelope = null): S
}

return new SendResult($result, $status, $sendMessage->getDebug(), $sendMessage);
} catch (\Throwable $throwable) {
} catch (Throwable $throwable) {
return new SendResult('Email not sent. Error: ' . $throwable->getMessage(), MailStatus::NOT_SENT, throwable: $throwable);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/Utility/MailUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MailUtility
* @param string $key The TypoScript key of your template
* @param int|null $languageUid The language uid
* @param array<array-key, mixed> $viewParameters This is necessary if you use Fluid for your mail fields
* @throws \Exception
* @throws Exception
*/
public static function getMailByKey(string $key, int $languageUid = null, array $viewParameters = []): TemplateBasedMailMessage
{
Expand All @@ -38,7 +38,7 @@ public static function getMailByKey(string $key, int $languageUid = null, array
*
* @param int $mailTemplateId The identifier uid of your template
* @param array<array-key, mixed> $viewParameters This is necessary if you use Fluid for your mail fields
* @throws \Exception
* @throws Exception
* @deprecated will be removed. use \Pluswerk\MailLogger\Utility\MailUtility::getMailByKey instead
*/
public static function getMailById(int $mailTemplateId, array $viewParameters = []): TemplateBasedMailMessage
Expand Down
3 changes: 0 additions & 3 deletions Classes/ViewHelpers/Pagination/UriViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

namespace Pluswerk\MailLogger\ViewHelpers\Pagination;

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Extbase\Service\ExtensionService;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;

class UriViewHelper extends AbstractTagBasedViewHelper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Pluswerk\MailLogger\Tests\Functional\MailLogRepository;

use ReflectionObject;
use DateTime;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Extbase\Persistence\Generic\Exception\NotImplementedException;
Expand Down Expand Up @@ -48,8 +49,8 @@ public function testInitializeObject(): void
'anonymizeAfter' => $mailLogRepository->getAnonymizeAfter(),
'anonymizeSymbol' => $mailLogRepository->getAnonymizeSymbol(),
],
JSON_THROW_ON_ERROR
)
JSON_THROW_ON_ERROR,
),
);
}

Expand Down Expand Up @@ -214,6 +215,10 @@ protected function assertModelSnapshot(?MailLog $model): void
unset($data['tstamp'], $data['crdate']);
}

if ($data) {
ksort($data);
}

$this->assertMatchesJsonSnapshot(json_encode($data, JSON_THROW_ON_ERROR));
}

Expand All @@ -225,6 +230,6 @@ protected function assertModelSnapshot(?MailLog $model): void
*/
protected function callInaccessibleMethod(object $object, string $name): mixed
{
return (new \ReflectionObject($object))->getMethod($name)->invokeArgs($object, []);
return (new ReflectionObject($object))->getMethod($name)->invokeArgs($object, []);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"uid": 1,
"pid": 1,
"typoScriptKey": "typoscriptKey558",
"subject": "subject558",
"message": "message558",
Expand All @@ -8,7 +10,7 @@
"mailBlindCopy": "mail558@test.test",
"headers": "headers558",
"result": "Not send until now",
"sysLanguageUid": 0,
"uid": 1,
"pid": 1
"status": 0,
"debug": "",
"sysLanguageUid": 0
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"uid": 1,
"pid": 1,
"typoScriptKey": "typoscriptKey7894",
"subject": "***",
"message": "***",
Expand All @@ -8,7 +10,7 @@
"mailBlindCopy": "***",
"headers": "***",
"result": "Not send until now",
"sysLanguageUid": 0,
"uid": 1,
"pid": 1
"status": 0,
"debug": "***",
"sysLanguageUid": 0
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"uid": 1,
"pid": 1,
"typoScriptKey": "typoscriptKey2345",
"subject": "***",
"message": "***",
Expand All @@ -8,7 +10,7 @@
"mailBlindCopy": "***",
"headers": "***",
"result": "Not send until now",
"sysLanguageUid": 0,
"uid": 1,
"pid": 1
"status": 0,
"debug": "",
"sysLanguageUid": 0
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"uid": 1,
"pid": 1,
"typoScriptKey": "typoscriptKey555",
"subject": "subject555",
"message": "message555",
Expand All @@ -8,7 +10,7 @@
"mailBlindCopy": "mail555@test.test",
"headers": "headers555",
"result": "Not send until now",
"sysLanguageUid": 0,
"uid": 1,
"pid": 1
"status": 0,
"debug": "",
"sysLanguageUid": 0
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"uid": 1,
"pid": 1,
"typoScriptKey": "typoscriptKey558",
"subject": "***",
"message": "***",
Expand All @@ -8,7 +10,7 @@
"mailBlindCopy": "***",
"headers": "***",
"result": "Not send until now",
"sysLanguageUid": 0,
"uid": 1,
"pid": 1
"status": 0,
"debug": "",
"sysLanguageUid": 0
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"uid": 1,
"pid": 1,
"typoScriptKey": "typoscriptKey7894",
"subject": "***",
"message": "***",
Expand All @@ -8,7 +10,7 @@
"mailBlindCopy": "***",
"headers": "***",
"result": "Not send until now",
"sysLanguageUid": 0,
"uid": 1,
"pid": 1
"status": 0,
"debug": "***",
"sysLanguageUid": 0
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"uid": 1,
"pid": 1,
"typoScriptKey": "typoscriptKey789",
"subject": "***",
"message": "***",
Expand All @@ -8,7 +10,7 @@
"mailBlindCopy": "***",
"headers": "***",
"result": "Not send until now",
"sysLanguageUid": 0,
"uid": 1,
"pid": 1
"status": 0,
"debug": "",
"sysLanguageUid": 0
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"uid": 1,
"pid": 1,
"typoScriptKey": "typoscriptKey2345",
"subject": "***",
"message": "***",
Expand All @@ -8,7 +10,7 @@
"mailBlindCopy": "***",
"headers": "***",
"result": "Not send until now",
"sysLanguageUid": 0,
"uid": 1,
"pid": 1
"status": 0,
"debug": "",
"sysLanguageUid": 0
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"uid": 1,
"pid": 1,
"typoScriptKey": "typoscriptKey555",
"subject": "***",
"message": "***",
Expand All @@ -8,7 +10,7 @@
"mailBlindCopy": "***",
"headers": "***",
"result": "Not send until now",
"sysLanguageUid": 0,
"uid": 1,
"pid": 1
"status": 0,
"debug": "",
"sysLanguageUid": 0
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"uid": 1,
"pid": 1,
"typoScriptKey": "typoscriptKey558",
"subject": "subject558",
"message": "message558",
Expand All @@ -8,7 +10,7 @@
"mailBlindCopy": "mail558@test.test",
"headers": "headers558",
"result": "Not send until now",
"sysLanguageUid": 0,
"uid": 1,
"pid": 1
"status": 0,
"debug": "",
"sysLanguageUid": 0
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"uid": 1,
"pid": 1,
"typoScriptKey": "typoscriptKey7894",
"subject": "subject7894",
"message": "message7894",
Expand All @@ -8,7 +10,7 @@
"mailBlindCopy": "mail7894@test.test",
"headers": "headers7894",
"result": "Not send until now",
"sysLanguageUid": 0,
"uid": 1,
"pid": 1
"status": 0,
"debug": "",
"sysLanguageUid": 0
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"uid": 1,
"pid": 1,
"typoScriptKey": "typoscriptKey2345",
"subject": "subject2345",
"message": "message2345",
Expand All @@ -8,7 +10,7 @@
"mailBlindCopy": "mail2345@test.test",
"headers": "headers2345",
"result": "Not send until now",
"sysLanguageUid": 0,
"uid": 1,
"pid": 1
"status": 0,
"debug": "",
"sysLanguageUid": 0
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"uid": 1,
"pid": 1,
"typoScriptKey": "typoscriptKey555",
"subject": "subject555",
"message": "message555",
Expand All @@ -8,7 +10,7 @@
"mailBlindCopy": "mail555@test.test",
"headers": "headers555",
"result": "Not send until now",
"sysLanguageUid": 0,
"uid": 1,
"pid": 1
"status": 0,
"debug": "",
"sysLanguageUid": 0
}
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
},
"require-dev": {
"ext-json": "*",
"pluswerk/grumphp-config": "^6.10.0",
"pluswerk/grumphp-config": "^7.1.0",
"saschaegerer/phpstan-typo3": "^1.10.1",
"spatie/phpunit-snapshot-assertions": "^4.2.17",
"ssch/typo3-rector": "^1.8.1",
"typo3/testing-framework": "^7.1.0"
"spatie/phpunit-snapshot-assertions": "^4.2.17 || ^5.1.6",
"ssch/typo3-rector": "^2.6.4",
"typo3/testing-framework": "^7.1.0 || ^8.2.1"
},
"replace": {
"pluswerk/mail_logger": "self.version",
Expand Down Expand Up @@ -54,7 +54,8 @@
},
"scripts": {
"post-update-cmd": [
"@composer bump --dev-only"
"@composer bump --dev-only",
"@composer normalize"
],
"test": "vendor/bin/phpunit --color=always",
"test:update": "vendor/bin/phpunit --color=always -d --update-snapshots"
Expand Down
Loading

0 comments on commit 6f3e450

Please sign in to comment.