Skip to content

Commit

Permalink
Add basic setup tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SMillerDev committed Sep 21, 2016
1 parent 3a8cf9a commit f5fa874
Show file tree
Hide file tree
Showing 10 changed files with 246 additions and 50 deletions.
55 changes: 6 additions & 49 deletions src/PHPDraft/Model/Elements/Tests/ArrayStructureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ArrayStructureTest extends TestBase
public function setUp()
{
$this->class = new ArrayStructureElement();
$this->reflection = new \ReflectionClass('PHPDraft\Model\DataStructureElement');
$this->reflection = new \ReflectionClass('PHPDraft\Model\Elements\ArrayStructureElement');
}

public function tearDown()
Expand All @@ -26,56 +26,13 @@ public function tearDown()
unset($this->reflection);
}

//
/**
// * Parse different objects
// *
// * @dataProvider parseObjectProvider
// *
// * @param string $object JSON Object
// * @param ArrayStructureElement $expected Expected Object output
// */
// public function testSuccesfulParse($object, $expected)
// {
// $dep = [];
// $this->class->parse(json_decode($object), $dep);
// $this->assertSame($this->class->key, $expected->key);
// $this->assertSame($this->class->value, $expected->value);
// $this->assertSame($this->class->element, $expected->element);
// $this->assertSame($this->class->type, $expected->type);
// }
/**
* Provide objects to parse including expected outcome
*
* @return array
* Test if the value the class is initialized with is correct
*/
public function parseObjectProvider()
public function testSetupCorrectly()
{
$return = [];
$base1 = new ArrayStructureElement();
$base1->key = 'Content-Type';
$base1->value = 'application/json';
$base1->element = 'member';
$base1->type = 'Struct2';

$base2 = new ArrayStructureElement();
$base2->key = 'Auth2';
$base2->value = 'something';
$base2->element = 'member';
$base2->type = 'Struct1';

// $return[] = [
// '{"element": "member", "meta": { "description": "Files to be added. Need to be downloaded from the server. Contains relative paths"},
// "attributes": { "typeAttributes": ["required"]},"content": {"key": {"element": "string","content": "add"},"value": {"element": "array"}}}',
// $base1,
// ];
// $return[] = [
// '{"element":"member","meta":{"description":"A json array of categories associated with the item"},"attributes":{"typeAttributes":["required"]},
// "content":{"key":{"element":"string","content":"categoryIds"},"value":{"element":"array","content":[{"element":"string",
// "content":"\"[\"111\",\"222\",\"333\"]\""}]}}}',
// $base2,
// ];

return $return;
$property = $this->reflection->getProperty('element');
$property->setAccessible(TRUE);
$this->assertNull($property->getValue($this->class));
}
}
21 changes: 21 additions & 0 deletions src/PHPDraft/Model/Elements/Tests/RequestBodyElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,29 @@


use PHPDraft\Core\TestBase;
use PHPDraft\Model\Elements\RequestBodyElement;

class RequestBodyElementTest extends TestBase
{
public function setUp()
{
$this->class = new RequestBodyElement();
$this->reflection = new \ReflectionClass('PHPDraft\Model\Elements\RequestBodyElement');
}

public function tearDown()
{
unset($this->class);
unset($this->reflection);
}

/**
* Test if the value the class is initialized with is correct
*/
public function testSetupCorrectly()
{
$property = $this->reflection->getProperty('element');
$property->setAccessible(TRUE);
$this->assertNull($property->getValue($this->class));
}
}
28 changes: 28 additions & 0 deletions src/PHPDraft/Model/Tests/CategoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,36 @@


use PHPDraft\Core\TestBase;
use PHPDraft\Model\Category;
use ReflectionClass;

class CategoryTest extends TestBase
{
/**
* Set up
*/
public function setUp()
{
$this->class = new Category();
$this->reflection = new ReflectionClass('PHPDraft\Model\Category');
}

/**
* Tear down
*/
public function tearDown()
{
unset($this->class);
unset($this->reflection);
}

/**
* Test if the value the class is initialized with is correct
*/
public function testSetupCorrectly()
{
$property = $this->reflection->getProperty('parent');
$property->setAccessible(TRUE);
$this->assertNull($property->getValue($this->class));
}
}
30 changes: 30 additions & 0 deletions src/PHPDraft/Model/Tests/HTTPRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,38 @@


use PHPDraft\Core\TestBase;
use PHPDraft\Model\HTTPRequest;
use PHPDraft\Model\Transition;
use ReflectionClass;

class HTTPRequestTest extends TestBase
{
/**
* Set up
*/
public function setUp()
{
$parent = NULL;
$this->class = new HTTPRequest($parent);
$this->reflection = new ReflectionClass('PHPDraft\Model\HTTPRequest');
}

/**
* Tear down
*/
public function tearDown()
{
unset($this->class);
unset($this->reflection);
}

/**
* Test if the value the class is initialized with is correct
*/
public function testSetupCorrectly()
{
$property = $this->reflection->getProperty('parent');
$property->setAccessible(TRUE);
$this->assertNull($property->getValue($this->class));
}
}
29 changes: 29 additions & 0 deletions src/PHPDraft/Model/Tests/HTTPResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,37 @@


use PHPDraft\Core\TestBase;
use PHPDraft\Model\HTTPResponse;
use ReflectionClass;

class HTTPResponseTest extends TestBase
{
/**
* Set up
*/
public function setUp()
{
$parent = NULL;
$this->class = new HTTPResponse($parent);
$this->reflection = new ReflectionClass('PHPDraft\Model\HTTPResponse');
}

/**
* Tear down
*/
public function tearDown()
{
unset($this->class);
unset($this->reflection);
}

/**
* Test if the value the class is initialized with is correct
*/
public function testSetupCorrectly()
{
$property = $this->reflection->getProperty('parent');
$property->setAccessible(TRUE);
$this->assertNull($property->getValue($this->class));
}
}
27 changes: 27 additions & 0 deletions src/PHPDraft/Model/Tests/HierarchyElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,35 @@


use PHPDraft\Core\TestBase;
use ReflectionClass;

class HierarchyElementTest extends TestBase
{
/**
* Set up
*/
public function setUp()
{
$this->class = $this->getMockForAbstractClass('PHPDraft\Model\HierarchyElement');
$this->reflection = new ReflectionClass('PHPDraft\Model\HierarchyElement');
}

/**
* Tear down
*/
public function tearDown()
{
unset($this->class);
unset($this->reflection);
}

/**
* Test if the value the class is initialized with is correct
*/
public function testSetupCorrectly()
{
$property = $this->reflection->getProperty('parent');
$property->setAccessible(TRUE);
$this->assertNull($property->getValue($this->class));
}
}
29 changes: 29 additions & 0 deletions src/PHPDraft/Model/Tests/ResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,37 @@


use PHPDraft\Core\TestBase;
use PHPDraft\Model\Resource;
use ReflectionClass;

class ResourceTest extends TestBase
{
/**
* Set up
*/
public function setUp()
{
$parent = NULL;
$this->class = new Resource($parent);
$this->reflection = new ReflectionClass('PHPDraft\Model\Resource');
}

/**
* Tear down
*/
public function tearDown()
{
unset($this->class);
unset($this->reflection);
}

/**
* Test if the value the class is initialized with is correct
*/
public function testSetupCorrectly()
{
$property = $this->reflection->getProperty('parent');
$property->setAccessible(TRUE);
$this->assertNull($property->getValue($this->class));
}
}
29 changes: 29 additions & 0 deletions src/PHPDraft/Model/Tests/TransitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,37 @@


use PHPDraft\Core\TestBase;
use PHPDraft\Model\Transition;
use ReflectionClass;

class TransitionTest extends TestBase
{
/**
* Set up
*/
public function setUp()
{
$parent = NULL;
$this->class = new Transition($parent);
$this->reflection = new ReflectionClass('PHPDraft\Model\Transition');
}

/**
* Tear down
*/
public function tearDown()
{
unset($this->class);
unset($this->reflection);
}

/**
* Test if the value the class is initialized with is correct
*/
public function testSetupCorrectly()
{
$property = $this->reflection->getProperty('parent');
$property->setAccessible(TRUE);
$this->assertNull($property->getValue($this->class));
}
}
24 changes: 24 additions & 0 deletions src/PHPDraft/Out/Tests/TemplateGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,32 @@


use PHPDraft\Core\TestBase;
use PHPDraft\Out\TemplateGenerator;

class TemplateGeneratorTest extends TestBase
{
public function setUp()
{
$this->class = new TemplateGenerator('default', 'none');
$this->reflection = new \ReflectionClass('PHPDraft\Out\TemplateGenerator');
}

public function tearDown()
{
unset($this->class);
unset($this->reflection);
}

/**
* Test if the value the class is initialized with is correct
*/
public function testSetupCorrectly()
{
$property = $this->reflection->getProperty('template');
$property->setAccessible(TRUE);
$this->assertSame('default', $property->getValue($this->class));
$property = $this->reflection->getProperty('image');
$property->setAccessible(TRUE);
$this->assertSame('none', $property->getValue($this->class));
}
}
Loading

0 comments on commit f5fa874

Please sign in to comment.