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-2025 |
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
|
|
|
\Aimeos\Controller\Frontend::cache( true ); |
23
|
|
|
\Aimeos\MShop::cache( true ); |
24
|
|
|
|
25
|
|
|
$this->view = \TestHelper::view(); |
26
|
|
|
$this->context = \TestHelper::context(); |
27
|
|
|
|
28
|
|
|
$this->object = new \Aimeos\Client\Html\Locale\Select\Language\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 testBody() |
43
|
|
|
{ |
44
|
|
|
$this->view->selectCurrencyId = 'EUR'; |
45
|
|
|
$this->view->selectLanguageId = 'de'; |
46
|
|
|
$this->view->selectMap = map( [ |
47
|
|
|
'de' => array( |
48
|
|
|
'EUR' => array( 'locale' => 'de', 'currency' => 'EUR' ), |
49
|
|
|
'CHF' => array( 'locale' => 'de', 'currency' => 'CHF' ), |
50
|
|
|
), |
51
|
|
|
'en' => array( 'USD' => array( 'locale' => 'en', 'currency' => 'USD' ) ), |
52
|
|
|
] ); |
53
|
|
|
|
54
|
|
|
$request = $this->getMockBuilder( \Psr\Http\Message\ServerRequestInterface::class )->getMock(); |
55
|
|
|
$helper = new \Aimeos\Base\View\Helper\Request\Standard( $this->view, $request, '127.0.0.1', 'test' ); |
56
|
|
|
$this->view->addHelper( 'request', $helper ); |
57
|
|
|
|
58
|
|
|
$tags = []; |
59
|
|
|
$expire = null; |
60
|
|
|
$output = $this->object->body( 1, $tags, $expire ); |
61
|
|
|
|
62
|
|
|
$this->assertStringStartsWith( '<div class="locale-select-language">', $output ); |
63
|
|
|
$this->assertStringContainsString( '<li class="select-dropdown select-current"><a href="#">de', $output ); |
64
|
|
|
$this->assertStringContainsString( '<li class="select-item active">', $output ); |
65
|
|
|
|
66
|
|
|
$this->assertEquals( 0, count( $tags ) ); |
67
|
|
|
$this->assertEquals( null, $expire ); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
public function testInit() |
72
|
|
|
{ |
73
|
|
|
$helper = new \Aimeos\Base\View\Helper\Param\Standard( $this->view, ['locale' => 'de'] ); |
74
|
|
|
$this->view->addHelper( 'param', $helper ); |
75
|
|
|
|
76
|
|
|
$this->object->init(); |
77
|
|
|
|
78
|
|
|
$this->assertEquals( 'de', $this->context->session()->get( 'aimeos/locale/languageid' ) ); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|