|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Aimeos\Client\Html\Catalog\Detail\Actions; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* @copyright Metaways Infosystems GmbH, 2014 |
|
8
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
9
|
|
|
* @copyright Aimeos (aimeos.org), 2015 |
|
10
|
|
|
*/ |
|
11
|
|
|
class StandardTest extends \PHPUnit_Framework_TestCase |
|
12
|
|
|
{ |
|
13
|
|
|
private $object; |
|
14
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Sets up the fixture, for example, opens a network connection. |
|
18
|
|
|
* This method is called before a test is executed. |
|
19
|
|
|
* |
|
20
|
|
|
* @access protected |
|
21
|
|
|
*/ |
|
22
|
|
|
protected function setUp() |
|
23
|
|
|
{ |
|
24
|
|
|
$paths = \TestHelperHtml::getHtmlTemplatePaths(); |
|
25
|
|
|
$this->object = new \Aimeos\Client\Html\Catalog\Detail\Actions\Standard( \TestHelperHtml::getContext(), $paths ); |
|
26
|
|
|
$this->object->setView( \TestHelperHtml::getView() ); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Tears down the fixture, for example, closes a network connection. |
|
32
|
|
|
* This method is called after a test is executed. |
|
33
|
|
|
* |
|
34
|
|
|
* @access protected |
|
35
|
|
|
*/ |
|
36
|
|
|
protected function tearDown() |
|
37
|
|
|
{ |
|
38
|
|
|
unset( $this->object ); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
public function testGetHeader() |
|
43
|
|
|
{ |
|
44
|
|
|
$view = $this->object->getView(); |
|
45
|
|
|
$view->detailProductItem = $this->getProductItem(); |
|
46
|
|
|
|
|
47
|
|
|
$output = $this->object->getHeader(); |
|
48
|
|
|
$this->assertNotNull( $output ); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
public function testGetBody() |
|
53
|
|
|
{ |
|
54
|
|
|
$view = $this->object->getView(); |
|
55
|
|
|
$view->detailProductItem = $this->getProductItem(); |
|
56
|
|
|
|
|
57
|
|
|
$output = $this->object->getBody(); |
|
58
|
|
|
|
|
59
|
|
|
$this->assertStringStartsWith( '<!-- catalog.detail.actions -->', $output ); |
|
60
|
|
|
$this->assertContains( 'actions-button-pin', $output ); |
|
61
|
|
|
$this->assertContains( 'actions-button-watch', $output ); |
|
62
|
|
|
$this->assertContains( 'actions-button-favorite', $output ); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
public function testModifyBody() |
|
67
|
|
|
{ |
|
68
|
|
|
$content = '<!-- catalog.detail.actions -->test<!-- catalog.detail.actions -->'; |
|
69
|
|
|
$output = $this->object->modifyBody( $content, -1 ); |
|
70
|
|
|
|
|
71
|
|
|
$this->assertStringStartsWith( '<!-- catalog.detail.actions -->', $output ); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
public function testGetSubClient() |
|
76
|
|
|
{ |
|
77
|
|
|
$this->setExpectedException( '\\Aimeos\\Client\\Html\\Exception' ); |
|
78
|
|
|
$this->object->getSubClient( 'invalid', 'invalid' ); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
|
|
82
|
|
|
protected function getProductItem() |
|
83
|
|
|
{ |
|
84
|
|
|
$manager = \Aimeos\MShop\Product\Manager\Factory::createManager( \TestHelperHtml::getContext() ); |
|
85
|
|
|
$search = $manager->createSearch(); |
|
86
|
|
|
$search->setConditions( $search->compare( '==', 'product.code', 'CNC' ) ); |
|
87
|
|
|
$items = $manager->searchItems( $search ); |
|
88
|
|
|
|
|
89
|
|
|
if( ( $item = reset( $items ) ) === false ) { |
|
90
|
|
|
throw new \Exception( 'No product item with code "CNC" found' ); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
return $item; |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|