1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2022 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Client\Html\Basket\Related; |
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::context(); |
21
|
|
|
|
22
|
|
|
$this->object = new \Aimeos\Client\Html\Basket\Related\Standard( $this->context ); |
23
|
|
|
$this->object->setView( \TestHelperHtml::view() ); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
protected function tearDown() : void |
28
|
|
|
{ |
29
|
|
|
\Aimeos\Controller\Frontend\Basket\Factory::create( $this->context )->clear(); |
30
|
|
|
unset( $this->object, $this->context ); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
public function testHeader() |
35
|
|
|
{ |
36
|
|
|
$output = $this->object->header(); |
37
|
|
|
|
38
|
|
|
$this->assertStringContainsString( '<link rel="stylesheet"', $output ); |
39
|
|
|
$this->assertStringContainsString( '<script defer', $output ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
public function testBody() |
44
|
|
|
{ |
45
|
|
|
$cntl = \Aimeos\Controller\Frontend\Basket\Factory::create( $this->context ); |
46
|
|
|
$basket = $cntl->get()->addProduct( $this->getOrderProductItem( 'CNE' ) ); |
|
|
|
|
47
|
|
|
$cntl->save(); |
48
|
|
|
|
49
|
|
|
$output = $this->object->body(); |
50
|
|
|
|
51
|
|
|
$this->assertStringContainsString( '<section class="basket-related', $output ); |
52
|
|
|
$this->assertStringContainsString( '<section class="basket-related-bought', $output ); |
53
|
|
|
$this->assertStringContainsString( 'Cafe Noire Cappuccino', $output ); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param string $code |
59
|
|
|
* @return \Aimeos\MShop\Order\Item\Base\Product\Iface |
60
|
|
|
*/ |
61
|
|
|
protected function getOrderProductItem( $code ) |
62
|
|
|
{ |
63
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'product' ); |
64
|
|
|
$search = $manager->filter(); |
65
|
|
|
$search->setConditions( $search->compare( '==', 'product.code', $code ) ); |
66
|
|
|
|
67
|
|
|
if( ( $item = $manager->search( $search )->first() ) === null ) { |
68
|
|
|
throw new \RuntimeException( sprintf( 'No product item with code "%1$s" found', $code ) ); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'order/base/product' ); |
72
|
|
|
$orderItem = $manager->create()->copyFrom( $item )->setStockType( 'default' ); |
73
|
|
|
|
74
|
|
|
return $orderItem; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|