Completed
Push — master ( 52d06b...ee11f0 )
by Aimeos
04:53
created

IndexTest::testSave()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 8
c 2
b 0
f 1
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), 2016-2020
6
 */
7
8
9
namespace Aimeos\Admin\JQAdm\Common\Decorator;
10
11
12
class IndexTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $context;
15
	private $object;
16
	private $mock;
17
18
19
	protected function setUp() : void
20
	{
21
		$this->context = \TestHelperJqadm::getContext();
22
23
		$this->mock = $this->getMockBuilder( 'Aimeos\Admin\JQAdm\Catalog\Product\Standard' )
24
			->disableOriginalConstructor()
25
			->setMethods( ['save'] )
26
			->getMock();
27
28
		$this->object = new \Aimeos\Admin\JQAdm\Common\Decorator\Index( $this->mock, $this->context );
29
		$this->object->setAimeos( \TestHelperJqadm::getAimeos() );
30
		$this->object->setView( \TestHelperJqadm::getView() );
31
	}
32
33
34
	protected function tearDown() : void
35
	{
36
		unset( $this->object, $this->mock, $this->context );
37
	}
38
39
40
	public function testSave()
41
	{
42
		$view = \TestHelperJqadm::getView();
43
		$params = ['product' => ['catalog.lists.refid' => [-1]]];
44
		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $view, $params );
45
		$view->addHelper( 'param', $helper );
46
47
		$this->mock->expects( $this->once() )->method( 'save' )->will( $this->returnValue( 'test' ) );
48
		$this->object->setView( $view );
49
50
		$result = $this->object->save();
51
52
		$this->assertEquals( 'test', $result );
53
	}
54
}
55