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

StandardTest::testGetSubClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
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\Language;
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\Language\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 testBody()
37
	{
38
		$this->view->selectCurrencyId = 'EUR';
39
		$this->view->selectLanguageId = 'de';
40
		$this->view->selectMap = map( [
41
			'de' => array(
42
				'EUR' => array( 'locale' => 'de', 'currency' => 'EUR' ),
43
				'CHF' => array( 'locale' => 'de', 'currency' => 'CHF' ),
44
			),
45
			'en' => array( 'USD' => array( 'locale' => 'en', 'currency' => 'USD' ) ),
46
		] );
47
48
		$request = $this->getMockBuilder( \Psr\Http\Message\ServerRequestInterface::class )->getMock();
49
		$helper = new \Aimeos\MW\View\Helper\Request\Standard( $this->view, $request, '127.0.0.1', 'test' );
50
		$this->view->addHelper( 'request', $helper );
51
52
		$tags = [];
53
		$expire = null;
54
		$output = $this->object->body( 1, $tags, $expire );
55
56
		$this->assertStringStartsWith( '<div class="locale-select-language">', $output );
57
		$this->assertStringContainsString( '<li class="select-dropdown select-current"><a href="#">de', $output );
58
		$this->assertStringContainsString( '<li class="select-item active">', $output );
59
60
		$this->assertEquals( 0, count( $tags ) );
61
		$this->assertEquals( null, $expire );
62
	}
63
64
65
	public function testInit()
66
	{
67
		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, ['locale' => 'de'] );
68
		$this->view->addHelper( 'param', $helper );
69
70
		$this->object->init();
71
72
		$this->assertEquals( 'de', $this->context->session()->get( 'aimeos/locale/languageid' ) );
73
	}
74
}
75