Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pierredup committed Mar 7, 2023
1 parent b5cb3ba commit 786163a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1105,16 +1105,6 @@ parameters:
count: 1
path: src/MailerBundle/Factory/MailerConfigFactory.php

-
message: "#^Property SolidInvoice\\\\MailerBundle\\\\Factory\\\\MailerConfigFactory\\:\\:\\$config has no type specified\\.$#"
count: 1
path: src/MailerBundle/Factory/MailerConfigFactory.php

-
message: "#^Property SolidInvoice\\\\MailerBundle\\\\Factory\\\\MailerConfigFactory\\:\\:\\$inner has no type specified\\.$#"
count: 1
path: src/MailerBundle/Factory/MailerConfigFactory.php

-
message: "#^Method SolidInvoice\\\\MoneyBundle\\\\Calculator\\:\\:calculateDiscount\\(\\) has parameter \\$entity with no type specified\\.$#"
count: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use SolidInvoice\CoreBundle\Response\FlashResponse;
use SolidInvoice\CoreBundle\Templating\Template;
use SolidInvoice\FormBundle\Test\FormHandlerTestCase;
use SolidInvoice\InvoiceBundle\Email\InvoiceEmail;
use SolidInvoice\InvoiceBundle\Entity\Invoice;
use SolidInvoice\InvoiceBundle\Form\Handler\InvoiceEditHandler;
use SolidInvoice\InvoiceBundle\Listener\WorkFlowSubscriber;
Expand Down Expand Up @@ -92,7 +93,12 @@ public function getHandler(): InvoiceEditHandler
->withAnyArgs()
->andReturn('/invoices/1');

$handler = new InvoiceEditHandler($stateMachine, $recurringStateMachine, $router, M::mock(MailerInterface::class));
$mailer = M::mock(MailerInterface::class);
$mailer->shouldReceive('send')
->zeroOrMoreTimes()
->with(M::type(InvoiceEmail::class));

$handler = new InvoiceEditHandler($stateMachine, $recurringStateMachine, $router, $mailer);
$handler->setDoctrine($this->registry);

return $handler;
Expand Down
15 changes: 11 additions & 4 deletions src/MailerBundle/Factory/MailerConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use SolidInvoice\SettingsBundle\SystemConfig;
use Symfony\Component\Mailer\Transport;
use Symfony\Component\Mailer\Transport\TransportInterface;
use function json_decode;

/**
* @see \SolidInvoice\MailerBundle\Tests\Factory\MailerConfigFactoryTest
Expand All @@ -27,14 +28,14 @@ final class MailerConfigFactory
{
private const CONFIG_KEY = 'email/sending_options/provider';

private $config;
private SystemConfig $config;

private $inner;
private Transport $inner;

/**
* @var ConfiguratorInterface[]
*/
private $transports;
private iterable $transports;

public function __construct(Transport $inner, SystemConfig $config, iterable $transports)
{
Expand All @@ -48,7 +49,13 @@ public function __construct(Transport $inner, SystemConfig $config, iterable $tr
*/
public function fromStrings(): TransportInterface
{
$config = \json_decode($this->config->get(self::CONFIG_KEY), true, 512, JSON_THROW_ON_ERROR);
$config = $this->config->get(self::CONFIG_KEY);

if (null === $config) {
return $this->inner->fromString('null://null');
}

$config = json_decode($this->config->get(self::CONFIG_KEY), true, 512, JSON_THROW_ON_ERROR);
$provider = $config['provider'] ?? '';

foreach ($this->transports as $transport) {
Expand Down

0 comments on commit 786163a

Please sign in to comment.