UserFormTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 23 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
 * UserFormTest
10
 *
11
 * @since 3.0.0
12
 *
13
 * @package Redaxscript
14
 * @category Tests
15
 * @author Henry Ruhs
16
 *
17
 * @covers Redaxscript\Admin\View\UserForm
18
 * @covers Redaxscript\Admin\View\ViewAbstract
19
 */
20
21
class UserFormTest 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('users')
36
			->create()
37
			->set(
38
			[
39
				'name' => 'User One',
40
				'user' => 'user-one'
41
			])
42
			->save();
43
		Db::forTablePrefix('users')
44
			->create()
45
			->set(
46
			[
47
				'name' => 'User Two',
48
				'user' => 'user-two'
49
			])
50
			->save();
51
	}
52
53
	/**
54
	 * tearDown
55
	 *
56
	 * @since 3.1.0
57
	 */
58
59
	public function tearDown() : void
60
	{
61
		$this->dropDatabase();
62
	}
63
64
	/**
65
	 * testRender
66
	 *
67
	 * @since 3.0.0
68
	 *
69
	 * @param array $registryArray
70
	 * @param int $userId
71
	 * @param array $expectArray
72
	 *
73
	 * @dataProvider providerAutoloader
74
	 */
75
76
	public function testRender(array $registryArray = [], int $userId = null, array $expectArray = []) : void
77
	{
78
		/* setup */
79
80
		$this->_registry->init($registryArray);
81
		$userForm = new Admin\View\UserForm($this->_registry, $this->_language);
82
83
		/* actual */
84
85
		$actual = $userForm->render($userId);
86
87
		/* compare */
88
89
		$this->assertStringStartsWith($expectArray['start'], $actual);
90
		$this->assertStringEndsWith($expectArray['end'], $actual);
91
	}
92
}
93