1 | <?php |
||
7 | class TableNodeTest extends \PHPUnit_Framework_TestCase |
||
8 | { |
||
9 | /** |
||
10 | * @expectedException \Behat\Gherkin\Exception\NodeException |
||
11 | */ |
||
12 | public function testConstructorExpectsSameNumberOfColumnsInEachRow() |
||
20 | |||
21 | public function constructorTestDataProvider() { |
||
31 | |||
32 | /** |
||
33 | * @dataProvider constructorTestDataProvider |
||
34 | * @expectedException \Behat\Gherkin\Exception\NodeException |
||
35 | * @expectedExceptionMessage Table is not two-dimensional. |
||
36 | */ |
||
37 | public function testConstructorExpectsTwoDimensionalArrays($table) |
||
41 | |||
42 | public function testHashTable() |
||
74 | |||
75 | public function testIterator() |
||
93 | |||
94 | public function testRowsHashTable() |
||
107 | |||
108 | public function testLongRowsHashTable() |
||
122 | |||
123 | public function testGetRows() |
||
124 | { |
||
125 | $table = new TableNode(array( |
||
126 | array('username', 'password'), |
||
127 | array('everzet', 'qwerty'), |
||
128 | array('antono', 'pa$sword') |
||
129 | )); |
||
130 | |||
131 | $this->assertEquals(array( |
||
132 | array('username', 'password'), |
||
133 | array('everzet', 'qwerty'), |
||
134 | array('antono', 'pa$sword') |
||
135 | ), $table->getRows()); |
||
136 | } |
||
137 | |||
138 | public function testGetLines() |
||
148 | |||
149 | public function testGetRow() |
||
150 | { |
||
151 | $table = new TableNode(array( |
||
152 | array('username', 'password'), |
||
153 | array('everzet', 'qwerty'), |
||
154 | array('antono', 'pa$sword') |
||
155 | )); |
||
156 | |||
157 | $this->assertEquals(array('username', 'password'), $table->getRow(0)); |
||
158 | $this->assertEquals(array('antono', 'pa$sword'), $table->getRow(2)); |
||
159 | } |
||
160 | |||
161 | public function testGetColumn() |
||
162 | { |
||
163 | $table = new TableNode(array( |
||
164 | array('username', 'password'), |
||
165 | array('everzet', 'qwerty'), |
||
166 | array('antono', 'pa$sword') |
||
167 | )); |
||
168 | |||
169 | $this->assertEquals(array('username', 'everzet', 'antono'), $table->getColumn(0)); |
||
170 | $this->assertEquals(array('password', 'qwerty', 'pa$sword'), $table->getColumn(1)); |
||
171 | |||
172 | $table = new TableNode(array( |
||
173 | array('username'), |
||
174 | array('everzet'), |
||
175 | array('antono') |
||
176 | )); |
||
177 | |||
178 | $this->assertEquals(array('username', 'everzet', 'antono'), $table->getColumn(0)); |
||
179 | } |
||
180 | |||
181 | public function testGetRowWithLineNumbers() |
||
182 | { |
||
183 | $table = new TableNode(array( |
||
184 | 5 => array('username', 'password'), |
||
185 | 10 => array('everzet', 'qwerty'), |
||
186 | 13 => array('antono', 'pa$sword') |
||
187 | )); |
||
188 | |||
189 | $this->assertEquals(array('username', 'password'), $table->getRow(0)); |
||
190 | $this->assertEquals(array('antono', 'pa$sword'), $table->getRow(2)); |
||
191 | } |
||
192 | |||
193 | public function testGetTable() |
||
203 | |||
204 | public function testGetRowLine() |
||
215 | |||
216 | public function testGetRowAsString() |
||
217 | { |
||
218 | $table = new TableNode(array( |
||
219 | 5 => array('username', 'password'), |
||
227 | |||
228 | public function testGetTableAsString() |
||
243 | |||
244 | public function testFromList() |
||
257 | |||
258 | /** |
||
259 | * @expectedException \Behat\Gherkin\Exception\NodeException |
||
260 | */ |
||
261 | public function testGetTableFromListWithMultidimensionalArrayArgument() |
||
268 | |||
269 | } |
||
270 |