@@ 22-47 (lines=26) @@ | ||
19 | $this->assertContains('Mailgun accepted the request to send/forward the email and the message has been placed in queue.', $display); |
|
20 | } |
|
21 | ||
22 | public function testDeleteOldEntries_WithoutParams() |
|
23 | { |
|
24 | $application = new Application(); |
|
25 | $application->add(new DeleteOldEntriesCommand()); |
|
26 | $command = $this->getDeleteOldEntriesCommand($application); |
|
27 | ||
28 | $mailgunServiceMock = $this->getMockBuilder("Azine\MailgunWebhooksBundle\Services\AzineMailgunService")->disableOriginalConstructor()->getMock(); |
|
29 | self::$days = 60; |
|
30 | self::$count = 14; |
|
31 | self::$type = null; |
|
32 | $mailgunServiceMock->expects($this->once())->method('removeEvents')->will($this->returnCallback(array($this, 'removeEventsCallback'))); |
|
33 | ||
34 | $containerMock = $this->getMockBuilder("Symfony\Component\DependencyInjection\ContainerInterface")->disableOriginalConstructor()->getMock(); |
|
35 | $containerMock->expects($this->once())->method('get')->with('azine_mailgun.service')->will($this->returnValue($mailgunServiceMock)); |
|
36 | ||
37 | $command->setContainer($containerMock); |
|
38 | $tester = new CommandTester($command); |
|
39 | ||
40 | $tester->execute(array('')); |
|
41 | $display = $tester->getDisplay(); |
|
42 | $this->assertContains('deleting entries of any type.', $display); |
|
43 | $this->assertContains("using default age-limit of '60 days ago'.", $display); |
|
44 | $this->assertContains('All MailgunEvents (& their CustomVariables & Attachments) older than', $display); |
|
45 | $this->assertContains('of any type have been deleted (14).', $display); |
|
46 | } |
|
47 | ||
48 | public static $days; |
|
49 | public static $count; |
|
50 | public static $type; |
|
@@ 71-94 (lines=24) @@ | ||
68 | return $application->find('mailgun:delete-events'); |
|
69 | } |
|
70 | ||
71 | public function testDeleteOldEntries_WithDate() |
|
72 | { |
|
73 | $application = new Application(); |
|
74 | $application->add(new DeleteOldEntriesCommand()); |
|
75 | $command = $this->getDeleteOldEntriesCommand($application); |
|
76 | ||
77 | $mailgunServiceMock = $this->getMockBuilder("Azine\MailgunWebhooksBundle\Services\AzineMailgunService")->disableOriginalConstructor()->getMock(); |
|
78 | self::$days = 21; |
|
79 | self::$count = 11; |
|
80 | self::$type = null; |
|
81 | $mailgunServiceMock->expects($this->once())->method('removeEvents')->will($this->returnCallback(array($this, 'removeEventsCallback'))); |
|
82 | ||
83 | $containerMock = $this->getMockBuilder("Symfony\Component\DependencyInjection\ContainerInterface")->disableOriginalConstructor()->getMock(); |
|
84 | $containerMock->expects($this->once())->method('get')->with('azine_mailgun.service')->will($this->returnValue($mailgunServiceMock)); |
|
85 | ||
86 | $command->setContainer($containerMock); |
|
87 | $tester = new CommandTester($command); |
|
88 | ||
89 | $tester->execute(array('date' => '21 days ago')); |
|
90 | $display = $tester->getDisplay(); |
|
91 | $this->assertContains('deleting entries of any type.', $display); |
|
92 | $this->assertContains('All MailgunEvents (& their CustomVariables & Attachments) older than', $display); |
|
93 | $this->assertContains('of any type have been deleted (11).', $display); |
|
94 | } |
|
95 | ||
96 | public function testDeleteOldEntries_WithDateAndType() |
|
97 | { |