Completed
Push — master ( 96a033...7625bb )
by Henry
07:07
created

ExtraTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 50

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 50
rs 9.0909
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Redaxscript\Tests\View;
3
4
use Redaxscript\Db;
5
use Redaxscript\Tests\TestCaseAbstract;
6
use Redaxscript\View;
7
8
/**
9
 * ExtraTest
10
 *
11
 * @since 4.2.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\View\Extra
18
 * @covers Redaxscript\View\ViewAbstract
19
 */
20
21
class ExtraTest extends TestCaseAbstract
22
{
23
	/**
24
	 * setUp
25
	 *
26
	 * @since 4.2.0
27
	 */
28
29
	public function setUp() : void
30
	{
31
		parent::setUp();
32
		$installer = $this->installerFactory();
0 ignored issues
show
Bug introduced by redaxmedia
The method installerFactory() does not seem to exist on object<Redaxscript\Tests\View\ExtraTest>.

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...
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
		Db::forTablePrefix('extras')
44
			->create()
45
			->set(
46
			[
47
				'title' => 'Extra Two',
48
				'alias' => 'extra-two'
49
			])
50
			->save();
51
		Db::forTablePrefix('extras')
52
			->create()
53
			->set(
54
			[
55
				'title' => 'Extra Three',
56
				'alias' => 'extra-three',
57
				'access' => '[1]'
58
			])
59
			->save();
60
		Db::forTablePrefix('extras')
61
			->create()
62
			->set(
63
			[
64
				'title' => 'Extra Four',
65
				'alias' => 'extra-four',
66
				'category' => 1
67
			])
68
			->save();
69
		Db::forTablePrefix('extras')
70
			->create()
71
			->set(
72
			[
73
				'title' => 'Extra Five',
74
				'alias' => 'extra-five',
75
				'article' => 1
76
			])
77
			->save();
78
	}
79
80
	/**
81
	 * tearDown
82
	 *
83
	 * @since 4.2.0
84
	 */
85
86
	public function tearDown() : void
87
	{
88
		$this->dropDatabase();
0 ignored issues
show
Bug introduced by redaxmedia
The method dropDatabase() does not seem to exist on object<Redaxscript\Tests\View\ExtraTest>.

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...
89
	}
90
91
	/**
92
	 * testRender
93
	 *
94
	 * @since 4.2.0
95
	 *
96
	 * @param array $registryArray
97
	 * @param array $optionArray
98
	 * @param int $extraId
99
	 * @param string $expect
100
	 *
101
	 * @dataProvider providerAutoloader
102
	 */
103
104
	public function testRender(array $registryArray = [], array $optionArray = [], int $extraId = null, string $expect = null) : void
105
	{
106
		/* setup */
107
108
		$this->_registry->init($registryArray);
109
		$extra = new View\Extra($this->_registry, $this->_request, $this->_language, $this->_config);
110
		$extra->init($optionArray);
111
112
		/* actual */
113
114
		$actual = $extra->render($extraId);
115
116
		/* compare */
117
118
		$this->assertEquals($expect, $actual);
119
	}
120
}
121