Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ on:
jobs:
tests:
runs-on: ubuntu-latest
name: "PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, Twig ${{ matrix.twig }}"
name: "PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}"
strategy:
fail-fast: false
matrix:
php: ["8.1", "8.2", "8.3"]
symfony: ["^5.4", "^6.4", "^7.0"]
twig: ["^2.12", "^3.3"]
exclude:
- twig: "^2.12"
symfony: "^7.0"
- php: "8.1"
symfony: "^7.0"

Expand All @@ -36,22 +33,15 @@ jobs:
with:
php-version: "${{ matrix.php }}"
coverage: none
tools: 'composer:v2, flex'

-
name: Restrict Symfony version
if: matrix.symfony != ''
run: |
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
composer config extra.symfony.require "${{ matrix.symfony }}"
(cd src/Component && composer config extra.symfony.require "${{ matrix.symfony }}")

-
name: Restrict Twig version
if: matrix.twig != ''
run: |
composer require "twig/twig:${{ matrix.twig }}" --no-update --no-scripts

-
name: Install dependencies
run: |
Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,3 @@ parameters:

ignoreErrors:
- '/Property Sylius\\Component\\Mailer\\Model\\Email\:\:\$id is never written\, only read\./'
- '/PHPDoc tag \@param references unknown parameter\: \$bccRecipients/'
- '/PHPDoc tag \@param references unknown parameter\: \$ccRecipients/'
11 changes: 3 additions & 8 deletions src/Component/Sender/Sender.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public function send(
array $data = [],
array $attachments = [],
array $replyTo = [],
array $ccRecipients = [],
array $bccRecipients = [],
): void {
$arguments = func_get_args();

Assert::allStringNotEmpty($recipients);

$email = $this->provider->getEmail($code);
Expand All @@ -65,12 +65,7 @@ public function send(

$renderedEmail = $this->rendererAdapter->render($email, $data);

if (count($arguments) > 5 && $this->senderAdapter instanceof CcAwareAdapterInterface) {
/** @var array<string> $ccRecipients */
$ccRecipients = $arguments[5] ?? [];
/** @var array<string> $bccRecipients */
$bccRecipients = $arguments[6] ?? [];

if ($this->senderAdapter instanceof CcAwareAdapterInterface) {
$this->senderAdapter->sendWithCC(
$recipients,
$senderAddress,
Expand Down
4 changes: 2 additions & 2 deletions src/Component/Sender/SenderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
interface SenderInterface
{
/**
* @deprecated using this method without 2 last arguments ($ccRecipients and $bccRecipients) is deprecated since 1.8 and won't be possible since 2.0
*
* @param string[]|null[] $recipients A list of email addresses to receive the message. Providing null or empty string in the list of recipients is deprecated and will be removed in SyliusMailerBundle 2.0
* @param string[] $attachments A list of file paths to attach to the message.
* @param string[] $replyTo A list of email addresses to set as the Reply-To address for the message.
Expand All @@ -30,5 +28,7 @@ public function send(
array $data = [],
array $attachments = [],
array $replyTo = [],
array $ccRecipients = [],
array $bccRecipients = [],
): void;
}
34 changes: 20 additions & 14 deletions src/Component/spec/Sender/SenderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
use Sylius\Component\Mailer\Provider\EmailProviderInterface;
use Sylius\Component\Mailer\Renderer\Adapter\AdapterInterface as RendererAdapterInterface;
use Sylius\Component\Mailer\Renderer\RenderedEmail;
use Sylius\Component\Mailer\Sender\Adapter\CcAwareAdapterInterface as SenderAdapterInterface;
use Sylius\Component\Mailer\Sender\Adapter\AdapterInterface as SenderAdapterInterface;
use Sylius\Component\Mailer\Sender\Adapter\CcAwareAdapterInterface as CcAwareSenderAdapterInterface;

final class SenderSpec extends ObjectBehavior
{
Expand All @@ -35,11 +36,11 @@ function let(
}

function it_sends_an_email_through_the_adapter(
EmailInterface $email,
EmailProviderInterface $provider,
RenderedEmail $renderedEmail,
RendererAdapterInterface $rendererAdapter,
SenderAdapterInterface $senderAdapter,
EmailProviderInterface $provider,
EmailInterface $email,
RenderedEmail $renderedEmail,
): void {
$provider->getEmail('bar')->willReturn($email);
$email->isEnabled()->willReturn(true);
Expand All @@ -49,6 +50,7 @@ function it_sends_an_email_through_the_adapter(
$data = ['foo' => 2];

$rendererAdapter->render($email, ['foo' => 2])->willReturn($renderedEmail);

$senderAdapter->send(
['john@example.com'],
'sender@example.com',
Expand All @@ -60,16 +62,19 @@ function it_sends_an_email_through_the_adapter(
[],
)->shouldBeCalled();

$this->send('bar', ['john@example.com'], $data, [], []);
$this->send('bar', ['john@example.com'], $data);
}

function it_sends_an_email_with_cc_and_bcc_through_the_adapter(
EmailInterface $email,
RendererAdapterInterface $rendererAdapter,
CcAwareSenderAdapterInterface $senderAdapter,
EmailProviderInterface $provider,
DefaultSettingsProviderInterface $defaultSettingsProvider,
EmailInterface $email,
RenderedEmail $renderedEmail,
RendererAdapterInterface $rendererAdapter,
SenderAdapterInterface $senderAdapter,
): void {
$this->beConstructedWith($rendererAdapter, $senderAdapter, $provider, $defaultSettingsProvider);

$provider->getEmail('bar')->willReturn($email);
$email->isEnabled()->willReturn(true);
$email->getSenderAddress()->willReturn('sender@example.com');
Expand All @@ -78,6 +83,7 @@ function it_sends_an_email_with_cc_and_bcc_through_the_adapter(
$data = ['foo' => 2];

$rendererAdapter->render($email, ['foo' => 2])->willReturn($renderedEmail);
$senderAdapter->send(Argument::cetera())->shouldNotBeCalled();
$senderAdapter->sendWithCC(
['john@example.com'],
'sender@example.com',
Expand All @@ -95,13 +101,13 @@ function it_sends_an_email_with_cc_and_bcc_through_the_adapter(
}

function it_sends_a_modified_email_with_cc_and_bcc_through_the_adapter(
EmailInterface $email,
EmailProviderInterface $provider,
RenderedEmail $renderedEmail,
RendererAdapterInterface $rendererAdapter,
SenderAdapterInterface $senderAdapter,
CcAwareSenderAdapterInterface $senderAdapter,
EmailProviderInterface $provider,
DefaultSettingsProviderInterface $defaultSettingsProvider,
EmailModifierInterface $emailModifier,
EmailInterface $email,
RenderedEmail $renderedEmail,
): void {
$this->beConstructedWith($rendererAdapter, $senderAdapter, $provider, $defaultSettingsProvider, $emailModifier);

Expand Down Expand Up @@ -133,10 +139,10 @@ function it_sends_a_modified_email_with_cc_and_bcc_through_the_adapter(
}

function it_does_not_send_disabled_emails(
EmailInterface $email,
EmailProviderInterface $provider,
RendererAdapterInterface $rendererAdapter,
SenderAdapterInterface $senderAdapter,
EmailProviderInterface $provider,
EmailInterface $email,
): void {
$provider->getEmail('bar')->willReturn($email);
$email->isEnabled()->willReturn(false);
Expand Down