Passed
Push — master ( 49c0d4...ffd40d )
by Aimeos
19:25 queued 16:39
created

StandardTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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

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

42
		$listItem = $manager->/** @scrutinizer ignore-call */ createListItem()->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...
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