Completed
Push — master ( f81167...15513d )
by Aimeos
02:00
created

ShopTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace Aimeos\Shop\Tests\Unit\Base;
5
6
7
class ShopTest extends \Neos\Flow\Tests\UnitTestCase
8
{
9
	private $object;
10
11
12
	public function setUp()
13
	{
14
		$this->object = new \Aimeos\Shop\Base\Shop();
15
16
		$aimeos = new \Aimeos\Shop\Base\Aimeos();
17
18
		$uriBuilder = $this->getMockBuilder( '\Neos\Flow\Mvc\Routing\UriBuilder' )
19
			->disableOriginalConstructor()
20
			->getMock();
21
22
		$this->inject( $this->object, 'aimeos', $aimeos );
23
		$this->inject( $this->object, 'uriBuilder', $uriBuilder );
24
	}
25
26
27
	/**
28
	 * @test
29
	 */
30
	public function get()
31
	{
32
		$view = $this->getMockBuilder( '\Aimeos\Shop\Base\View' )
33
			->setMethods( array( 'create' ) )
34
			->disableOriginalConstructor()
35
			->getMock();
36
37
		$mwView = new \Aimeos\MW\View\Standard();
38
39
		$view->expects( $this->once() )->method( 'create' )
40
			->will( $this->returnValue( $mwView ) );
41
42
		$this->inject( $this->object, 'view', $view );
43
44
45
		$context = $this->getMockBuilder( '\Aimeos\Shop\Base\Context' )
46
			->setMethods( array( 'get' ) )
47
			->disableOriginalConstructor()
48
			->getMock();
49
50
		$ctx = new \Aimeos\MShop\Context\Item\Standard();
51
		$ctx->setConfig( new \Aimeos\MW\Config\PHPArray() );
52
		$ctx->setLocale( new \Aimeos\MShop\Locale\Item\Standard( array( 'langid' => 'de' ) ) );
53
54
		$context->expects( $this->once() )->method( 'get' )
55
			->will( $this->returnValue( $ctx ) );
56
57
		$this->inject( $this->object, 'context', $context );
58
59
60
		$settings = array(
61
			'flow' => array( 'cache' => array( 'name' => 'None' ) ),
62
			'page' => array(),
63
		);
64
		$this->inject( $this->object, 'settings', $settings );
65
66
67
		$request = $this->getMockBuilder( '\Neos\Flow\Mvc\ActionRequest' )
68
			->setMethods( array( 'getArguments' ) )
69
			->disableOriginalConstructor()
70
			->getMock();
71
72
73
		$result = $this->object->get( $request, 'catalog/list' );
74
75
		$this->assertInternalType( 'array', $result );
76
		$this->assertArrayHasKey( 'aibody', $result );
77
		$this->assertArrayHasKey( 'aiheader', $result );
78
	}
79
80
81
	/**
82
	 * @test
83
	 */
84
	public function injectSettings()
85
	{
86
		$this->object->injectSettings( array( 'test' ) );
87
88
		$this->assertEquals( array( 'test' ), \PHPUnit\Framework\Assert::readAttribute( $this->object, 'settings' ) );
89
	}
90
}