StandardTest::tearDown()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2013
6
 * @copyright Aimeos (aimeos.org), 2015-2025
7
 */
8
9
10
namespace Aimeos\Client\Html\Checkout\Standard;
11
12
13
class StandardTest extends \PHPUnit\Framework\TestCase
14
{
15
	private $object;
16
	private $context;
17
	private $view;
18
19
20
	protected function setUp() : void
21
	{
22
		\Aimeos\Controller\Frontend::cache( true );
23
		\Aimeos\MShop::cache( true );
24
25
		$this->view = \TestHelper::view();
26
		$this->context = \TestHelper::context();
27
		$this->context->setUser( \Aimeos\MShop::create( $this->context, 'customer' )->find( '[email protected]' ) );
28
29
		$this->object = new \Aimeos\Client\Html\Checkout\Standard\Standard( $this->context );
30
		$this->object->setView( $this->view );
31
	}
32
33
34
	protected function tearDown() : void
35
	{
36
		\Aimeos\Controller\Frontend::cache( false );
37
		\Aimeos\MShop::cache( false );
38
39
		unset( $this->object, $this->context, $this->view );
40
	}
41
42
43
	public function testHeader()
44
	{
45
		$tags = [];
46
		$expire = null;
47
48
		$this->object->setView( $this->object->data( $this->view, $tags, $expire ) );
49
		$output = $this->object->header();
50
51
		$this->assertStringContainsString( '<title>summary | Aimeos</title>', $output );
52
	}
53
54
55
	public function testBody()
56
	{
57
		$this->view->standardStepActive = 'address';
58
59
		$helper = new \Aimeos\Base\View\Helper\Param\Standard( $this->view, array( 'c_step' => 'payment' ) );
60
		$this->view->addHelper( 'param', $helper );
61
62
		$output = $this->object->body();
63
64
		$this->assertStringStartsWith( '<div class="section aimeos checkout-standard"', $output );
65
		$this->assertMatchesRegularExpression( '#<ol class="steps">.*<li class="step.*>.*</li>.*</ol>#smU', $output );
66
		$this->assertStringContainsString( '<div class="section checkout-standard-address', $output );
67
		$this->assertStringNotContainsString( '<div class="section checkout-standard-delivery', $output );
68
		$this->assertStringNotContainsString( '<div class="section checkout-standard-payment', $output );
69
		$this->assertStringNotContainsString( '<div class="section checkout-standard-summary', $output );
70
		$this->assertStringNotContainsString( '<div class="section checkout-standard-order', $output );
71
	}
72
73
74
	public function testBodyOnepage()
75
	{
76
77
		$config = $this->context->config();
78
		$config->set( 'client/html/checkout/standard/onepage', array( 'address', 'delivery', 'payment', 'summary' ) );
79
80
		$helper = new \Aimeos\Base\View\Helper\Config\Standard( $this->view, $config );
81
		$this->view->addHelper( 'config', $helper );
82
83
		$output = $this->object->body();
84
85
		$this->assertStringContainsString( '<div class="section checkout-standard-address', $output );
86
		$this->assertStringContainsString( '<div class="section checkout-standard-delivery', $output );
87
		$this->assertStringContainsString( '<div class="section checkout-standard-payment', $output );
88
		$this->assertStringContainsString( '<div class="section checkout-standard-summary', $output );
89
		$this->assertStringNotContainsString( '<div class="section checkout-standard-order', $output );
90
	}
91
92
93
	public function testBodyOnepagePartitial()
94
	{
95
		$this->view->standardStepActive = 'delivery';
96
97
		$config = $this->context->config();
98
		$config->set( 'client/html/checkout/standard/onepage', array( 'delivery', 'payment' ) );
99
100
		$helper = new \Aimeos\Base\View\Helper\Config\Standard( $this->view, $config );
101
		$this->view->addHelper( 'config', $helper );
102
103
		$output = $this->object->body();
104
105
		$this->assertStringContainsString( '<div class="section checkout-standard-delivery', $output );
106
		$this->assertStringContainsString( '<div class="section checkout-standard-payment', $output );
107
		$this->assertStringNotContainsString( '<div class="section checkout-standard-address', $output );
108
		$this->assertStringNotContainsString( '<div class="section checkout-standard-summary', $output );
109
		$this->assertStringNotContainsString( '<div class="section checkout-standard-order', $output );
110
	}
111
112
113
	public function testBodyOnepageDifferentStep()
114
	{
115
		$this->view->standardStepActive = 'address';
116
117
		$config = $this->context->config();
118
		$config->set( 'client/html/checkout/standard/onepage', array( 'delivery', 'payment' ) );
119
120
		$helper = new \Aimeos\Base\View\Helper\Config\Standard( $this->view, $config );
121
		$this->view->addHelper( 'config', $helper );
122
123
		$output = $this->object->body();
124
125
		$this->assertStringContainsString( '<div class="section checkout-standard-address', $output );
126
		$this->assertStringNotContainsString( '<div class="section checkout-standard-delivery', $output );
127
		$this->assertStringNotContainsString( '<div class="section checkout-standard-payment', $output );
128
		$this->assertStringNotContainsString( '<div class="section checkout-standard-summary', $output );
129
		$this->assertStringNotContainsString( '<div class="section checkout-standard-order', $output );
130
	}
131
132
133
	public function testGetSubClient()
134
	{
135
		$client = $this->object->getSubClient( 'address', 'Standard' );
136
		$this->assertInstanceOf( '\\Aimeos\\Client\\HTML\\Iface', $client );
137
	}
138
139
140
	public function testGetSubClientInvalid()
141
	{
142
		$this->expectException( \LogicException::class );
143
		$this->object->getSubClient( 'invalid', 'invalid' );
144
	}
145
146
147
	public function testGetSubClientInvalidName()
148
	{
149
		$this->expectException( \LogicException::class );
150
		$this->object->getSubClient( '$$$', '$$$' );
151
	}
152
153
154
	public function testInit()
155
	{
156
		$this->object->init();
157
158
		$this->assertEmpty( $this->view->get( 'errors' ) );
159
	}
160
}
161