Skip to content

Commit

Permalink
[Mailer] fix PR tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PEtanguy committed May 11, 2023
1 parent 8937020 commit 8cf7fda
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BrevoApiTransportTest extends TestCase
*/
public function testToString(BrevoApiTransport $transport, string $expected)
{
$this->assertSame($expected, (string)$transport);
$this->assertSame($expected, (string) $transport);
}

public static function getTransportData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public function __toString(): string

protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $envelope): ResponseInterface
{
// TODO check this
$response = $this->client->request('POST', 'https://' . $this->getEndpoint() . '/v3/smtp/email', [
$response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/v3/smtp/email', [
'json' => $this->getPayload($email, $envelope),
'headers' => [
'api-key' => $this->key,
Expand All @@ -60,13 +59,13 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e
$statusCode = $response->getStatusCode();
$result = $response->toArray(false);
} catch (DecodingExceptionInterface) {
throw new HttpTransportException('Unable to send an email: ' . $response->getContent(false) . sprintf(' (code %d).', $statusCode), $response);
throw new HttpTransportException('Unable to send an email: '.$response->getContent(false).sprintf(' (code %d).', $statusCode), $response);
} catch (TransportExceptionInterface $e) {
throw new HttpTransportException('Could not reach the remote Brevo server.', $response, 0, $e);
}

if (201 !== $statusCode) {
throw new HttpTransportException('Unable to send an email: ' . $result['message'] . sprintf(' (code %d).', $statusCode), $response);
throw new HttpTransportException('Unable to send an email: '.$result['message'].sprintf(' (code %d).', $statusCode), $response);
}

$sentMessage->setMessageId($result['messageId']);
Expand Down Expand Up @@ -153,7 +152,7 @@ private function prepareHeadersAndTags(Headers $headers): array
continue;
}
if ('templateid' === $name) {
$headersAndTags[$header->getName()] = (int)$header->getValue();
$headersAndTags[$header->getName()] = (int) $header->getValue();

continue;
}
Expand Down Expand Up @@ -181,7 +180,6 @@ private function stringifyAddress(Address $address): array

private function getEndpoint(): ?string
{
// TODO check this
return ($this->host ?: 'api.brevo.com') . ($this->port ? ':' . $this->port : '');
return ($this->host ?: 'api.brevo.com').($this->port ? ':'.$this->port : '');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function create(Dsn $dsn): TransportInterface
return (new BrevoApiTransport($this->getUser($dsn), $this->client, $this->dispatcher, $this->logger))
->setHost('default' === $dsn->getHost() ? null : $dsn->getHost())
->setPort($dsn->getPort())
;
;
}

return new $transport($this->getUser($dsn), $this->getPassword($dsn), $this->dispatcher, $this->logger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class SendinblueTransportFactory extends AbstractTransportFactory
{
public function create(Dsn $dsn): TransportInterface
{
trigger_deprecation('symfony/sendinblue-mailer', '6.3', 'The "%s" class is deprecated, use "%s" instead.', SendinblueTransportFactory::class, BrevoTransportFactory::class);
trigger_deprecation('symfony/sendinblue-mailer', '6.3', 'The "%s" class is deprecated, use "%s" instead.', self::class, BrevoTransportFactory::class);

if (!\in_array($dsn->getScheme(), $this->getSupportedSchemes(), true)) {
throw new UnsupportedSchemeException($dsn, 'sendinblue', $this->getSupportedSchemes());
Expand Down

0 comments on commit 8cf7fda

Please sign in to comment.