|
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\Currency; |
|
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\Currency\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-currency">', $output ); |
|
57
|
|
|
$this->assertStringContainsString( '<li class="select-dropdown select-current"><a href="#">EUR', $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, ['currency' => 'EUR'] ); |
|
68
|
|
|
$this->view->addHelper( 'param', $helper ); |
|
69
|
|
|
|
|
70
|
|
|
$this->object->init(); |
|
71
|
|
|
|
|
72
|
|
|
$this->assertEquals( 'EUR', $this->context->session()->get( 'aimeos/locale/currencyid' ) ); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|