Passed
Push — master ( e3af5b...6cd0a8 )
by Aimeos
03:53
created

StandardTest::testInit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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