StandardTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017-2025
6
 */
7
8
9
namespace Aimeos\Admin\JQAdm\Dashboard\Order\Salesmonth;
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 = \TestHelper::view();
22
		$this->context = \TestHelper::context();
23
24
		$this->object = new \Aimeos\Admin\JQAdm\Dashboard\Order\Salesmonth\Standard( $this->context );
25
		$this->object = new \Aimeos\Admin\JQAdm\Common\Decorator\Page( $this->object, $this->context );
26
		$this->object->setAimeos( \TestHelper::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 line order-salesmonth', $result );
42
	}
43
44
45
	public function testSearchException()
46
	{
47
		$object = $this->getMockBuilder( \Aimeos\Admin\JQAdm\Dashboard\Standard::class )
48
			->setConstructorArgs( array( $this->context, \TestHelper::getTemplatePaths() ) )
49
			->onlyMethods( 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, \TestHelper::getTemplatePaths() ) )
65
			->onlyMethods( 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( \LogicException::class );
80
		$this->object->getSubClient( 'unknown' );
81
	}
82
83
84
	protected function getViewNoRender()
85
	{
86
		return $this->getMockBuilder( \Aimeos\Base\View\Standard::class )
87
			->setConstructorArgs( array( [] ) )
88
			->onlyMethods( ['render'] )->addMethods( ['config'] )
89
			->getMock();
90
	}
91
}
92