Passed
Push — master ( f0002b...c777f5 )
by Aimeos
08:04 queued 04:27
created

StandardTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 33
dl 0
loc 67
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscription() 0 7 1
A testRenewAfter() 0 20 1
A tearDown() 0 3 1
A setUp() 0 3 1
A testEnd() 0 20 1
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