|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2018-2020 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace Aimeos\Controller\Common\Subscription\Process\Processor\Email; |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
protected function setUp() : void |
|
14
|
|
|
{ |
|
15
|
|
|
\Aimeos\MShop::cache( true ); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
protected function tearDown() : void |
|
20
|
|
|
{ |
|
21
|
|
|
\Aimeos\MShop::cache( false ); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
public function testRenewAfter() |
|
26
|
|
|
{ |
|
27
|
|
|
$context = \TestHelperCntl::getContext(); |
|
28
|
|
|
|
|
29
|
|
|
$mailStub = $this->getMockBuilder( '\\Aimeos\\MW\\Mail\\None' ) |
|
30
|
|
|
->disableOriginalConstructor() |
|
31
|
|
|
->getMock(); |
|
32
|
|
|
|
|
33
|
|
|
$mailMsgStub = $this->getMockBuilder( '\\Aimeos\\MW\\Mail\\Message\\None' ) |
|
34
|
|
|
->disableOriginalConstructor() |
|
35
|
|
|
->disableOriginalClone() |
|
36
|
|
|
->getMock(); |
|
37
|
|
|
|
|
38
|
|
|
$mailStub->expects( $this->once() ) |
|
39
|
|
|
->method( 'createMessage' ) |
|
40
|
|
|
->will( $this->returnValue( $mailMsgStub ) ); |
|
41
|
|
|
|
|
42
|
|
|
$context->setMail( $mailStub ); |
|
43
|
|
|
$subscription = $this->getSubscription( $context )->setReason( \Aimeos\MShop\Subscription\Item\Iface::REASON_PAYMENT ); |
|
44
|
|
|
$order = \Aimeos\MShop::create( $context, 'order' )->createItem(); |
|
45
|
|
|
|
|
46
|
|
|
$object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Email\Standard( $context ); |
|
47
|
|
|
$object->renewAfter( $subscription, $order ); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
public function testEnd() |
|
52
|
|
|
{ |
|
53
|
|
|
$context = \TestHelperCntl::getContext(); |
|
54
|
|
|
|
|
55
|
|
|
$mailStub = $this->getMockBuilder( '\\Aimeos\\MW\\Mail\\None' ) |
|
56
|
|
|
->disableOriginalConstructor() |
|
57
|
|
|
->getMock(); |
|
58
|
|
|
|
|
59
|
|
|
$mailMsgStub = $this->getMockBuilder( '\\Aimeos\\MW\\Mail\\Message\\None' ) |
|
60
|
|
|
->disableOriginalConstructor() |
|
61
|
|
|
->disableOriginalClone() |
|
62
|
|
|
->getMock(); |
|
63
|
|
|
|
|
64
|
|
|
$mailStub->expects( $this->once() ) |
|
65
|
|
|
->method( 'createMessage' ) |
|
66
|
|
|
->will( $this->returnValue( $mailMsgStub ) ); |
|
67
|
|
|
|
|
68
|
|
|
$context->setMail( $mailStub ); |
|
69
|
|
|
|
|
70
|
|
|
$object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Email\Standard( $context ); |
|
71
|
|
|
$object->end( $this->getSubscription( $context ) ); |
|
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
protected function getSubscription( $context ) |
|
76
|
|
|
{ |
|
77
|
|
|
$manager = \Aimeos\MShop::create( $context, 'subscription' ); |
|
78
|
|
|
|
|
79
|
|
|
$search = $manager->createSearch(); |
|
80
|
|
|
$search->setConditions( $search->compare( '==', 'subscription.dateend', '2010-01-01' ) ); |
|
81
|
|
|
|
|
82
|
|
|
if( ( $item = $manager->searchItems( $search )->first() ) === null ) { |
|
83
|
|
|
throw new \Exception( 'No subscription item found' ); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
return $item; |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|