Completed
Push — master ( 7b4297...eec074 )
by Aimeos
03:02
created

StandardTest::testCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015
6
 */
7
8
9
namespace Aimeos\Admin\JQAdm\Dashboard;
10
11
12
class StandardTest extends \PHPUnit_Framework_TestCase
13
{
14
	private $context;
15
	private $object;
16
	private $view;
17
18
19
	protected function setUp()
20
	{
21
		$this->view = \TestHelperJqadm::getView();
22
		$request = $this->getMock( '\Psr\Http\Message\ServerRequestInterface' );
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::getMock() has been deprecated with message: Method deprecated since Release 5.4.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
23
		$helper = new \Aimeos\MW\View\Helper\Request\Standard( $this->view, $request, '127.0.0.1', 'test' );
24
		$this->view ->addHelper( 'request', $helper );
25
26
		$this->context = \TestHelperJqadm::getContext();
27
		$templatePaths = \TestHelperJqadm::getTemplatePaths();
28
29
		$this->object = new \Aimeos\Admin\JQAdm\Dashboard\Standard( $this->context, $templatePaths );
30
		$this->object->setView( $this->view );
31
	}
32
33
34
	protected function tearDown()
35
	{
36
		unset( $this->object );
37
	}
38
39
40
	public function testCreate()
41
	{
42
		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
1 ignored issue
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
43
		$this->object->create();
44
	}
45
46
47
	public function testCopy()
48
	{
49
		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
1 ignored issue
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
50
		$this->object->copy();
51
	}
52
53
54
	public function testDelete()
55
	{
56
		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
1 ignored issue
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
57
		$this->object->delete();
58
	}
59
60
61
	public function testGet()
62
	{
63
		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
1 ignored issue
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
64
		$this->object->get();
65
	}
66
67
68
	public function testSave()
69
	{
70
		$this->setExpectedException( '\Aimeos\Admin\JQAdm\Exception' );
1 ignored issue
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
71
		$this->object->save();
72
	}
73
74
75
	public function testSearch()
76
	{
77
		$result = $this->object->search();
78
79
		$this->assertContains( '<div class="dashboard">', $result );
80
	}
81
82
83
	public function testSearchException()
84
	{
85
		$object = $this->getMockBuilder( '\Aimeos\Admin\JQAdm\Dashboard\Standard' )
86
			->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) )
87
			->setMethods( array( 'getSubClients' ) )
88
			->getMock();
89
90
		$object->expects( $this->once() )->method( 'getSubClients' )
91
			->will( $this->throwException( new \Exception() ) );
92
93
		$object->setView( $this->getViewNoRender() );
94
95
		$object->search();
96
	}
97
98
99
	public function testSearchMShopException()
100
	{
101
		$object = $this->getMockBuilder( '\Aimeos\Admin\JQAdm\Dashboard\Standard' )
102
			->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) )
103
			->setMethods( array( 'getSubClients' ) )
104
			->getMock();
105
106
		$object->expects( $this->once() )->method( 'getSubClients' )
107
			->will( $this->throwException( new \Aimeos\MShop\Exception() ) );
108
109
		$object->setView( $this->getViewNoRender() );
110
111
		$object->search();
112
	}
113
114
115
	public function testGetSubClient()
116
	{
117
		$result = $this->object->getSubClient( 'order' );
118
		$this->assertInstanceOf( '\Aimeos\Admin\JQAdm\Iface', $result );
119
	}
120
121
122
	protected function getViewNoRender()
123
	{
124
		return $this->getMockBuilder( '\Aimeos\MW\View\Standard' )
125
			->setConstructorArgs( array( array() ) )
126
			->setMethods( array( 'render', 'config' ) )
127
			->getMock();
128
	}
129
}
130