|
5 | 5 | use Console_Table; |
6 | 6 | use Doctrine\DBAL\Configuration; |
7 | 7 | use Doctrine\DBAL\DriverManager; |
8 | | -use Doctrine\DBAL\Schema\Schema; |
9 | 8 | use PNX\NestedSet\Node; |
10 | 9 | use PNX\NestedSet\Storage\DbalNestedSet; |
| 10 | +use PNX\NestedSet\Storage\DbalNestedSetSchema; |
11 | 11 |
|
12 | 12 | /** |
13 | 13 | * Tests the Dbal Tree implementation. |
@@ -37,18 +37,25 @@ class DbalNestedSetTest extends \PHPUnit_Framework_TestCase { |
37 | 37 | */ |
38 | 38 | protected $tableName = 'nested_set'; |
39 | 39 |
|
| 40 | + /** |
| 41 | + * The nested set schema. |
| 42 | + * |
| 43 | + * @var \PNX\NestedSet\Storage\DbalNestedSetSchema |
| 44 | + */ |
| 45 | + protected $schema; |
| 46 | + |
40 | 47 | /** |
41 | 48 | * {@inheritdoc} |
42 | 49 | */ |
43 | 50 | protected function setUp() { |
44 | | - if ($this->connection === NULL) { |
45 | | - $this->connection = DriverManager::getConnection([ |
46 | | - 'url' => 'sqlite:///:memory:', |
47 | | - ], new Configuration()); |
48 | | - $this->createTable(); |
49 | | - $this->loadTestData(); |
50 | | - $this->nestedSet = new DbalNestedSet($this->connection, $this->tableName); |
51 | | - } |
| 51 | + $this->connection = DriverManager::getConnection([ |
| 52 | + 'url' => 'sqlite:///:memory:', |
| 53 | + ], new Configuration()); |
| 54 | + |
| 55 | + $this->schema = new DbalNestedSetSchema($this->connection, $this->tableName); |
| 56 | + $this->schema->create(); |
| 57 | + $this->loadTestData(); |
| 58 | + $this->nestedSet = new DbalNestedSet($this->connection, $this->tableName); |
52 | 59 | } |
53 | 60 |
|
54 | 61 | /** |
@@ -423,34 +430,6 @@ public function testValidateTableInvalidFirstChars() { |
423 | 430 | $this->nestedSet = new DbalNestedSet($this->connection, "1abc"); |
424 | 431 | } |
425 | 432 |
|
426 | | - /** |
427 | | - * Drops the table. |
428 | | - */ |
429 | | - protected function dropTable() { |
430 | | - $schema = new Schema(); |
431 | | - $schema->dropTable("tree"); |
432 | | - foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) { |
433 | | - $this->connection->exec($sql); |
434 | | - } |
435 | | - } |
436 | | - |
437 | | - /** |
438 | | - * Creates the table. |
439 | | - */ |
440 | | - protected function createTable() { |
441 | | - $schema = new Schema(); |
442 | | - $tree = $schema->createTable($this->tableName); |
443 | | - $tree->addColumn("id", "integer", ["unsigned" => TRUE]); |
444 | | - $tree->addColumn("revision_id", "integer", ["unsigned" => TRUE]); |
445 | | - $tree->addColumn("left_pos", "integer", ["unsigned" => TRUE]); |
446 | | - $tree->addColumn("right_pos", "integer", ["unsigned" => TRUE]); |
447 | | - $tree->addColumn("depth", "integer", ["unsigned" => TRUE]); |
448 | | - |
449 | | - foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) { |
450 | | - $this->connection->exec($sql); |
451 | | - } |
452 | | - } |
453 | | - |
454 | 433 | /** |
455 | 434 | * Loads the test data. |
456 | 435 | */ |
|
0 commit comments