Completed
Push — master ( b1ac59...547661 )
by Aimeos
04:06
created

StandardTest::getProcess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 15
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 21
rs 9.7666
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2020
6
 */
7
8
9
namespace Aimeos\Client\Html\Account\Review\Todo;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
	private $context;
16
17
18
	protected function setUp() : void
19
	{
20
		$this->context = \TestHelperHtml::getContext();
21
22
		$customer = \Aimeos\MShop\Customer\Manager\Factory::create( $this->context )->find( '[email protected]' );
23
		$this->context->setUserId( $customer->getId() );
24
25
		$this->object = new \Aimeos\Client\Html\Account\Review\Todo\Standard( $this->context );
26
		$this->object->setView( \TestHelperHtml::getView() );
27
	}
28
29
30
	protected function tearDown() : void
31
	{
32
		unset( $this->object, $this->context );
33
	}
34
35
36
	public function testGetBody()
37
	{
38
		$view = \TestHelperHtml::getView();
39
		$this->object->setView( $this->object->addData( $view ) );
40
41
		$output = $this->object->getBody();
42
43
		$this->assertStringContainsString( '<div class="account-review-todo">', $output );
44
	}
45
46
47
	public function testGetSubClientInvalid()
48
	{
49
		$this->expectException( '\\Aimeos\\Client\\Html\\Exception' );
50
		$this->object->getSubClient( 'invalid', 'invalid' );
51
	}
52
53
54
	public function testGetSubClientInvalidName()
55
	{
56
		$this->expectException( '\\Aimeos\\Client\\Html\\Exception' );
57
		$this->object->getSubClient( '$$$', '$$$' );
58
	}
59
60
61
	public function getProcess()
62
	{
63
		$view = $this->object->getView();
64
		$param = ['review-todo' => [['review.rating' => 5]]];
65
		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $view, $param );
66
		$view->addHelper( 'param', $helper );
67
		$this->object->setView( $view );
68
69
		$stub = $this->getMockBuilder( \Aimeos\Controller\Frontend\Review\Standard::class )
70
			->setConstructorArgs( [$this->context] )
71
			->setMethods( ['save'] )
72
			->getMock();
73
74
		$stub->expects( $this->once() )->method( 'save' );
75
76
		\Aimeos\Controller\Frontend\Review\Factory::injectController( '\Aimeos\Controller\Frontend\Review\Standard', $stub );
77
		$this->object->process();
78
		\Aimeos\Controller\Frontend\Review\Factory::injectController( '\Aimeos\Controller\Frontend\Review\Standard', null );
79
80
		$this->assertEmpty( $view->get( 'reviewErrorList' ) );
81
		$this->assertCount( 1, $view->get( 'reviewInfoList' ) );
82
	}
83
}
84