Passed
Push — master ( 23e72e...dc62e4 )
by Aimeos
03:22
created

StandardTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 32
c 1
b 0
f 0
dl 0
loc 66
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscription() 0 6 1
A testEnd() 0 19 1
A tearDown() 0 3 1
A testRenewAfter() 0 21 1
A setUp() 0 3 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2018-2022
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::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
		$order = \Aimeos\MShop::create( $context, 'order' )->create();
42
		$subscription = $this->getSubscription()->setReason( \Aimeos\MShop\Subscription\Item\Iface::REASON_PAYMENT );
43
44
		$object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Email\Standard( $context );
45
		$object->renewAfter( $subscription, $order );
46
	}
47
48
49
	public function testEnd()
50
	{
51
		$context = \TestHelperCntl::context();
52
53
		$mailStub = $this->getMockBuilder( '\\Aimeos\\Base\\Mail\\None' )
54
			->disableOriginalConstructor()
55
			->getMock();
56
57
		$mailMsgStub = $this->getMockBuilder( '\\Aimeos\\Base\\Mail\\Message\\None' )
58
			->disableOriginalConstructor()
59
			->disableOriginalClone()
60
			->getMock();
61
62
		$mailStub->expects( $this->once() )->method( 'create' )->will( $this->returnValue( $mailMsgStub ) );
63
64
		$context->setMail( $mailStub );
65
66
		$object = new \Aimeos\Controller\Common\Subscription\Process\Processor\Email\Standard( $context );
67
		$object->end( $this->getSubscription() );
68
	}
69
70
71
	protected function getSubscription()
72
	{
73
		$manager = \Aimeos\MShop::create( \TestHelperCntl::context(), 'subscription' );
74
		$search = $manager->filter()->add( ['subscription.dateend' => '2010-01-01'] );
75
76
		return $manager->search( $search )->first( new \RuntimeException( 'No subscription item found' ) );
77
	}
78
}
79