Spaces:
No application file
No application file
File size: 1,902 Bytes
d2897cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
<?php
namespace Mautic\ChannelBundle\Tests\Event;
use Mautic\ChannelBundle\Event\ChannelBroadcastEvent;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\OutputInterface;
class ChannelBroadcastEventTest extends TestCase
{
private string $channel;
private int $channelId;
private OutputInterface $output;
protected function setUp(): void
{
$this->channel = 'email';
$this->channelId = 1;
$this->output = new BufferedOutput();
}
public function testConstructorAndGetters(): void
{
$event = new ChannelBroadcastEvent($this->channel, $this->channelId, $this->output);
$this->assertSame($this->channel, $event->getChannel());
$this->assertSame($this->channelId, $event->getId());
$this->assertSame($this->output, $event->getOutput());
}
public function testResults(): void
{
$event = new ChannelBroadcastEvent($this->channel, $this->channelId, $this->output);
$successCount = 10;
$failedCount = 2;
$failedRecipientsByList = ['list1' => ['[email protected]', '[email protected]']];
$event->setResults($this->channel, $successCount, $failedCount, $failedRecipientsByList);
$this->assertSame([
$this->channel => [
'success' => $successCount,
'failed' => $failedCount,
'failedRecipientsByList' => $failedRecipientsByList,
],
], $event->getResults());
}
public function testCheckContext(): void
{
$event = new ChannelBroadcastEvent($this->channel, $this->channelId, $this->output);
$this->assertTrue($event->checkContext('email'));
$this->assertFalse($event->checkContext('sms'));
}
}
|