|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2014 |
|
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2022 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
namespace Aimeos\Controller\Jobs\Customer\Email\Account; |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
private $object; |
|
16
|
|
|
private $context; |
|
17
|
|
|
private $aimeos; |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
|
|
protected function setUp() : void |
|
21
|
|
|
{ |
|
22
|
|
|
$this->context = \TestHelperJobs::context(); |
|
23
|
|
|
$this->aimeos = \TestHelperJobs::getAimeos(); |
|
24
|
|
|
|
|
25
|
|
|
$this->object = new \Aimeos\Controller\Jobs\Customer\Email\Account\Standard( $this->context, $this->aimeos ); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
protected function tearDown() : void |
|
30
|
|
|
{ |
|
31
|
|
|
$this->object = null; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
public function testGetName() |
|
36
|
|
|
{ |
|
37
|
|
|
$this->assertEquals( 'Customer account e-mails', $this->object->getName() ); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
public function testGetDescription() |
|
42
|
|
|
{ |
|
43
|
|
|
$text = 'Sends e-mails for new customer accounts'; |
|
44
|
|
|
$this->assertEquals( $text, $this->object->getDescription() ); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
public function testRun() |
|
49
|
|
|
{ |
|
50
|
|
|
$mailStub = $this->getMockBuilder( '\\Aimeos\\Base\\Mail\\None' ) |
|
51
|
|
|
->disableOriginalConstructor() |
|
52
|
|
|
->getMock(); |
|
53
|
|
|
|
|
54
|
|
|
$mailMsgStub = $this->getMockBuilder( '\\Aimeos\\Base\\Mail\\Message\\None' ) |
|
55
|
|
|
->disableOriginalConstructor() |
|
56
|
|
|
->disableOriginalClone() |
|
57
|
|
|
->setMethods( ['send'] ) |
|
58
|
|
|
->getMock(); |
|
59
|
|
|
|
|
60
|
|
|
$mailStub->expects( $this->once() )->method( 'create' )->will( $this->returnValue( $mailMsgStub ) ); |
|
61
|
|
|
$mailMsgStub->expects( $this->once() )->method( 'send' ); |
|
62
|
|
|
|
|
63
|
|
|
$this->context->setMail( $mailStub ); |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
$queueStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Queue\\Standard' ) |
|
67
|
|
|
->disableOriginalConstructor() |
|
68
|
|
|
->getMock(); |
|
69
|
|
|
|
|
70
|
|
|
$queueStub->expects( $this->exactly( 2 ) )->method( 'get' ) |
|
71
|
|
|
->will( $this->onConsecutiveCalls( new \Aimeos\MW\MQueue\Message\Standard( array( 'message' => '{"customer.languageid": "de"}' ) ), null ) ); |
|
72
|
|
|
|
|
73
|
|
|
$queueStub->expects( $this->once() )->method( 'del' ); |
|
74
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
$mqueueStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Standard' ) |
|
77
|
|
|
->disableOriginalConstructor() |
|
78
|
|
|
->getMock(); |
|
79
|
|
|
|
|
80
|
|
|
$mqueueStub->expects( $this->once() )->method( 'getQueue' ) |
|
81
|
|
|
->will( $this->returnValue( $queueStub ) ); |
|
82
|
|
|
|
|
83
|
|
|
|
|
84
|
|
|
$managerStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Manager\\Standard' ) |
|
85
|
|
|
->disableOriginalConstructor() |
|
86
|
|
|
->getMock(); |
|
87
|
|
|
|
|
88
|
|
|
$managerStub->expects( $this->once() )->method( 'get' ) |
|
89
|
|
|
->will( $this->returnValue( $mqueueStub ) ); |
|
90
|
|
|
|
|
91
|
|
|
$this->context->setMessageQueueManager( $managerStub ); |
|
92
|
|
|
|
|
93
|
|
|
|
|
94
|
|
|
$object = new \Aimeos\Controller\Jobs\Customer\Email\Account\Standard( $this->context, $this->aimeos ); |
|
95
|
|
|
$object->run(); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
|
|
99
|
|
|
public function testRunException() |
|
100
|
|
|
{ |
|
101
|
|
|
$queueStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Queue\\Standard' ) |
|
102
|
|
|
->disableOriginalConstructor() |
|
103
|
|
|
->getMock(); |
|
104
|
|
|
|
|
105
|
|
|
$queueStub->expects( $this->exactly( 2 ) )->method( 'get' ) |
|
106
|
|
|
->will( $this->onConsecutiveCalls( new \Aimeos\MW\MQueue\Message\Standard( array( 'message' => 'error' ) ), null ) ); |
|
107
|
|
|
|
|
108
|
|
|
$queueStub->expects( $this->once() )->method( 'del' ); |
|
109
|
|
|
|
|
110
|
|
|
|
|
111
|
|
|
$mqueueStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Standard' ) |
|
112
|
|
|
->disableOriginalConstructor() |
|
113
|
|
|
->getMock(); |
|
114
|
|
|
|
|
115
|
|
|
$mqueueStub->expects( $this->once() )->method( 'getQueue' ) |
|
116
|
|
|
->will( $this->returnValue( $queueStub ) ); |
|
117
|
|
|
|
|
118
|
|
|
|
|
119
|
|
|
$managerStub = $this->getMockBuilder( '\\Aimeos\\MW\\MQueue\\Manager\\Standard' ) |
|
120
|
|
|
->disableOriginalConstructor() |
|
121
|
|
|
->getMock(); |
|
122
|
|
|
|
|
123
|
|
|
$managerStub->expects( $this->once() )->method( 'get' ) |
|
124
|
|
|
->will( $this->returnValue( $mqueueStub ) ); |
|
125
|
|
|
|
|
126
|
|
|
$this->context->setMessageQueueManager( $managerStub ); |
|
127
|
|
|
|
|
128
|
|
|
|
|
129
|
|
|
$this->object->run(); |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|