1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2020-2022 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Client\Html\Account\Review; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
private $object; |
15
|
|
|
private $context; |
16
|
|
|
private $view; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
protected function setUp() : void |
20
|
|
|
{ |
21
|
|
|
$this->view = \TestHelperHtml::view(); |
22
|
|
|
$this->context = \TestHelperHtml::context(); |
23
|
|
|
|
24
|
|
|
$this->object = new \Aimeos\Client\Html\Account\Review\Standard( $this->context ); |
25
|
|
|
$this->object->setView( $this->view ); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
protected function tearDown() : void |
30
|
|
|
{ |
31
|
|
|
unset( $this->object, $this->context, $this->view ); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
public function testHeader() |
36
|
|
|
{ |
37
|
|
|
$output = $this->object->header(); |
38
|
|
|
|
39
|
|
|
$this->assertStringContainsString( '<link rel="stylesheet"', $output ); |
40
|
|
|
$this->assertStringContainsString( '<script defer', $output ); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
public function testBody() |
45
|
|
|
{ |
46
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'customer' ); |
47
|
|
|
$this->context->setUserId( $manager->find( '[email protected]' )->getId() ); |
48
|
|
|
|
49
|
|
|
$this->view = $this->object->data( $this->view ); |
50
|
|
|
$this->view->reviewProductItems = map( \Aimeos\MShop::create( $this->context, 'product' )->find( 'CNE' ) ); |
51
|
|
|
|
52
|
|
|
$output = $this->object->body(); |
53
|
|
|
|
54
|
|
|
$this->assertStringContainsString( '<section class="aimeos account-review"', $output ); |
55
|
|
|
$this->assertStringContainsString( 'ABCD/16 discs', $output ); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
public function getInit() |
60
|
|
|
{ |
61
|
|
|
$param = ['review-todo' => [['review.rating' => 5]]]; |
62
|
|
|
$helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $param ); |
63
|
|
|
$this->view->addHelper( 'param', $helper ); |
64
|
|
|
$this->object->setView( $this->view ); |
65
|
|
|
|
66
|
|
|
$stub = $this->getMockBuilder( \Aimeos\Controller\Frontend\Review\Standard::class ) |
67
|
|
|
->setConstructorArgs( [$this->context] ) |
68
|
|
|
->setMethods( ['save'] ) |
69
|
|
|
->getMock(); |
70
|
|
|
|
71
|
|
|
$stub->expects( $this->once() )->method( 'save' ); |
72
|
|
|
|
73
|
|
|
\Aimeos\Controller\Frontend\Review\Factory::injectController( '\Aimeos\Controller\Frontend\Review\Standard', $stub ); |
74
|
|
|
$this->object->init(); |
75
|
|
|
\Aimeos\Controller\Frontend\Review\Factory::injectController( '\Aimeos\Controller\Frontend\Review\Standard', null ); |
76
|
|
|
|
77
|
|
|
$this->assertCount( 1, $this->view->get( 'reviewInfoList' ) ); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|