Skip to content

Commit 0b5af03

Browse files
committed
Cleanup & splitting of tests.
1 parent 4cede91 commit 0b5af03

28 files changed

+2334
-1516
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ language: php
33
php:
44
- 5.4
55
- 5.5
6+
- 5.6
67

78
before_script:
89
- curl -s http://getcomposer.org/installer | php

bootstrap.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@
1919
$capsule->setAsGlobal();
2020

2121
/**
22-
* Manually load some required models
22+
* Autoload required libraries
2323
*/
24-
require __DIR__.'/tests/models/Category.php';
25-
require __DIR__.'/tests/models/OrderedCategory.php';
26-
require __DIR__.'/tests/models/ScopedCategory.php';
27-
require __DIR__.'/tests/models/Menu.php';
28-
require __DIR__.'/tests/models/Rank.php';
24+
$__autoload_paths = array('models', 'migrators', 'seeders');
25+
26+
foreach($__autoload_paths as $path) {
27+
foreach(glob(__DIR__ . "/tests/$path/*.php") as $dep) {
28+
require_once $dep;
29+
}
30+
}
31+
32+
/**
33+
* Require test helpers
34+
*/
35+
require __DIR__ . '/tests/suite/CategoryTestCase.php';
36+
require __DIR__ . '/tests/suite/ClusterTestCase.php';

boris

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,11 @@
44
require __DIR__.'/bootstrap.php';
55

66
// Prepare the DB
7-
require __DIR__.'/tests/BaumTest.php';
8-
BaumTest::setUpBeforeClass();
7+
with(new CategoryMigrator)->up();
8+
with(new ClusterMigrator)->up();
99

1010
// Seed the database with some data
11-
ScopedCategory::unguard();
12-
13-
$root1 = ScopedCategory::create(array('id' => 1 , 'company_id' => 1, 'name' => 'Root 1' , 'lft' => 1 , 'rgt' => 10 , 'depth' => 0));
14-
$child1 = ScopedCategory::create(array('id' => 2 , 'company_id' => 1, 'name' => 'Child 1' , 'lft' => 2 , 'rgt' => 3 , 'depth' => 1, 'parent_id' => 1));
15-
$child2 = ScopedCategory::create(array('id' => 3 , 'company_id' => 1, 'name' => 'Child 2' , 'lft' => 4 , 'rgt' => 7 , 'depth' => 1, 'parent_id' => 1));
16-
$child21 = ScopedCategory::create(array('id' => 4 , 'company_id' => 1, 'name' => 'Child 2.1', 'lft' => 5 , 'rgt' => 6 , 'depth' => 2, 'parent_id' => 3));
17-
$child3 = ScopedCategory::create(array('id' => 5 , 'company_id' => 1, 'name' => 'Child 3' , 'lft' => 8 , 'rgt' => 9 , 'depth' => 1, 'parent_id' => 1));
18-
$root2 = ScopedCategory::create(array('id' => 6 , 'company_id' => 2, 'name' => 'Root 2' , 'lft' => 1 , 'rgt' => 10 , 'depth' => 0));
19-
$child4 = ScopedCategory::create(array('id' => 7 , 'company_id' => 2, 'name' => 'Child 4' , 'lft' => 2 , 'rgt' => 3 , 'depth' => 1, 'parent_id' => 6));
20-
$child5 = ScopedCategory::create(array('id' => 8 , 'company_id' => 2, 'name' => 'Child 5' , 'lft' => 4 , 'rgt' => 7 , 'depth' => 1, 'parent_id' => 6));
21-
$child51 = ScopedCategory::create(array('id' => 9 , 'company_id' => 2, 'name' => 'Child 5.1', 'lft' => 5 , 'rgt' => 6 , 'depth' => 2, 'parent_id' => 8));
22-
$child6 = ScopedCategory::create(array('id' => 10, 'company_id' => 2, 'name' => 'Child 6' , 'lft' => 8 , 'rgt' => 9 , 'depth' => 1, 'parent_id' => 6));
23-
24-
ScopedCategory::reguard();
25-
26-
$connection = $root1->getConnection();
27-
28-
if ( $connection->getDriverName() === 'pgsql' ) {
29-
$tablePrefix = $connection->getTablePrefix();
30-
31-
$sequenceName = $tablePrefix . 'categories_id_seq';
32-
33-
$connection->statement('ALTER SEQUENCE ' . $sequenceName . ' RESTART WITH 11');
34-
}
11+
// ...
3512

3613
// Set up a custom inspector for our models
3714
class BaumNodeInspector extends \Boris\ColoredInspector {
@@ -43,7 +20,8 @@ class BaumNodeInspector extends \Boris\ColoredInspector {
4320
}
4421
}
4522

46-
// Start-up boris REPL and import our nodes into the context
23+
// Start-up boris REPL and import any defined var (in scope) which happens to be
24+
// a Baum\Node instance into the context
4725
$boris = new \Boris\Boris('> ');
4826

4927
$boris->setInspector(new BaumNodeInspector);

phpunit.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
syntaxCheck="false">
1212
<testsuites>
1313
<testsuite name="Baum Test Suite">
14-
<file>tests/BaumTest.php</file>
15-
<file>tests/QueryBuilderExtensionTest.php</file>
14+
<file>tests/suite/QueryBuilderExtensionTest.php</file>
15+
<file>tests/suite/NodeModelExtensionsTest.php</file>
16+
<directory>tests/suite/Category</directory>
1617
</testsuite>
1718
</testsuites>
1819
</phpunit>

0 commit comments

Comments
 (0)