1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2018-2023 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Aimeos\Controller\Jobs\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 = \TestHelper::context(); |
28
|
|
|
|
29
|
|
|
$mailStub = $this->getMockBuilder( '\\Aimeos\\Base\\Mail\\None' ) |
30
|
|
|
->disableOriginalConstructor() |
31
|
|
|
->getMock(); |
32
|
|
|
|
33
|
|
|
$mailMsgStub = $this->getMockBuilder( '\\Aimeos\\Base\\Mail\\Message\\None' ) |
34
|
|
|
->disableOriginalConstructor() |
35
|
|
|
->disableOriginalClone() |
36
|
|
|
->getMock(); |
37
|
|
|
|
38
|
|
|
$mailStub->expects( $this->once() )->method( 'create' )->will( $this->returnValue( $mailMsgStub ) ); |
39
|
|
|
|
40
|
|
|
$context->setMail( $mailStub ); |
41
|
|
|
$subscription = $this->getSubscription()->setReason( \Aimeos\MShop\Subscription\Item\Iface::REASON_PAYMENT ); |
42
|
|
|
|
43
|
|
|
$object = new \Aimeos\Controller\Jobs\Common\Subscription\Process\Processor\Email\Standard( $context ); |
44
|
|
|
$object->renewAfter( $subscription, $subscription->getOrderItem() ); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
public function testEnd() |
49
|
|
|
{ |
50
|
|
|
$context = \TestHelper::context(); |
51
|
|
|
|
52
|
|
|
$mailStub = $this->getMockBuilder( '\\Aimeos\\Base\\Mail\\None' ) |
53
|
|
|
->disableOriginalConstructor() |
54
|
|
|
->getMock(); |
55
|
|
|
|
56
|
|
|
$mailMsgStub = $this->getMockBuilder( '\\Aimeos\\Base\\Mail\\Message\\None' ) |
57
|
|
|
->disableOriginalConstructor() |
58
|
|
|
->disableOriginalClone() |
59
|
|
|
->getMock(); |
60
|
|
|
|
61
|
|
|
$mailStub->expects( $this->once() )->method( 'create' )->will( $this->returnValue( $mailMsgStub ) ); |
62
|
|
|
|
63
|
|
|
$subscription = $this->getSubscription(); |
64
|
|
|
$context->setMail( $mailStub ); |
65
|
|
|
|
66
|
|
|
$object = new \Aimeos\Controller\Jobs\Common\Subscription\Process\Processor\Email\Standard( $context ); |
67
|
|
|
$object->end( $subscription, $subscription->getOrderItem() ); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
protected function getSubscription() |
72
|
|
|
{ |
73
|
|
|
$manager = \Aimeos\MShop::create( \TestHelper::context(), 'subscription' ); |
74
|
|
|
$search = $manager->filter()->add( ['subscription.dateend' => '2010-01-01'] ); |
75
|
|
|
$domains = ['order', 'order/address', 'order/coupon', 'order/product', 'order/service']; |
76
|
|
|
|
77
|
|
|
return $manager->search( $search, $domains )->first( new \Exception( 'No subscription item found' ) ); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|