Completed
Push — master ( b0734c...5d2c35 )
by Aimeos
03:40
created

ContextTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 3 1
A testAddData() 0 13 1
A setUp() 0 11 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2020
6
 */
7
8
9
namespace Aimeos\Client\Html\Common\Decorator;
10
11
12
class ContextTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $client;
15
	private $object;
16
17
18
	protected function setUp() : void
19
	{
20
		$context = \TestHelperHtml::getContext();
21
22
		$this->client = $this->getMockBuilder( '\\Aimeos\\Client\\Html\\Catalog\\Filter\\Standard' )
23
			->setConstructorArgs( [$context] )
24
			->setMethods( ['addData'] )
25
			->getMock();
26
27
		$this->object = new \Aimeos\Client\Html\Common\Decorator\Context( $this->client, $context );
28
		$this->object->setView( \TestHelperHtml::getView() );
29
	}
30
31
32
	protected function tearDown() : void
33
	{
34
		unset( $this->object, $this->client );
35
	}
36
37
38
	public function testAddData()
39
	{
40
		$this->client->expects( $this->once() )->method( 'addData' ) ->will( $this->returnArgument( 0 ) );
41
42
		$result = $this->object->addData( \TestHelperHtml::getView() );
43
44
		$this->assertInstanceOf( '\Aimeos\MW\View\Iface', $result );
45
		$this->assertEquals( 'unittest', $result->get( 'contextSite' ) );
46
		$this->assertIsString( $result->get( 'contextSiteId' ) );
47
		$this->assertEquals( 'de', $result->get( 'contextLanguage' ) );
48
		$this->assertEquals( 'EUR', $result->get( 'contextCurrency' ) );
49
		$this->assertEquals( null, $result->get( 'contextUserId' ) );
50
		$this->assertEquals( [], $result->get( 'contextGroupIds' ) );
51
	}
52
}
53