1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2021 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Client\Html\Cms\Page\Cataloglist; |
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()->setView( \TestHelperHtml::getView() ); |
21
|
|
|
|
22
|
|
|
$this->object = new \Aimeos\Client\Html\Cms\Page\Cataloglist\Standard( $this->context ); |
23
|
|
|
$this->object->setView( \TestHelperHtml::getView() ); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
protected function tearDown() : void |
28
|
|
|
{ |
29
|
|
|
unset( $this->object ); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
public function testAddData() |
34
|
|
|
{ |
35
|
|
|
$manager = \Aimeos\MShop::create( $this->context, 'catalog' ); |
36
|
|
|
$catId1 = $manager->find( 'cafe' )->getId(); |
|
|
|
|
37
|
|
|
$catId2 = $manager->find( 'new' )->getId(); |
38
|
|
|
|
39
|
|
|
$view = $this->object->getView(); |
40
|
|
|
$view->pageCmsItem = \Aimeos\MShop::create( $this->context, 'cms' )->find( '/catlist', ['text'] ); |
41
|
|
|
|
42
|
|
|
$textItems = $view->pageCmsItem->getRefItems( 'text', 'content' )->map( function( $item ) { |
43
|
|
|
$data = ( $json = json_decode( $item->getContent(), true ) ) ? $json['html'] : $item->getContent(); |
44
|
|
|
return '<div class="cms-content>' . $data . '</div>'; |
45
|
|
|
} )->all(); |
46
|
|
|
|
47
|
|
|
$this->assertEquals( 1, count( $textItems ) ); |
48
|
|
|
|
49
|
|
|
foreach( $textItems as $textItem ) { |
50
|
|
|
$textItem = str_replace( ['_cat1_', '_cat2_'], [$catId1, $catId2], $textItem ); |
|
|
|
|
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$view->pageContent = $textItems; |
54
|
|
|
|
55
|
|
|
$view = $this->object->addData( $view ); |
56
|
|
|
|
57
|
|
|
foreach( $view->pageContent as $text ) |
58
|
|
|
{ |
59
|
|
|
$this->assertStringContainsString( '<div class="catalog-list">', $text ); |
60
|
|
|
$this->assertStringContainsString( 'class="list-items', $text ); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
public function testGetSubClient() |
66
|
|
|
{ |
67
|
|
|
$this->expectException( '\\Aimeos\\Client\\Html\\Exception' ); |
68
|
|
|
$this->object->getSubClient( 'invalid', 'invalid' ); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
public function testModifyBody() |
73
|
|
|
{ |
74
|
|
|
$output = 'BEFORE<!-- catalog.lists.items.csrf -->CSRF<!-- catalog.lists.items.csrf -->AFTER'; |
75
|
|
|
|
76
|
|
|
$output = $this->object->modifyBody( $output, 1 ); |
77
|
|
|
|
78
|
|
|
$this->assertStringContainsString( '<input class="csrf-token" type="hidden" name="_csrf_token" value="_csrf_value"', $output ); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths