Completed
Push — develop ( d0fbe3...729812 )
by Bartko
14:43
created

NestedSetTest::testSetScopeColumnName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
namespace StefanoTreeTest\Unit\NestedSet;
3
4
use StefanoTree\NestedSet\Options;
5
6
class NestedSetTest
7
    extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
8
{
9
    public function testThrowExceptionIfAllRequiredSettingsAreNotProvided()
10
    {
11
        $this->setExpectedException('\StefanoTree\Exception\InvalidArgumentException',
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
12
            'tableName, idColumnName must be set');
13
14
        new Options(array());
15
    }
16
17
    /**
18
     * @return \StefanoTree\NestedSet\Options
19
     */
20
    private function getOptionsWithDefaultSettings()
21
    {
22
        return new Options(array(
23
            'tableName' => 'table',
24
            'idColumnName' => 'id',
25
            'dbAdapter' => \Mockery::mock('\StefanoDb\Adapter\Adapter'),
26
        ));
27
    }
28
29
    public function testThrowExceptionIfTrySetWrongTableName()
30
    {
31
        $optionsStub = $this->getOptionsWithDefaultSettings();
32
33
        $this->setExpectedException('\StefanoTree\Exception\InvalidArgumentException',
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
34
            'tableName cannot be empty');
35
36
        $optionsStub->setTableName(' ');
37
    }
38
39
    public function testThrowExceptionIfTrySetWrongIdColumnName()
40
    {
41
        $optionsStub = $this->getOptionsWithDefaultSettings();
42
43
        $this->setExpectedException('\StefanoTree\Exception\InvalidArgumentException',
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
44
            'idColumnName cannot be empty');
45
46
        $optionsStub->setIdColumnName(' ');
47
    }
48
49
    public function testThrowExceptionIfTrySetWrongLeftColumnName()
50
    {
51
        $optionsStub = $this->getOptionsWithDefaultSettings();
52
53
        $this->setExpectedException('\StefanoTree\Exception\InvalidArgumentException',
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
54
            'leftColumnName cannot be empty');
55
56
        $optionsStub->setLeftColumnName(' ');
57
    }
58
59
    public function testThrowExceptionIfTrySetWrongRightColumnName()
60
    {
61
        $optionsStub = $this->getOptionsWithDefaultSettings();
62
63
        $this->setExpectedException('\StefanoTree\Exception\InvalidArgumentException',
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
64
            'rightColumnName cannot be empty');
65
66
        $optionsStub->setRightColumnName(' ');
67
    }
68
69
    public function testThrowExceptionIfTrySetWrongLevelColumnName()
70
    {
71
        $optionsStub = $this->getOptionsWithDefaultSettings();
72
73
        $this->setExpectedException('\StefanoTree\Exception\InvalidArgumentException',
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
74
            'levelColumnName cannot be empty');
75
76
        $optionsStub->setLevelColumnName(' ');
77
    }
78
79
    public function testThrowExceptionIfTrySetWrongParentIdColumnName()
80
    {
81
        $optionsStub = $this->getOptionsWithDefaultSettings();
82
83
        $this->setExpectedException('\StefanoTree\Exception\InvalidArgumentException',
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
84
            'parentIdColumnName cannot be empty');
85
86
        $optionsStub->setParentIdColumnName(' ');
87
    }
88
89
    public function testGetTableName()
90
    {
91
        $optionsStub = $this->getOptionsWithDefaultSettings();
92
93
        $optionsStub->setTableName('   table ');
94
95
        $this->assertEquals('table', $optionsStub->getTableName());
96
    }
97
98
    public function testGetIdColumnName()
99
    {
100
        $optionsStub = $this->getOptionsWithDefaultSettings();
101
102
        $optionsStub->setIdColumnName('   id ');
103
104
        $this->assertEquals('id', $optionsStub->getIdColumnName());
105
    }
106
107
    public function testGetLeftColumnName()
108
    {
109
        $optionsStub = $this->getOptionsWithDefaultSettings();
110
111
        $this->assertEquals('lft', $optionsStub->getLeftColumnName(), 'Wrong default value');
112
113
        $optionsStub->setLeftColumnName('   left ');
114
115
        $this->assertEquals('left', $optionsStub->getLeftColumnName());
116
    }
117
118
    public function testGetRightColumnName()
119
    {
120
        $optionsStub = $this->getOptionsWithDefaultSettings();
121
122
        $this->assertEquals('rgt', $optionsStub->getRightColumnName(), 'Wrong default value');
123
124
        $optionsStub->setRightColumnName('   right ');
125
126
        $this->assertEquals('right', $optionsStub->getRightColumnName());
127
    }
128
129
    public function testGetLevelColumnName()
130
    {
131
        $optionsStub = $this->getOptionsWithDefaultSettings();
132
133
        $this->assertEquals('level', $optionsStub->getLevelColumnName(), 'Wrong default value');
134
135
        $optionsStub->setLevelColumnName('   lvl ');
136
137
        $this->assertEquals('lvl', $optionsStub->getLevelColumnName());
138
    }
139
140
    public function testGetParentIdColumnName()
141
    {
142
        $optionsStub = $this->getOptionsWithDefaultSettings();
143
144
        $this->assertEquals('parent_id', $optionsStub->getParentIdColumnName(), 'Wrong default value');
145
146
        $optionsStub->setParentIdColumnName('   prt ');
147
148
        $this->assertEquals('prt', $optionsStub->getParentIdColumnName());
149
    }
150
151
    public function testGetSequenceName()
152
    {
153
        $optionsStub = $this->getOptionsWithDefaultSettings();
154
155
        $this->assertEquals('', $optionsStub->getSequenceName(), 'Wrong default value');
156
157
        $optionsStub->setSequenceName('   seq ');
158
159
        $this->assertEquals('seq', $optionsStub->getSequenceName());
160
    }
161
162
    public function testGetDefaultScopeColumnName()
163
    {
164
        $optionsStub = $this->getOptionsWithDefaultSettings();
165
166
        $this->assertEquals('', $optionsStub->getScopeColumnName());
167
    }
168
169
    public function testSetScopeColumnName()
170
    {
171
        $optionsStub = $this->getOptionsWithDefaultSettings();
172
173
        $optionsStub->setScopeColumnName('   scope   ');
174
175
        $this->assertEquals('scope', $optionsStub->getScopeColumnName());
176
    }
177
}
178