Completed
Push — master ( 0c89f9...7a6f38 )
by Aimeos
01:52
created

AccountControllerTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 5
c 3
b 0
f 2
lcom 1
cbo 0
dl 0
loc 82
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 13 1
A indexAction() 0 12 1
A historyComponentAction() 0 10 1
A watchComponentAction() 0 10 1
A favoriteComponentAction() 0 10 1
1
<?php
2
3
4
namespace Aimeos\Shop\Tests\Unit\Controller;
5
6
7
class AccountControllerTest extends \TYPO3\Flow\Tests\UnitTestCase
8
{
9
	private $object;
10
	private $view;
11
12
13
	public function setUp()
14
	{
15
		$this->object = $this->getMockBuilder( '\Aimeos\Shop\Controller\AccountController' )
16
			->setMethods( array( 'getOutput', 'getSections' ) )
17
			->disableOriginalConstructor()
18
			->getMock();
19
20
		$this->view = $this->getMockBuilder( '\TYPO3\Flow\Mvc\View\JsonView' )
21
			->disableOriginalConstructor()
22
			->getMock();
23
24
		$this->inject( $this->object, 'view', $this->view );
25
	}
26
27
28
	/**
29
	 * @test
30
	 */
31
	public function indexAction()
32
	{
33
		$expected = array( 'aibody' => 'body', 'aiheader' => 'header' );
34
35
		$this->object->expects( $this->once() )->method( 'getSections' )
36
			->will( $this->returnValue( $expected ) );
37
38
		$this->view->expects( $this->once() )->method( 'assignMultiple' )
39
			->with( $this->equalTo( $expected ) );
40
41
		$this->object->indexAction();
42
	}
43
44
45
	/**
46
	 * @test
47
	 */
48
	public function favoriteComponentAction()
49
	{
50
		$this->object->expects( $this->once() )->method( 'getOutput' )
51
			->will( $this->returnValue( 'body' ) );
52
53
		$this->view->expects( $this->once() )->method( 'assign' )
54
			->with( $this->equalTo( 'output' ), $this->equalTo( 'body' ) );
55
56
		$this->object->favoriteComponentAction();
57
	}
58
59
60
	/**
61
	 * @test
62
	 */
63
	public function historyComponentAction()
64
	{
65
		$this->object->expects( $this->once() )->method( 'getOutput' )
66
			->will( $this->returnValue( 'body' ) );
67
68
		$this->view->expects( $this->once() )->method( 'assign' )
69
			->with( $this->equalTo( 'output' ), $this->equalTo( 'body' ) );
70
71
		$this->object->historyComponentAction();
72
	}
73
74
75
	/**
76
	 * @test
77
	 */
78
	public function watchComponentAction()
79
	{
80
		$this->object->expects( $this->once() )->method( 'getOutput' )
81
			->will( $this->returnValue( 'body' ) );
82
83
		$this->view->expects( $this->once() )->method( 'assign' )
84
			->with( $this->equalTo( 'output' ), $this->equalTo( 'body' ) );
85
86
		$this->object->watchComponentAction();
87
	}
88
}