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\Base\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
|
|
|
$conf = new \Aimeos\Base\Config\PHPArray( ['resource' => ['fs-media' => ['baseurl' => '/path/to']]] ); |
20
|
|
|
$view = new \Aimeos\Base\View\Standard(); |
21
|
|
|
|
22
|
|
|
$view->addHelper( 'config', new \Aimeos\Base\View\Helper\Config\Standard( $view, $conf ) ); |
23
|
|
|
$view->addHelper( 'content', new \Aimeos\Base\View\Helper\Content\Standard( $view ) ); |
24
|
|
|
$view->addHelper( 'encoder', new \Aimeos\Base\View\Helper\Encoder\Standard( $view ) ); |
25
|
|
|
|
26
|
|
|
$this->object = new \Aimeos\Base\View\Helper\Image\Standard( $view ); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
protected function tearDown() : void |
31
|
|
|
{ |
32
|
|
|
unset( $this->object ); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
public function testTransform() |
37
|
|
|
{ |
38
|
|
|
$context = \TestHelper::context(); |
39
|
|
|
$manager = \Aimeos\MShop::create( $context, 'media' ); |
40
|
|
|
|
41
|
|
|
$attrItem = \Aimeos\MShop::create( $context, 'attribute' )->create()->setType( 'color' )->setId( 123 ); |
42
|
|
|
$listItem = $manager->createListItem()->setType( 'variant' ); |
|
|
|
|
43
|
|
|
|
44
|
|
|
$mediaItem = $manager->create()->setLabel( 'testimage' ) |
45
|
|
|
->setPreviews( ['100' => 'image-1.jpg', '200' => 'image-2.jpg'] ) |
46
|
|
|
->addListItem( 'attribute', $listItem, $attrItem ); |
47
|
|
|
|
48
|
|
|
$result = $this->object->transform( $mediaItem, '240px' ); |
49
|
|
|
|
50
|
|
|
$this->assertStringContainsString( '/path/to/image-1.jpg 100w, /path/to/image-2.jpg 200w', $result ); |
51
|
|
|
$this->assertStringContainsString( 'src="/path/to/image-1.jpg"', $result ); |
52
|
|
|
$this->assertStringContainsString( 'data-variant-color="123"', $result ); |
53
|
|
|
$this->assertStringContainsString( 'sizes="240px"', $result ); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
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.