1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * @copyright 2017 Mautic Contributors. All rights reserved |
||
7 | * @author Mautic, Inc. |
||
8 | * |
||
9 | * @link https://mautic.org |
||
10 | * |
||
11 | * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html |
||
12 | */ |
||
13 | |||
14 | namespace Mautic\CampaignBundle\Tests\Model; |
||
15 | |||
16 | use Mautic\CampaignBundle\Entity\LeadEventLogRepository; |
||
17 | use Mautic\CampaignBundle\Model\EventModel; |
||
18 | use PHPUnit\Framework\TestCase; |
||
19 | |||
20 | class EventModelTest extends TestCase |
||
21 | { |
||
22 | /** |
||
23 | * @var LeadEventLogRepository |
||
24 | */ |
||
25 | private $leadEventLogRepository; |
||
26 | |||
27 | /** |
||
28 | * @var EventModel |
||
29 | */ |
||
30 | private $eventModel; |
||
31 | |||
32 | protected function setUp(): void |
||
33 | { |
||
34 | $this->eventModel = $this->getMockBuilder(EventModel::class) |
||
0 ignored issues
–
show
|
|||
35 | ->disableOriginalConstructor() |
||
36 | ->setMethods([ |
||
37 | 'getRepository', |
||
38 | 'getLeadEventLogRepository', |
||
39 | 'deleteEntities', |
||
40 | ]) |
||
41 | ->getMock(); |
||
42 | |||
43 | $this->leadEventLogRepository = $this->createMock(LeadEventLogRepository::class); |
||
44 | } |
||
45 | |||
46 | public function testThatClonedEventsDoNotAttemptNullingParentInDeleteEvents(): void |
||
47 | { |
||
48 | $this->eventModel->expects($this->exactly(0)) |
||
49 | ->method('getRepository') |
||
50 | ->willReturn($this->leadEventLogRepository); |
||
51 | |||
52 | $currentEvents = [ |
||
53 | 'new1', |
||
54 | 'new2', |
||
55 | 'new3', |
||
56 | ]; |
||
57 | |||
58 | $deletedEvents = [ |
||
59 | 'new1', |
||
60 | ]; |
||
61 | |||
62 | $this->eventModel->deleteEvents($currentEvents, $deletedEvents); |
||
63 | } |
||
64 | |||
65 | public function testThatItDeletesEventLogs(): void |
||
66 | { |
||
67 | $idToDelete = 'old1'; |
||
68 | |||
69 | $this->eventModel->expects($this->once()) |
||
70 | ->method('getRepository') |
||
71 | ->willReturn($this->leadEventLogRepository); |
||
72 | |||
73 | $this->eventModel->expects($this->once()) |
||
74 | ->method('getLeadEventLogRepository') |
||
75 | ->willReturn($this->leadEventLogRepository); |
||
76 | |||
77 | $this->leadEventLogRepository->expects($this->once()) |
||
78 | ->method('removeEventLogs') |
||
79 | ->with($idToDelete); |
||
80 | |||
81 | $this->eventModel->expects($this->once()) |
||
82 | ->method('deleteEntities') |
||
83 | ->with([$idToDelete]); |
||
84 | |||
85 | $currentEvents = [ |
||
86 | 'new1', |
||
87 | ]; |
||
88 | |||
89 | $deletedEvents = [ |
||
90 | 'new1', |
||
91 | $idToDelete, |
||
92 | ]; |
||
93 | |||
94 | $this->eventModel->deleteEvents($currentEvents, $deletedEvents); |
||
95 | } |
||
96 | } |
||
97 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.