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\MW\View\Helper\Image; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
private $object; |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
protected function setUp() : void |
18
|
|
|
{ |
19
|
|
|
$view = new \Aimeos\MW\View\Standard(); |
20
|
|
|
$view->addHelper( 'content', new \Aimeos\MW\View\Helper\Content\Standard( $view, '/path/to' ) ); |
21
|
|
|
$view->addHelper( 'encoder', new \Aimeos\MW\View\Helper\Encoder\Standard( $view ) ); |
22
|
|
|
|
23
|
|
|
$this->object = new \Aimeos\MW\View\Helper\Image\Standard( $view ); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
protected function tearDown() : void |
28
|
|
|
{ |
29
|
|
|
unset( $this->object ); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
public function testTransform() |
34
|
|
|
{ |
35
|
|
|
$context = \TestHelper::getContext(); |
36
|
|
|
$manager = \Aimeos\MShop::create( $context, 'media' ); |
37
|
|
|
|
38
|
|
|
$attrItem = \Aimeos\MShop::create( $context, 'attribute' )->createItem()->setType( 'color' )->setId( 123 ); |
39
|
|
|
$listItem = $manager->createListsItem()->setType( 'variant' ); |
|
|
|
|
40
|
|
|
|
41
|
|
|
$mediaItem = $manager->createItem()->setLabel( 'testimage' ) |
42
|
|
|
->setPreviews( ['100' => 'image-1.jpg', '200' => 'image-2.jpg'] ) |
43
|
|
|
->addListItem( 'attribute', $listItem, $attrItem ); |
44
|
|
|
|
45
|
|
|
$result = $this->object->transform( $mediaItem ); |
46
|
|
|
|
47
|
|
|
$this->assertStringContainsString( '/path/to/image-1.jpg 100w, /path/to/image-2.jpg 200w', $result ); |
48
|
|
|
$this->assertStringContainsString( 'src="/path/to/image-1.jpg"', $result ); |
49
|
|
|
$this->assertStringContainsString( 'data-variant-color="123"', $result ); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.