Skip to content

Commit

Permalink
Major unit test cleanup & organizing
Browse files Browse the repository at this point in the history
- Docblock all methods
- Break fixtures out of test code
- Organize all support classes into lib directory
- Concrete test classes for abstract classes
  • Loading branch information
Ben Batschelet committed Jan 2, 2017
1 parent 85eb18c commit 13e0b15
Show file tree
Hide file tree
Showing 29 changed files with 766 additions and 350 deletions.
317 changes: 108 additions & 209 deletions tests/Database/IndirectAttachTest.php

Large diffs are not rendered by default.

91 changes: 0 additions & 91 deletions tests/Database/TestCase.php

This file was deleted.

9 changes: 9 additions & 0 deletions tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@
use BeBat\PolyTree\Relations;
use PHPUnit_Framework_TestCase as TestCase;

/**
* Test the covenience model methods.
*
* @package BeBat\PolyTree
* @subpackage Test
*/
class ModelTest extends TestCase
{
/**
* Test that our relationship aliases return classes of the expected type.
*/
public function testRelationshipAliases()
{
$model = new TestModel();
Expand Down
19 changes: 19 additions & 0 deletions tests/NodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,29 @@
use BeBat\PolyTree\Relations;
use PHPUnit_Framework_TestCase as TestCase;

/**
* Test methods built into the Node trait.
*
* @package BeBat\PolyTree
* @subpackage Test
*/
class NodeTest extends TestCase
{
/** @var BeBat\PolyTree\Test\TestModel */
protected $model;

/**
* Instantiate our test model and hard code its table name.
*/
protected function setUp()
{
$this->model = new TestModel();
$this->model->setTable('nodes');
}

/**
* Test methods for getting & setting related table names.
*/
public function testTableNames()
{
verify('generates a relation table name', $this->model->getRelationsTable())->equals('node_relations');
Expand All @@ -27,6 +40,9 @@ public function testTableNames()
verify('uses hard coded ancestry table name', $this->model->getAncestryTable())->equals('overriden_ancestry');
}

/**
* Test methods for getting & setting related table column names.
*/
public function testColumNames()
{
verify('generates parent key name', $this->model->getParentKeyname())->equals('parent_node_id');
Expand All @@ -45,6 +61,9 @@ public function testColumNames()
verify('uses had coded descendant key name', $this->model->getDescendantKeyName())->equals('overriden_descendant_id');
}

/**
* Test methods for getting underlying relationships.
*/
public function testRelationMethods()
{
verify($this->model->hasParents())->isInstanceOf(Relations\HasParents::class);
Expand Down
Loading

0 comments on commit 13e0b15

Please sign in to comment.