StandardTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 10
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\Account\History;
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->context = \TestHelper::context();
26
		$this->view = \TestHelper::view();
27
28
		$this->object = new \Aimeos\Client\Html\Account\History\Standard( $this->context );
29
		$this->object->setView( $this->view );
30
	}
31
32
33
	protected function tearDown() : void
34
	{
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 testHeader()
43
	{
44
		$output = $this->object->header();
45
46
		$this->assertStringContainsString( '<link rel="stylesheet"', $output );
47
		$this->assertStringContainsString( '<script defer', $output );
48
	}
49
50
51
	public function testBody()
52
	{
53
		$this->context->setUser( \Aimeos\MShop::create( $this->context, 'customer' )->find( '[email protected]' ) );
54
55
		$output = $this->object->body();
56
57
		$this->assertStringContainsString( '<div class="section aimeos account-history', $output );
58
		$this->assertMatchesRegularExpression( '#<div class="history-item#', $output );
59
		$this->assertMatchesRegularExpression( '#<h2 class="order-basic.*<span class="value[^<]+</span>.*</h2>#smU', $output );
60
		$this->assertMatchesRegularExpression( '#<div class="order-invoiceno.*<span class="value[^<]+</span>.*</div>#smU', $output );
61
		$this->assertMatchesRegularExpression( '#<div class="order-payment.*<span class="value[^<]+</span>.*</div>#smU', $output );
62
		$this->assertMatchesRegularExpression( '#<div class="order-delivery.*<span class="value.*</span>.*</div>#smU', $output );
63
64
		$this->assertStringContainsString( '<div class="account-history-detail common-summary', $output );
65
66
		$this->assertStringContainsString( 'Our Unittest', $output );
67
		$this->assertStringContainsString( 'Example company', $output );
68
69
		$this->assertStringContainsString( '<h4>unitdeliverycode</h4>', $output );
70
		$this->assertStringContainsString( '<h4>unitpaymentcode</h4>', $output );
71
72
		$this->assertStringContainsString( '>1234<', $output );
73
		$this->assertStringContainsString( 'This is a comment', $output );
74
75
		$this->assertStringContainsString( 'Cafe Noire Expresso', $output );
76
		$this->assertStringContainsString( 'Cafe Noire Cappuccino', $output );
77
		$this->assertStringContainsString( 'Unittest: Monetary rebate', $output );
78
		$this->assertMatchesRegularExpression( '#<div class="price.+55.00 EUR</div>#', $output );
79
		$this->assertMatchesRegularExpression( '#<div class="quantity.+14 articles</div>#', $output );
80
	}
81
}
82