mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-14 04:00:57 +03:00
Reduced duplicated code in NotifyNewShortUrlToRabbitMqTest
This commit is contained in:
parent
19b0f0d7dc
commit
cd27a72982
1 changed files with 5 additions and 9 deletions
|
@ -31,34 +31,30 @@ class NotifyNewShortUrlToRabbitMqTest extends TestCase
|
|||
private ObjectProphecy $helper;
|
||||
private ObjectProphecy $em;
|
||||
private ObjectProphecy $logger;
|
||||
private RabbitMqOptions $options;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->helper = $this->prophesize(RabbitMqPublishingHelperInterface::class);
|
||||
$this->em = $this->prophesize(EntityManagerInterface::class);
|
||||
$this->logger = $this->prophesize(LoggerInterface::class);
|
||||
$this->options = new RabbitMqOptions(['enabled' => true]);
|
||||
|
||||
$this->listener = new NotifyNewShortUrlToRabbitMq(
|
||||
$this->helper->reveal(),
|
||||
$this->em->reveal(),
|
||||
$this->logger->reveal(),
|
||||
new ShortUrlDataTransformer(new ShortUrlStringifier([])),
|
||||
new RabbitMqOptions(['enabled' => true]),
|
||||
$this->options,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function doesNothingWhenTheFeatureIsNotEnabled(): void
|
||||
{
|
||||
$listener = new NotifyNewShortUrlToRabbitMq(
|
||||
$this->helper->reveal(),
|
||||
$this->em->reveal(),
|
||||
$this->logger->reveal(),
|
||||
new ShortUrlDataTransformer(new ShortUrlStringifier([])),
|
||||
new RabbitMqOptions(['enabled' => false]),
|
||||
);
|
||||
$this->options->enabled = false;
|
||||
|
||||
$listener(new ShortUrlCreated('123'));
|
||||
($this->listener)(new ShortUrlCreated('123'));
|
||||
|
||||
$this->em->find(Argument::cetera())->shouldNotHaveBeenCalled();
|
||||
$this->logger->warning(Argument::cetera())->shouldNotHaveBeenCalled();
|
||||
|
|
Loading…
Add table
Reference in a new issue