Skip to content

Commit f5fa874

Browse files
committed
Add basic setup tests
1 parent 3a8cf9a commit f5fa874

10 files changed

+246
-50
lines changed

src/PHPDraft/Model/Elements/Tests/ArrayStructureTest.php

+6-49
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ArrayStructureTest extends TestBase
1717
public function setUp()
1818
{
1919
$this->class = new ArrayStructureElement();
20-
$this->reflection = new \ReflectionClass('PHPDraft\Model\DataStructureElement');
20+
$this->reflection = new \ReflectionClass('PHPDraft\Model\Elements\ArrayStructureElement');
2121
}
2222

2323
public function tearDown()
@@ -26,56 +26,13 @@ public function tearDown()
2626
unset($this->reflection);
2727
}
2828

29-
//
3029
/**
31-
// * Parse different objects
32-
// *
33-
// * @dataProvider parseObjectProvider
34-
// *
35-
// * @param string $object JSON Object
36-
// * @param ArrayStructureElement $expected Expected Object output
37-
// */
38-
// public function testSuccesfulParse($object, $expected)
39-
// {
40-
// $dep = [];
41-
// $this->class->parse(json_decode($object), $dep);
42-
// $this->assertSame($this->class->key, $expected->key);
43-
// $this->assertSame($this->class->value, $expected->value);
44-
// $this->assertSame($this->class->element, $expected->element);
45-
// $this->assertSame($this->class->type, $expected->type);
46-
// }
47-
/**
48-
* Provide objects to parse including expected outcome
49-
*
50-
* @return array
30+
* Test if the value the class is initialized with is correct
5131
*/
52-
public function parseObjectProvider()
32+
public function testSetupCorrectly()
5333
{
54-
$return = [];
55-
$base1 = new ArrayStructureElement();
56-
$base1->key = 'Content-Type';
57-
$base1->value = 'application/json';
58-
$base1->element = 'member';
59-
$base1->type = 'Struct2';
60-
61-
$base2 = new ArrayStructureElement();
62-
$base2->key = 'Auth2';
63-
$base2->value = 'something';
64-
$base2->element = 'member';
65-
$base2->type = 'Struct1';
66-
67-
// $return[] = [
68-
// '{"element": "member", "meta": { "description": "Files to be added. Need to be downloaded from the server. Contains relative paths"},
69-
// "attributes": { "typeAttributes": ["required"]},"content": {"key": {"element": "string","content": "add"},"value": {"element": "array"}}}',
70-
// $base1,
71-
// ];
72-
// $return[] = [
73-
// '{"element":"member","meta":{"description":"A json array of categories associated with the item"},"attributes":{"typeAttributes":["required"]},
74-
// "content":{"key":{"element":"string","content":"categoryIds"},"value":{"element":"array","content":[{"element":"string",
75-
// "content":"\"[\"111\",\"222\",\"333\"]\""}]}}}',
76-
// $base2,
77-
// ];
78-
79-
return $return;
34+
$property = $this->reflection->getProperty('element');
35+
$property->setAccessible(TRUE);
36+
$this->assertNull($property->getValue($this->class));
8037
}
8138
}

src/PHPDraft/Model/Elements/Tests/RequestBodyElementTest.php

+21
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,29 @@
1010

1111

1212
use PHPDraft\Core\TestBase;
13+
use PHPDraft\Model\Elements\RequestBodyElement;
1314

1415
class RequestBodyElementTest extends TestBase
1516
{
17+
public function setUp()
18+
{
19+
$this->class = new RequestBodyElement();
20+
$this->reflection = new \ReflectionClass('PHPDraft\Model\Elements\RequestBodyElement');
21+
}
1622

23+
public function tearDown()
24+
{
25+
unset($this->class);
26+
unset($this->reflection);
27+
}
28+
29+
/**
30+
* Test if the value the class is initialized with is correct
31+
*/
32+
public function testSetupCorrectly()
33+
{
34+
$property = $this->reflection->getProperty('element');
35+
$property->setAccessible(TRUE);
36+
$this->assertNull($property->getValue($this->class));
37+
}
1738
}

src/PHPDraft/Model/Tests/CategoryTest.php

+28
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,36 @@
1010

1111

1212
use PHPDraft\Core\TestBase;
13+
use PHPDraft\Model\Category;
14+
use ReflectionClass;
1315

1416
class CategoryTest extends TestBase
1517
{
18+
/**
19+
* Set up
20+
*/
21+
public function setUp()
22+
{
23+
$this->class = new Category();
24+
$this->reflection = new ReflectionClass('PHPDraft\Model\Category');
25+
}
1626

27+
/**
28+
* Tear down
29+
*/
30+
public function tearDown()
31+
{
32+
unset($this->class);
33+
unset($this->reflection);
34+
}
35+
36+
/**
37+
* Test if the value the class is initialized with is correct
38+
*/
39+
public function testSetupCorrectly()
40+
{
41+
$property = $this->reflection->getProperty('parent');
42+
$property->setAccessible(TRUE);
43+
$this->assertNull($property->getValue($this->class));
44+
}
1745
}

src/PHPDraft/Model/Tests/HTTPRequestTest.php

+30
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,38 @@
1010

1111

1212
use PHPDraft\Core\TestBase;
13+
use PHPDraft\Model\HTTPRequest;
14+
use PHPDraft\Model\Transition;
15+
use ReflectionClass;
1316

1417
class HTTPRequestTest extends TestBase
1518
{
19+
/**
20+
* Set up
21+
*/
22+
public function setUp()
23+
{
24+
$parent = NULL;
25+
$this->class = new HTTPRequest($parent);
26+
$this->reflection = new ReflectionClass('PHPDraft\Model\HTTPRequest');
27+
}
1628

29+
/**
30+
* Tear down
31+
*/
32+
public function tearDown()
33+
{
34+
unset($this->class);
35+
unset($this->reflection);
36+
}
37+
38+
/**
39+
* Test if the value the class is initialized with is correct
40+
*/
41+
public function testSetupCorrectly()
42+
{
43+
$property = $this->reflection->getProperty('parent');
44+
$property->setAccessible(TRUE);
45+
$this->assertNull($property->getValue($this->class));
46+
}
1747
}

src/PHPDraft/Model/Tests/HTTPResponseTest.php

+29
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,37 @@
1010

1111

1212
use PHPDraft\Core\TestBase;
13+
use PHPDraft\Model\HTTPResponse;
14+
use ReflectionClass;
1315

1416
class HTTPResponseTest extends TestBase
1517
{
18+
/**
19+
* Set up
20+
*/
21+
public function setUp()
22+
{
23+
$parent = NULL;
24+
$this->class = new HTTPResponse($parent);
25+
$this->reflection = new ReflectionClass('PHPDraft\Model\HTTPResponse');
26+
}
1627

28+
/**
29+
* Tear down
30+
*/
31+
public function tearDown()
32+
{
33+
unset($this->class);
34+
unset($this->reflection);
35+
}
36+
37+
/**
38+
* Test if the value the class is initialized with is correct
39+
*/
40+
public function testSetupCorrectly()
41+
{
42+
$property = $this->reflection->getProperty('parent');
43+
$property->setAccessible(TRUE);
44+
$this->assertNull($property->getValue($this->class));
45+
}
1746
}

src/PHPDraft/Model/Tests/HierarchyElementTest.php

+27
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,35 @@
1010

1111

1212
use PHPDraft\Core\TestBase;
13+
use ReflectionClass;
1314

1415
class HierarchyElementTest extends TestBase
1516
{
17+
/**
18+
* Set up
19+
*/
20+
public function setUp()
21+
{
22+
$this->class = $this->getMockForAbstractClass('PHPDraft\Model\HierarchyElement');
23+
$this->reflection = new ReflectionClass('PHPDraft\Model\HierarchyElement');
24+
}
1625

26+
/**
27+
* Tear down
28+
*/
29+
public function tearDown()
30+
{
31+
unset($this->class);
32+
unset($this->reflection);
33+
}
34+
35+
/**
36+
* Test if the value the class is initialized with is correct
37+
*/
38+
public function testSetupCorrectly()
39+
{
40+
$property = $this->reflection->getProperty('parent');
41+
$property->setAccessible(TRUE);
42+
$this->assertNull($property->getValue($this->class));
43+
}
1744
}

src/PHPDraft/Model/Tests/ResourceTest.php

+29
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,37 @@
1010

1111

1212
use PHPDraft\Core\TestBase;
13+
use PHPDraft\Model\Resource;
14+
use ReflectionClass;
1315

1416
class ResourceTest extends TestBase
1517
{
18+
/**
19+
* Set up
20+
*/
21+
public function setUp()
22+
{
23+
$parent = NULL;
24+
$this->class = new Resource($parent);
25+
$this->reflection = new ReflectionClass('PHPDraft\Model\Resource');
26+
}
1627

28+
/**
29+
* Tear down
30+
*/
31+
public function tearDown()
32+
{
33+
unset($this->class);
34+
unset($this->reflection);
35+
}
36+
37+
/**
38+
* Test if the value the class is initialized with is correct
39+
*/
40+
public function testSetupCorrectly()
41+
{
42+
$property = $this->reflection->getProperty('parent');
43+
$property->setAccessible(TRUE);
44+
$this->assertNull($property->getValue($this->class));
45+
}
1746
}

src/PHPDraft/Model/Tests/TransitionTest.php

+29
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,37 @@
1010

1111

1212
use PHPDraft\Core\TestBase;
13+
use PHPDraft\Model\Transition;
14+
use ReflectionClass;
1315

1416
class TransitionTest extends TestBase
1517
{
18+
/**
19+
* Set up
20+
*/
21+
public function setUp()
22+
{
23+
$parent = NULL;
24+
$this->class = new Transition($parent);
25+
$this->reflection = new ReflectionClass('PHPDraft\Model\Transition');
26+
}
1627

28+
/**
29+
* Tear down
30+
*/
31+
public function tearDown()
32+
{
33+
unset($this->class);
34+
unset($this->reflection);
35+
}
36+
37+
/**
38+
* Test if the value the class is initialized with is correct
39+
*/
40+
public function testSetupCorrectly()
41+
{
42+
$property = $this->reflection->getProperty('parent');
43+
$property->setAccessible(TRUE);
44+
$this->assertNull($property->getValue($this->class));
45+
}
1746
}

src/PHPDraft/Out/Tests/TemplateGeneratorTest.php

+24
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,32 @@
1010

1111

1212
use PHPDraft\Core\TestBase;
13+
use PHPDraft\Out\TemplateGenerator;
1314

1415
class TemplateGeneratorTest extends TestBase
1516
{
17+
public function setUp()
18+
{
19+
$this->class = new TemplateGenerator('default', 'none');
20+
$this->reflection = new \ReflectionClass('PHPDraft\Out\TemplateGenerator');
21+
}
1622

23+
public function tearDown()
24+
{
25+
unset($this->class);
26+
unset($this->reflection);
27+
}
28+
29+
/**
30+
* Test if the value the class is initialized with is correct
31+
*/
32+
public function testSetupCorrectly()
33+
{
34+
$property = $this->reflection->getProperty('template');
35+
$property->setAccessible(TRUE);
36+
$this->assertSame('default', $property->getValue($this->class));
37+
$property = $this->reflection->getProperty('image');
38+
$property->setAccessible(TRUE);
39+
$this->assertSame('none', $property->getValue($this->class));
40+
}
1741
}

0 commit comments

Comments
 (0)