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\Attrname;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
16
17
	protected function setUp() : void
18
	{
19
		$translate = new \Aimeos\Base\Translation\None( 'en_GB' );
20
21
		$view = new \Aimeos\Base\View\Standard();
22
		$view->addHelper( 'number', new \Aimeos\Base\View\Helper\Number\Standard( $view ) );
23
		$view->addHelper( 'translate', new \Aimeos\Base\View\Helper\Translate\Standard( $view, $translate ) );
24
25
		$this->object = new \Aimeos\Base\View\Helper\Attrname\Standard( $view );
26
	}
27
28
29
	protected function tearDown() : void
30
	{
31
		unset( $this->object );
32
	}
33
34
35
	public function testTransform()
36
	{
37
		$manager = \Aimeos\MShop::create( \TestHelper::context(), 'attribute' );
38
		$search = $manager->filter()->slice( 0, 1 );
39
		$search->setConditions( $search->compare( '!=', $search->make( 'attribute:has', ['price'] ), null ) );
40
		$item = $manager->search( $search, ['price'] )->first( new \Exception( 'No item found' ) );
41
42
		$result = $this->object->transform( $item );
43
44
		$this->assertRegexp( '/[^ ]+ \(\+[0-9]+\.[0-9]+EUR\)/', $result );
45
	}
46
}
47