Skip to content

Commit

Permalink
refactor: enable phpunit code quality set for rector (#1186)
Browse files Browse the repository at this point in the history
  • Loading branch information
spiralbot committed Jan 4, 2025
1 parent c6da58d commit 477c806
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 33 deletions.
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',
]);

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

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

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

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

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

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

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

public function testGetsQueueConnectionWithoutKey(): void
{
$cfg = new MailerConfig();
$this->assertNull($cfg->getQueueConnection());
self::assertNull($cfg->getQueueConnection());
}
}
2 changes: 1 addition & 1 deletion tests/JobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private function expectRenderer(Email $email): void
{
$this->renderer->expects('render')->withArgs(
function (Message $message): bool {
$this->assertSame($message->getSubject(), 'test');
self::assertSame('test', $message->getSubject());
return true;
}
)->andReturn($email);
Expand Down
6 changes: 3 additions & 3 deletions tests/JobsQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public function testQueue(): void

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

return true;
}
Expand Down
14 changes: 7 additions & 7 deletions tests/QueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public function testQueue(): void

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

return true;
}
Expand All @@ -68,21 +68,21 @@ public function testQueueWithDelay(): void

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

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

$this->queue->expects('push')->once()->withArgs(
function ($job, $data, Options $options): bool {
$this->assertSame(200, $options->getDelay());
self::assertSame(200, $options->getDelay());
return true;
}
);
Expand Down
6 changes: 3 additions & 3 deletions tests/RenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public function testRender(): void
{
$email = $this->send(new Message('email', ['email@domain.com'], ['name' => 'Antony']));

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

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

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

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

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

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

public function testCanResolveRegisteredTransport(): void
Expand All @@ -38,7 +38,7 @@ public function testCanResolveRegisteredTransport(): void

$transportResolver->registerTransport($transportFactory);

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

public function testCanResolveRegisteredDefaultTransport(): void
Expand All @@ -52,7 +52,7 @@ public function testCanResolveRegisteredDefaultTransport(): void

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

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

public function testNotRegisteredTransportShouldTrowAnException(): void
Expand Down

0 comments on commit 477c806

Please sign in to comment.