Completed
Push — master ( 8024d2...3434fe )
by Henry
08:54
created

SearchTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 88
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 7 1
A tearDown() 0 4 1
A testCreateColumnArray() 0 17 1
A testCreateLikeArray() 0 18 1
1
<?php
2
namespace Redaxscript\Tests\Model;
3
4
use Redaxscript\Model;
5
use Redaxscript\Tests\TestCaseAbstract;
6
7
/**
8
 * SearchTest
9
 *
10
 * @since 4.0.0
11
 *
12
 * @package Redaxscript
13
 * @category Tests
14
 * @author Henry Ruhs
15
 *
16
 * @covers Redaxscript\Model\Search
17
 */
18
19
class SearchTest extends TestCaseAbstract
20
{
21
	/**
22
	 * setUp
23
	 *
24
	 * @since 4.0.0
25
	 */
26
27
	public function setUp() : void
28
	{
29
		parent::setUp();
30
		$installer = $this->installerFactory();
31
		$installer->init();
32
		$installer->rawCreate();
33
	}
34
35
	/**
36
	 * tearDown
37
	 *
38
	 * @since 4.0.0
39
	 */
40
41
	public function tearDown() : void
42
	{
43
		$this->dropDatabase();
44
	}
45
46
	/**
47
	 * testCreateColumnArray
48
	 *
49
	 * @since 4.0.0
50
	 *
51
	 * @param string $table
52
	 * @param array $expectArray
53
	 *
54
	 * @dataProvider providerAutoloader
55
	 */
56
57
	public function testCreateColumnArray(string $table = null, array $expectArray = []) : void
58
	{
59
		/* setup */
60
61
		$searchModel = new Model\Search();
62
63
		/* actual */
64
65
		$actualArray = $this->callMethod($searchModel, '_createColumnArray',
66
		[
67
			$table
68
		]);
69
70
		/* compare */
71
72
		$this->assertEquals($expectArray, $actualArray);
73
	}
74
75
76
	/**
77
	 * testCreateLikeArray
78
	 *
79
	 * @since 4.0.0
80
	 *
81
	 * @param string $table
82
	 * @param string $search
83
	 * @param array $expectArray
84
	 *
85
	 * @dataProvider providerAutoloader
86
	 */
87
88
	public function testCreateLikeArray(string $table = null, string $search = null, array $expectArray = []) : void
89
	{
90
		/* setup */
91
92
		$searchModel = new Model\Search();
93
94
		/* actual */
95
96
		$actualArray = $this->callMethod($searchModel, '_createLikeArray',
97
		[
98
			$table,
99
			$search
100
		]);
101
102
		/* compare */
103
104
		$this->assertEquals($expectArray, $actualArray);
105
	}
106
}
107