ExtraFormTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 64
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 15 1
A tearDown() 0 4 1
A testRender() 0 16 1
1
<?php
2
namespace Redaxscript\Tests\Admin\View;
3
4
use Redaxscript\Admin;
5
use Redaxscript\Db;
6
use Redaxscript\Tests\TestCaseAbstract;
7
8
/**
9
 * ExtraFormTest
10
 *
11
 * @since 3.0.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\Admin\View\ExtraForm
18
 * @covers Redaxscript\Admin\View\ViewAbstract
19
 */
20
21
class ExtraFormTest extends TestCaseAbstract
22
{
23
	/**
24
	 * setUp
25
	 *
26
	 * @since 3.1.0
27
	 */
28
29
	public function setUp() : void
30
	{
31
		parent::setUp();
32
		$installer = $this->installerFactory();
33
		$installer->init();
34
		$installer->rawCreate();
35
		Db::forTablePrefix('extras')
36
			->create()
37
			->set(
38
			[
39
				'title' => 'Extra One',
40
				'alias' => 'extra-one',
41
			])
42
			->save();
43
	}
44
45
	/**
46
	 * tearDown
47
	 *
48
	 * @since 3.1.0
49
	 */
50
51
	public function tearDown() : void
52
	{
53
		$this->dropDatabase();
54
	}
55
56
	/**
57
	 * testRender
58
	 *
59
	 * @since 3.0.0
60
	 *
61
	 * @param array $registryArray
62
	 * @param int $extraId
63
	 * @param array $expectArray
64
	 *
65
	 * @dataProvider providerAutoloader
66
	 */
67
68
	public function testRender(array $registryArray = [], int $extraId = null, array $expectArray = []) : void
69
	{
70
		/* setup */
71
72
		$this->_registry->init($registryArray);
73
		$extraForm = new Admin\View\ExtraForm($this->_registry, $this->_language);
74
75
		/* actual */
76
77
		$actual = $extraForm->render($extraId);
78
79
		/* compare */
80
81
		$this->assertStringStartsWith($expectArray['start'], $actual);
82
		$this->assertStringEndsWith($expectArray['end'], $actual);
83
	}
84
}
85