Skip to content

Commit

Permalink
prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
spiralbot committed Jan 7, 2025
1 parent 477c806 commit d83788f
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 48 deletions.
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@
"require": {
"php": ">=8.1",
"ext-json": "*",
"spiral/core": "^3.15",
"spiral/queue": "^3.15",
"spiral/logger": "^3.15",
"spiral/mailer": "^3.15",
"spiral/views": "^3.15",
"spiral/core": "^3.14.9",
"spiral/queue": "^3.14.9",
"spiral/logger": "^3.14.9",
"spiral/mailer": "^3.14.9",
"spiral/views": "^3.14.9",
"symfony/mailer": "^5.1 || ^6.0 || ^7.0",
"psr/event-dispatcher": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^10.1",
"mockery/mockery": "^1.5",
"spiral/boot": "^3.15",
"spiral/stempler-bridge": "^3.15",
"spiral/boot": "^3.14.9",
"spiral/stempler-bridge": "^3.14.9",
"spiral/testing": "^2.8",
"vimeo/psalm": "^5.9"
},
Expand Down
22 changes: 11 additions & 11 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public function testConfig(): void
'queueConnection' => 'foo',
]);

self::assertSame('mailer-dsn', $cfg->getDSN());
self::assertSame('admin@spiral.dev', $cfg->getFromAddress());
self::assertSame('emails', $cfg->getQueue());
self::assertSame('foo', $cfg->getQueueConnection());
$this->assertSame('mailer-dsn', $cfg->getDSN());
$this->assertSame('admin@spiral.dev', $cfg->getFromAddress());
$this->assertSame('emails', $cfg->getQueue());
$this->assertSame('foo', $cfg->getQueueConnection());
}

public function testDefaultConfig(): void
Expand All @@ -36,10 +36,10 @@ public function testDefaultConfig(): void
'queueConnection' => $env->get('MAILER_QUEUE_CONNECTION'),
]);

self::assertSame('', $config->getDSN());
self::assertSame('Spiral <sendit@local.host>', $config->getFromAddress());
self::assertSame('local', $config->getQueue());
self::assertNull($config->getQueueConnection());
$this->assertSame('', $config->getDSN());
$this->assertSame('Spiral <sendit@local.host>', $config->getFromAddress());
$this->assertSame('local', $config->getQueue());
$this->assertNull($config->getQueueConnection());
}

public function testDefaultConfigWithQueue(): void
Expand All @@ -50,7 +50,7 @@ public function testDefaultConfigWithQueue(): void
'queue' => $env->get('MAILER_QUEUE', 'local'),
]);

self::assertSame('emails', $config->getQueue());
$this->assertSame('emails', $config->getQueue());
}

public function testQueueWithNull(): void
Expand All @@ -59,12 +59,12 @@ public function testQueueWithNull(): void
'queue' => null,
]);

self::assertNull($config->getQueue());
$this->assertNull($config->getQueue());
}

public function testGetsQueueConnectionWithoutKey(): void
{
$cfg = new MailerConfig();
self::assertNull($cfg->getQueueConnection());
$this->assertNull($cfg->getQueueConnection());
}
}
4 changes: 2 additions & 2 deletions tests/JobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ private function getEmail(): Email
private function expectRenderer(Email $email): void
{
$this->renderer->expects('render')->withArgs(
function (Message $message): bool {
self::assertSame('test', $message->getSubject());
function (Message $message) {
$this->assertSame($message->getSubject(), 'test');
return true;
}
)->andReturn($email);
Expand Down
8 changes: 4 additions & 4 deletions tests/JobsQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public function testQueue(): void
$mail->setBCC('admin2@google.com');

$queue->expects('push')->withArgs(
function ($job, $data, Options $options) use ($mail): bool {
self::assertSame(MailQueue::JOB_NAME, $job);
self::assertSame($data, MessageSerializer::pack($mail));
self::assertSame('mailer', $options->getQueue());
function ($job, $data, Options $options) use ($mail) {
$this->assertSame(MailQueue::JOB_NAME, $job);
$this->assertSame($data, MessageSerializer::pack($mail));
$this->assertSame('mailer', $options->getQueue());

return true;
}
Expand Down
25 changes: 13 additions & 12 deletions tests/QueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class QueueTest extends TestCase
{
/** @var m\LegacyMockInterface|m\MockInterface|QueueInterface */
private $queue;
private MailQueue $mailer;
/** @var MailQueue */
private $mailer;

protected function setUp(): void
{
Expand All @@ -42,11 +43,11 @@ public function testQueue(): void
$mail->setBCC('admin2@google.com');

$this->queue->expects('push')->withArgs(
function ($job, $data, Options $options) use ($mail): bool {
self::assertSame(MailQueue::JOB_NAME, $job);
self::assertSame($data, MessageSerializer::pack($mail));
self::assertSame('mailer', $options->getQueue());
self::assertNull($options->getDelay());
function ($job, $data, Options $options) use ($mail) {
$this->assertSame(MailQueue::JOB_NAME, $job);
$this->assertSame($data, MessageSerializer::pack($mail));
$this->assertSame('mailer', $options->getQueue());
$this->assertNull($options->getDelay());

return true;
}
Expand All @@ -67,22 +68,22 @@ public function testQueueWithDelay(): void
$mail3->setDelay(200);

$this->queue->expects('push')->once()->withArgs(
function ($job, $data, Options $options): bool {
self::assertSame(30, $options->getDelay());
function ($job, $data, Options $options) {
$this->assertSame(30, $options->getDelay());
return true;
}
);

$this->queue->expects('push')->once()->withArgs(
function ($job, $data, Options $options): bool {
self::assertSame(100, $options->getDelay());
function ($job, $data, Options $options) {
$this->assertSame(100, $options->getDelay());
return true;
}
);

$this->queue->expects('push')->once()->withArgs(
function ($job, $data, Options $options): bool {
self::assertSame(200, $options->getDelay());
function ($job, $data, Options $options) {
$this->assertSame(200, $options->getDelay());
return true;
}
);
Expand Down
8 changes: 3 additions & 5 deletions tests/RenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public function defineDirectories(string $root): array

public function tearDown(): void
{
parent::tearDown();

foreach (glob(__DIR__ . '/App/runtime/cache/views/*.php') as $file) {
@unlink($file);
}
Expand All @@ -55,11 +53,11 @@ public function testRender(): void
{
$email = $this->send(new Message('email', ['email@domain.com'], ['name' => 'Antony']));

self::assertSame('Demo Email', $email->getSubject());
$this->assertSame('Demo Email', $email->getSubject());

$body = $email->getBody()->toString();
self::assertStringContainsString('bootstrap.txt', $body);
self::assertStringContainsString('<p>Hello, Antony!</p>', $body);
$this->assertStringContainsString('bootstrap.txt', $body);
$this->assertStringContainsString('<p>Hello, Antony!</p>', $body);
}

private function send(MessageInterface $message): Email
Expand Down
7 changes: 5 additions & 2 deletions tests/SerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public function testSerializeUnserialize(): void

$data = MessageSerializer::pack($mail);

self::assertSame(['subject', 'data', 'to', 'cc', 'bcc', 'from', 'replyTo', 'options'], array_keys($data));
self::assertEquals($mail, MessageSerializer::unpack($data));
$this->assertSame(
['subject', 'data', 'to', 'cc', 'bcc', 'from', 'replyTo', 'options'],
array_keys($data)
);
$this->assertEquals($mail, MessageSerializer::unpack($data));
}
}
10 changes: 5 additions & 5 deletions tests/TransportResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public function testCanRegisterTransport(): void
$transportResolver = new TransportResolver(new Transport([]));

$transportResolver->registerTransport($transportFactory);
self::assertCount(1, $transportResolver->getTransports());
$this->assertCount(1, $transportResolver->getTransports());
}

public function testCanResolveRegisteredTransport(): void
{
$transportFactory = m::mock(TransportFactoryInterface::class);
$arg = static fn(Transport\Dsn $dsn): bool => $dsn->getHost() === 'localhost' and $dsn->getScheme() === 'smtp';
$arg = fn(Transport\Dsn $dsn) => $dsn->getHost() === 'localhost' and $dsn->getScheme() === 'smtp';

$transportFactory->shouldReceive('supports')->once()->withArgs($arg)->andReturn(true);
$transportFactory->shouldReceive('create')->once()->withArgs($arg)
Expand All @@ -38,21 +38,21 @@ public function testCanResolveRegisteredTransport(): void

$transportResolver->registerTransport($transportFactory);

self::assertSame($transport, $transportResolver->resolve('smtp://localhost'));
$this->assertSame($transport, $transportResolver->resolve('smtp://localhost'));
}

public function testCanResolveRegisteredDefaultTransport(): void
{
$transportFactory = m::mock(TransportFactoryInterface::class);
$arg = static fn(Transport\Dsn $dsn): bool => $dsn->getHost() === 'localhost' and $dsn->getScheme() === 'smtp';
$arg = fn(Transport\Dsn $dsn) => $dsn->getHost() === 'localhost' and $dsn->getScheme() === 'smtp';

$transportFactory->shouldReceive('supports')->once()->withArgs($arg)->andReturn(true);
$transportFactory->shouldReceive('create')->once()->withArgs($arg)
->andReturn($transport = m::mock(Transport\TransportInterface::class));

$transportResolver = new TransportResolver(new Transport([$transportFactory]));

self::assertSame($transport, $transportResolver->resolve('smtp://localhost'));
$this->assertSame($transport, $transportResolver->resolve('smtp://localhost'));
}

public function testNotRegisteredTransportShouldTrowAnException(): void
Expand Down

0 comments on commit d83788f

Please sign in to comment.