| | 259 | |
| | 260 | public function testImportNestedSetMultipleTreeData() |
| | 261 | { |
| | 262 | $yml = <<<END |
| | 263 | --- |
| | 264 | ImportNestedSetMultipleTree: |
| | 265 | ImportNestedSetMultipleTree_Item1: |
| | 266 | name: Item 1 |
| | 267 | |
| | 268 | children: |
| | 269 | ImportNestedSetMultipleTree_Item1_1: |
| | 270 | name: Item 1.1 |
| | 271 | |
| | 272 | ImportNestedSetMultipleTree_Item1_2: |
| | 273 | name: Item 1.2 |
| | 274 | |
| | 275 | ImportNestedSetMultipleTree_Item2: |
| | 276 | name: Item 2 |
| | 277 | |
| | 278 | children: |
| | 279 | ImportNestedSetMultipleTree_Item2_1: |
| | 280 | name: Item 2.1 |
| | 281 | |
| | 282 | ImportNestedSetMultipleTree_Item2_2: |
| | 283 | name: Item 2.2 |
| | 284 | |
| | 285 | children: |
| | 286 | ImportNestedSetMultipleTree_Item2_2_1: |
| | 287 | name: Item 2.2.1 |
| | 288 | |
| | 289 | ImportNestedSetMultipleTree_Item2_2_2: |
| | 290 | name: Item 2.2.2 |
| | 291 | |
| | 292 | ImportNestedSetMultipleTree_Item2_2_3: |
| | 293 | name: Item 2.2.3 |
| | 294 | END; |
| | 295 | try { |
| | 296 | file_put_contents('test.yml', $yml); |
| | 297 | Doctrine::loadData('test.yml'); |
| | 298 | |
| | 299 | $this->conn->clear(); |
| | 300 | |
| | 301 | $query = Doctrine_Query::create() |
| | 302 | ->from('ImportNestedSetMultipleTree insmt') |
| | 303 | ->orderBy('insmt.root_id ASC, insmt.lft ASC'); |
| | 304 | |
| | 305 | $i = $query->execute(array(), Doctrine::FETCH_ARRAY); |
| | 306 | |
| | 307 | $this->assertEqual($i[0]['name'], 'Item 1'); |
| | 308 | $this->assertEqual($i[0]['lft'], 1); |
| | 309 | $this->assertEqual($i[0]['rgt'], 6); |
| | 310 | $this->assertEqual($i[0]['level'], 0); |
| | 311 | $this->assertEqual($i[0]['root_id'], '1'); |
| | 312 | |
| | 313 | $this->assertEqual($i[1]['name'], 'Item 1.1'); |
| | 314 | $this->assertEqual($i[1]['lft'], 2); |
| | 315 | $this->assertEqual($i[1]['rgt'], 3); |
| | 316 | $this->assertEqual($i[1]['level'], 1); |
| | 317 | $this->assertEqual($i[1]['root_id'], $i[0]['root_id']); |
| | 318 | |
| | 319 | $this->assertEqual($i[3]['name'], 'Item 2'); |
| | 320 | $this->assertEqual($i[3]['lft'], 1); |
| | 321 | $this->assertEqual($i[3]['rgt'], 12); |
| | 322 | $this->assertEqual($i[3]['level'], 0); |
| | 323 | $this->assertEqual($i[3]['root_id'], '2'); |
| | 324 | |
| | 325 | $this->assertEqual($i[4]['name'], 'Item 2.1'); |
| | 326 | $this->assertEqual($i[4]['lft'], 2); |
| | 327 | $this->assertEqual($i[4]['rgt'], 3); |
| | 328 | $this->assertEqual($i[4]['level'], 1); |
| | 329 | $this->assertEqual($i[4]['root_id'], $i[3]['root_id']); |
| | 330 | |
| | 331 | $this->assertEqual($i[5]['name'], 'Item 2.2'); |
| | 332 | $this->assertEqual($i[5]['lft'], 4); |
| | 333 | $this->assertEqual($i[5]['rgt'], 11); |
| | 334 | $this->assertEqual($i[5]['level'], 1); |
| | 335 | $this->assertEqual($i[5]['root_id'], $i[3]['root_id']); |
| | 336 | |
| | 337 | $this->pass(); |
| | 338 | } catch (Exception $e) { |
| | 339 | $this->fail(); |
| | 340 | } |
| | 341 | |
| | 342 | unlink('test.yml'); |
| | 343 | } |