StandardTest::tearDown()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2025
6
 */
7
8
9
namespace Aimeos\Client\Html\Checkout\Standard\Process\Account;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
	private $context;
16
	private $view;
17
18
19
	protected function setUp() : void
20
	{
21
		\Aimeos\Controller\Frontend::cache( true );
22
		\Aimeos\MShop::cache( true );
23
24
		$this->view = \TestHelper::view();
25
		$this->context = \TestHelper::context();
26
27
		$this->object = new \Aimeos\Client\Html\Checkout\Standard\Process\Account\Standard( $this->context );
28
		$this->object->setView( $this->view );
29
	}
30
31
32
	protected function tearDown() : void
33
	{
34
		\Aimeos\Controller\Frontend::create( $this->context, 'basket' )->clear();
35
		\Aimeos\Controller\Frontend::cache( false );
36
		\Aimeos\MShop::cache( false );
37
38
		unset( $this->object, $this->context, $this->view );
39
	}
40
41
42
	public function testBody()
43
	{
44
		$this->view = \TestHelper::view();
45
		$this->object->setView( $this->object->data( $this->view ) );
46
47
		$output = $this->object->body();
48
		$this->assertNotNull( $output );
49
	}
50
51
52
	public function testInit()
53
	{
54
		$customerItem = \Aimeos\MShop::create( $this->context, 'customer' )->find( '[email protected]' );
55
		$address = $customerItem->getPaymentAddress()->setEmail( '[email protected]' )->toArray();
56
57
		$basketCntl = \Aimeos\Controller\Frontend::create( $this->context, 'basket' );
58
		$basketCntl->addAddress( \Aimeos\MShop\Order\Item\Address\Base::TYPE_PAYMENT, $address );
59
60
		$this->view = \TestHelper::view();
61
		$helper = new \Aimeos\Base\View\Helper\Param\Standard( $this->view, array( 'cs_option_account' => 1 ) );
62
		$this->view->addHelper( 'param', $helper );
63
		$this->object->setView( $this->view );
64
65
		$customerStub = $this->getMockBuilder( \Aimeos\Controller\Frontend\Customer\Standard::class )
66
			->setConstructorArgs( array( $this->context ) )
67
			->onlyMethods( array( 'add', 'get', 'store' ) )
68
			->getMock();
69
70
		$customerStub->expects( $this->once() )->method( 'add' )->willReturn( $customerStub );
71
		$customerStub->expects( $this->once() )->method( 'store' )->willReturn( $customerStub );
72
		$customerStub->expects( $this->once() )->method( 'get' )->willReturn( $customerItem );
73
74
		\Aimeos\Controller\Frontend::inject( \Aimeos\Controller\Frontend\Customer\Standard::class, $customerStub );
75
76
		$this->object->init();
77
	}
78
}
79