Passed
Push — master ( 64247a...702fed )
by Aimeos
06:01
created

StandardTest::testSearchMShopException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
rs 10
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2021
6
 */
7
8
9
namespace Aimeos\Admin\JQAdm\Dashboard\Order\Countcountry;
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() : void
20
	{
21
		$this->view = \TestHelperJqadm::getView();
22
		$this->context = \TestHelperJqadm::getContext();
23
24
		$this->object = new \Aimeos\Admin\JQAdm\Dashboard\Order\Countcountry\Standard( $this->context );
25
		$this->object = new \Aimeos\Admin\JQAdm\Common\Decorator\Page( $this->object, $this->context );
26
		$this->object->setAimeos( \TestHelperJqadm::getAimeos() );
27
		$this->object->setView( $this->view );
28
	}
29
30
31
	protected function tearDown() : void
32
	{
33
		unset( $this->object, $this->view, $this->context );
34
	}
35
36
37
	public function testSearch()
38
	{
39
		$result = $this->object->search();
40
41
		$this->assertStringContainsString( '<div class="chart geo order-countcountry', $result );
42
	}
43
44
45
	public function testSearchException()
46
	{
47
		$object = $this->getMockBuilder( \Aimeos\Admin\JQAdm\Dashboard\Standard::class )
48
			->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) )
49
			->setMethods( array( 'getSubClients' ) )
50
			->getMock();
51
52
		$object->expects( $this->once() )->method( 'getSubClients' )
53
			->will( $this->throwException( new \RuntimeException() ) );
54
55
		$object->setView( $this->getViewNoRender() );
56
57
		$object->search();
58
	}
59
60
61
	public function testSearchMShopException()
62
	{
63
		$object = $this->getMockBuilder( \Aimeos\Admin\JQAdm\Dashboard\Standard::class )
64
			->setConstructorArgs( array( $this->context, \TestHelperJqadm::getTemplatePaths() ) )
65
			->setMethods( array( 'getSubClients' ) )
66
			->getMock();
67
68
		$object->expects( $this->once() )->method( 'getSubClients' )
69
			->will( $this->throwException( new \Aimeos\MShop\Exception() ) );
70
71
		$object->setView( $this->getViewNoRender() );
72
73
		$object->search();
74
	}
75
76
77
	public function testGetSubClient()
78
	{
79
		$this->expectException( \Aimeos\Admin\JQAdm\Exception::class );
80
		$this->object->getSubClient( 'unknown' );
81
	}
82
83
84
	protected function getViewNoRender()
85
	{
86
		return $this->getMockBuilder( \Aimeos\MW\View\Standard::class )
87
			->setConstructorArgs( array( [] ) )
88
			->setMethods( array( 'render', 'config' ) )
89
			->getMock();
90
	}
91
}
92