Skip to content

Commit

Permalink
100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyoak committed Sep 21, 2015
1 parent 770c23b commit 2bfd2b1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
37 changes: 22 additions & 15 deletions test/Utility/ObjectUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,11 @@ class ObjectUtilsTest extends UtilsBaseTest
private $expectedParsedXml;
private $expectedParsedXmlString;
private $objectToParse;
private $objectParsedIntoArray = [
'details' => [
'media' => [
'image' => [
'anImage.png',
'anotherImage.png',
],
'video' => 'aVideo.mp4',
'audio' => [],
]
]
];

protected function setUp()
{
$this->prepareObjectToParse();

$this->expectedParsedXmlString = '<?xml version="1.0" encoding="UTF-8"?>' .
'<details>' .
'<media>' .
Expand All @@ -36,10 +26,11 @@ protected function setUp()
'<video>aVideo.mp4</video>' .
'<audio/>' .
'</media>' .
'<resource>'.
(string) $this->objectToParse->details->resource .
'</resource>'.
'</details>';

$this->prepareObjectToParse();

$this->expectedParsedXml = simplexml_load_string($this->expectedParsedXmlString);

$this->utils = ObjectUtils::instance();
Expand All @@ -48,9 +39,23 @@ protected function setUp()
/** @test */
public function transformsObjectIntoArray()
{
$expected = [
'details' => [
'media' => [
'image' => [
'anImage.png',
'anotherImage.png',
],
'video' => 'aVideo.mp4',
'audio' => [],
],
'resource' => (string) $this->objectToParse->details->resource,
],
];

$result = $this->utils->toArray($this->objectToParse);

$this->assertSame($this->objectParsedIntoArray, $result);
$this->assertSame($expected, $result);
}

/** @test */
Expand Down Expand Up @@ -94,6 +99,7 @@ public function transformsObjectToArrayDeeply()
'oneMoreValue' => 'Oak',
]
],
'aResource' => (string) $object->aResource,
'aParentProperty' => 5,
];

Expand All @@ -112,6 +118,7 @@ private function prepareObjectToParse()
$media->audio = [];

$details->media = $media;
$details->resource = tmpfile();

$this->objectToParse = new \stdClass();
$this->objectToParse->details = $details;
Expand Down
2 changes: 2 additions & 0 deletions test/Value/DummyClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class DummyClass extends ParentDummyClass
public $aPublicProperty = 'ANOTHER STRING';
private $anObject;
private $anArrayOfObjects;
public $aResource;

public function __construct()
{
Expand All @@ -17,6 +18,7 @@ public function __construct()
$this->anObject,
$this->anObject
];
$this->aResource = tmpfile();
}

/**
Expand Down

0 comments on commit 2bfd2b1

Please sign in to comment.