Passed
Push — master ( 6cd0a8...5d904d )
by Aimeos
03:19
created

StandardTest::testBodyMShopException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 13
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, 2014
6
 * @copyright Aimeos (aimeos.org), 2015-2022
7
 */
8
9
10
namespace Aimeos\Client\Html\Locale\Select;
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
		$this->view = \TestHelperHtml::view();
23
		$this->context = \TestHelperHtml::context();
24
25
		$this->object = new \Aimeos\Client\Html\Locale\Select\Standard( $this->context );
26
		$this->object->setView( $this->view );
27
	}
28
29
30
	protected function tearDown() : void
31
	{
32
		unset( $this->object, $this->context, $this->view );
33
	}
34
35
36
	public function testHeader()
37
	{
38
		$tags = [];
39
		$expire = null;
40
		$output = $this->object->header( 1, $tags, $expire );
41
42
		$this->assertNotNull( $output );
43
		$this->assertEquals( null, $expire );
44
		$this->assertEquals( 0, count( $tags ) );
45
	}
46
47
48
	public function testBody()
49
	{
50
		$request = $this->getMockBuilder( \Psr\Http\Message\ServerRequestInterface::class )->getMock();
51
		$helper = new \Aimeos\MW\View\Helper\Request\Standard( $this->view, $request, '127.0.0.1', 'test' );
52
		$this->view->addHelper( 'request', $helper );
53
54
		$tags = [];
55
		$expire = null;
56
		$output = $this->object->body( 1, $tags, $expire );
57
58
		$this->assertStringStartsWith( '<section class="aimeos locale-select"', $output );
59
		$this->assertEquals( null, $expire );
60
		$this->assertEquals( 0, count( $tags ) );
61
	}
62
63
64
	public function testGetSubClient()
65
	{
66
		$client = $this->object->getSubClient( 'language', 'Standard' );
67
		$this->assertInstanceOf( '\\Aimeos\\Client\\HTML\\Iface', $client );
68
	}
69
70
71
	public function testGetSubClientInvalid()
72
	{
73
		$this->expectException( '\\Aimeos\\Client\\Html\\Exception' );
74
		$this->object->getSubClient( 'invalid', 'invalid' );
75
	}
76
77
78
	public function testGetSubClientInvalidName()
79
	{
80
		$this->expectException( '\\Aimeos\\Client\\Html\\Exception' );
81
		$this->object->getSubClient( '$$$', '$$$' );
82
	}
83
}
84