Spaces:
No application file
No application file
File size: 2,486 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 61 62 63 64 65 66 67 68 69 70 71 72 73 |
<?php
namespace Mautic\CampaignBundle\Tests\Executioner\ContactFinder\Limiter;
use Mautic\CampaignBundle\Executioner\ContactFinder\Limiter\ContactLimiter;
use Mautic\CampaignBundle\Executioner\Exception\NoContactsFoundException;
class ContactLimiterTest extends \PHPUnit\Framework\TestCase
{
public function testGetters(): void
{
$limiter = new ContactLimiter(1, 2, 3, 4, [1, 2, 3]);
$this->assertEquals(1, $limiter->getBatchLimit());
$this->assertEquals(2, $limiter->getContactId());
$this->assertEquals(3, $limiter->getMinContactId());
$this->assertEquals(4, $limiter->getMaxContactId());
$this->assertEquals([1, 2, 3], $limiter->getContactIdList());
}
public function testBatchMinContactIsReturned(): void
{
$limiter = new ContactLimiter(1, 2, 3, 10, [1, 2, 3]);
$limiter->setBatchMinContactId(5);
$this->assertEquals(5, $limiter->getMinContactId());
}
public function testNoContactsFoundExceptionThrownIfIdIsLessThanMin(): void
{
$this->expectException(NoContactsFoundException::class);
$limiter = new ContactLimiter(1, 2, 3, 10, [1, 2, 3]);
$limiter->setBatchMinContactId(1);
}
public function testNoContactsFoundExceptionThrownIfIdIsMoreThanMax(): void
{
$this->expectException(NoContactsFoundException::class);
$limiter = new ContactLimiter(1, 2, 3, 10, [1, 2, 3]);
$limiter->setBatchMinContactId(11);
}
public function testNoContactsFoundExceptionThrownIfIdIsTheSameAsLastBatch(): void
{
$this->expectException(NoContactsFoundException::class);
$limiter = new ContactLimiter(1, 2, 3, 10, [1, 2, 3]);
$limiter->setBatchMinContactId(5);
$limiter->setBatchMinContactId(5);
}
public function testExceptionNotThrownIfIdEqualsMinSoThatItsIsIncluded(): void
{
$limiter = new ContactLimiter(1, 2, 3, 10, [1, 2, 3]);
$this->assertSame($limiter, $limiter->setBatchMinContactId(3));
}
public function testExceptionNotThrownIfIdEqualsMaxSoThatItsIsIncluded(): void
{
$limiter = new ContactLimiter(1, 2, 3, 10, [1, 2, 3]);
$this->assertSame($limiter, $limiter->setBatchMinContactId(10));
}
public function testExceptionThrownIfThreadIdLargerThanMaxThreads(): void
{
$this->expectException(\InvalidArgumentException::class);
new ContactLimiter(1, null, null, null, [], 5, 3);
}
}
|