Completed
Push — master ( 4dbc3b...796c61 )
by Aimeos
03:24
created

StandardTest::testTransform()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 11
nc 1
nop 0
dl 0
loc 17
rs 9.9
c 1
b 0
f 0
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' );
0 ignored issues
show
Bug introduced by
The method createListsItem() does not exist on Aimeos\MShop\Common\Manager\Iface. Did you maybe mean createItem()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
		$listItem = $manager->/** @scrutinizer ignore-call */ createListsItem()->setType( 'variant' );

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.

Loading history...
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