Completed
Push — master ( 01f593...6661e3 )
by Henry
10:15
created

GroupTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
namespace Redaxscript\Tests\Module;
3
4
use Redaxscript\Db;
5
use Redaxscript\Model;
6
use Redaxscript\Tests\TestCaseAbstract;
7
8
/**
9
 * GroupTest
10
 *
11
 * @since 3.3.0
12
 *
13
 * @package Redaxscript
14
 * @group Tests
15
 * @author Henry Ruhs
16
 */
17
18
class GroupTest extends TestCaseAbstract
19
{
20
	/**
21
	 * setUp
22
	 *
23
	 * @since 3.3.0
24
	 */
25
26
	public function setUp()
27
	{
28
		parent::setUp();
29
		$installer = $this->installerFactory();
30
		$installer->init();
31
		$installer->rawCreate();
32
		$installer->insertSettings(
33
		[
34
			'adminName' => 'Test',
35
			'adminUser' => 'test',
36
			'adminPassword' => 'test',
37
			'adminEmail' => '[email protected]'
38
		]);
39
		Db::forTablePrefix('groups')
40
			->create()
41
			->set(
42
			[
43
				'name' => 'Group One',
44
				'alias' => 'group-one'
45
			])
46
			->save();
47
		Db::forTablePrefix('groups')
48
			->create()
49
			->set(
50
			[
51
				'name' => 'Group Two',
52
				'alias' => 'group-two'
53
			])
54
			->save();
55
		Db::forTablePrefix('groups')
56
			->create()
57
			->set(
58
			[
59
				'name' => 'Group Three',
60
				'alias' => 'group-three'
61
			])
62
			->save();
63
	}
64
65
	/**
66
	 * tearDown
67
	 *
68
	 * @since 3.3.0
69
	 */
70
71
	public function tearDown()
72
	{
73
		$installer = $this->installerFactory();
74
		$installer->init();
75
		$installer->rawDrop();
76
	}
77
78
	/**
79
	 * providerGroupGetId
80
	 *
81
	 * @since 3.3.0
82
	 *
83
	 * @return array
84
	 */
85
86
	public function providerGroupGetId() : array
87
	{
88
		return $this->getProvider('tests/provider/Model/group_get_id.json');
89
	}
90
91
	/**
92
	 * testGetIdByAlias
93
	 *
94
	 * @since 3.3.0
95
	 *
96
	 * @param string $alias
97
	 * @param int $expect
98
	 *
99
	 * @dataProvider providerGroupGetId
100
	 */
101
102
	public function testGetIdByAlias(string $alias = null, int $expect = null)
103
	{
104
		/* setup */
105
106
		$groupModel = new Model\Group();
107
108
		/* actual */
109
110
		$actual = $groupModel->getIdByAlias($alias);
111
112
		/* compare */
113
114
		$this->assertEquals($expect, $actual);
115
	}
116
}
117