-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
DynamicContentHelperTest.php
80 lines (70 loc) · 2.66 KB
/
DynamicContentHelperTest.php
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
74
75
76
77
78
79
80
<?php
declare(strict_types=1);
/*
* @copyright 2017 Mautic Contributors. All rights reserved
* @author Mautic
*
* @link http://mautic.org
*
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
namespace Mautic\DynamicContentBundle\Tests\Helper;
use Mautic\CampaignBundle\Executioner\RealTimeExecutioner;
use Mautic\DynamicContentBundle\Helper\DynamicContentHelper;
use Mautic\DynamicContentBundle\Model\DynamicContentModel;
use Symfony\Component\EventDispatcher\EventDispatcher;
class DynamicContentHelperTest extends \PHPUnit\Framework\TestCase
{
public function testGetDwcBySlotNameWithPublished(): void
{
$mockModel = $this->getMockBuilder(DynamicContentModel::class)
->disableOriginalConstructor()
->onlyMethods(['getEntities'])
->getMock();
$mockModel->expects($this->exactly(2))
->method('getEntities')
->withConsecutive(
[
[
'filter' => [
'where' => [
[
'col' => 'e.slotName',
'expr' => 'eq',
'val' => 'test',
],
[
'col' => 'e.isPublished',
'expr' => 'eq',
'val' => 1,
],
],
],
'ignore_paginator' => true,
],
],
[
[
'filter' => [
'where' => [
[
'col' => 'e.slotName',
'expr' => 'eq',
'val' => 'secondtest',
],
],
],
'ignore_paginator' => true,
],
]
)
->willReturnOnConsecutiveCalls(true, false);
$realTimeExecutioner = $this->createMock(RealTimeExecutioner::class);
$mockDispatcher = $this->createMock(EventDispatcher::class);
$fixture = new DynamicContentHelper($mockModel, $realTimeExecutioner, $mockDispatcher);
// Only get published
$this->assertTrue($fixture->getDwcsBySlotName('test', true));
// Get all
$this->assertFalse($fixture->getDwcsBySlotName('secondtest'));
}
}