StandardTest::tearDown()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 10
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-2025
6
 */
7
8
9
namespace Aimeos\Client\Html\Supplier\Detail;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
	private $context;
16
	private $view;
17
18
19
	protected function setUp() : void
20
	{
21
		\Aimeos\Controller\Frontend::cache( true );
22
		\Aimeos\MShop::cache( true );
23
24
		$this->view = \TestHelper::view();
25
		$this->context = \TestHelper::context();
26
27
		$this->object = new \Aimeos\Client\Html\Supplier\Detail\Standard( $this->context );
28
		$this->object->setView( $this->view );
29
	}
30
31
32
	protected function tearDown() : void
33
	{
34
		\Aimeos\Controller\Frontend::cache( false );
35
		\Aimeos\MShop::cache( false );
36
37
		unset( $this->object, $this->context, $this->view );
38
	}
39
40
41
	public function testHeader()
42
	{
43
		$helper = new \Aimeos\Base\View\Helper\Param\Standard( $this->view, array( 'f_supid' => $this->getSupplierItem()->getId() ) );
44
		$this->view->addHelper( 'param', $helper );
45
46
		$tags = [];
47
		$expire = null;
48
49
		$this->object->setView( $this->object->data( $this->view, $tags, $expire ) );
50
		$output = $this->object->header();
51
52
		$this->assertStringContainsString( '<title>Test supplier | Aimeos</title>', $output );
53
		$this->assertEquals( '2100-01-01 00:00:00', $expire );
54
		$this->assertEquals( 1, count( $tags ) );
55
	}
56
57
58
	public function testBody()
59
	{
60
		$helper = new \Aimeos\Base\View\Helper\Param\Standard( $this->view, array( 'f_supid' => $this->getSupplierItem()->getId() ) );
61
		$this->view->addHelper( 'param', $helper );
62
63
		$tags = [];
64
		$expire = null;
65
66
		$this->object->setView( $this->object->data( $this->view, $tags, $expire ) );
67
		$output = $this->object->body();
68
69
		$this->assertStringContainsString( '<div class="section aimeos supplier-detail"', $output );
70
		$this->assertStringContainsString( '<div class="supplier-detail-basic', $output );
71
		$this->assertStringContainsString( '<div class="supplier-detail-image', $output );
72
73
		$this->assertEquals( '2100-01-01 00:00:00', $expire );
74
		$this->assertEquals( 1, count( $tags ) );
75
	}
76
77
78
	public function testBodyDefaultId()
79
	{
80
		$context = clone $this->context;
81
		$context->config()->set( 'client/html/supplier/detail/supid-default', $this->getSupplierItem()->getId() );
82
83
		$this->object = new \Aimeos\Client\Html\Supplier\Detail\Standard( $context );
84
		$this->object->setView( \TestHelper::view() );
85
86
		$helper = new \Aimeos\Base\View\Helper\Param\Standard( $this->view, [] );
87
		$this->view->addHelper( 'param', $helper );
88
89
		$this->object->setView( $this->object->data( $this->view ) );
90
		$output = $this->object->body();
91
92
		$this->assertStringContainsString( '<h1 class="name" itemprop="name">Test supplier</h1>', $output );
93
	}
94
95
96
	protected function getSupplierItem( $code = 'unitSupplier001', $domains = [] )
97
	{
98
		return \Aimeos\MShop::create( $this->context, 'supplier' )->find( $code, $domains );
99
	}
100
}
101