Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Hydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace PowerLinks\OpenRtb;

use PowerLinks\OpenRtb\BidRequest\Banner;
use PowerLinks\OpenRtb\Tools\ObjectAnalyzer\ObjectDescriberFactory;
use PowerLinks\OpenRtb\Tools\ObjectAnalyzer\ObjectDescriber;

Expand Down Expand Up @@ -111,6 +112,10 @@ protected static function getDependencyClassName(ObjectDescriber $objectDescribe
if ($key == 'ArrayCollection') {
return 'PowerLinks\OpenRtb\Tools\Classes\ArrayCollection';
}
if ($key == 'Companionad') {
return Banner::class;
}

return $objectDescriber->getNamespace().'\\'.$key;
}

Expand Down
35 changes: 35 additions & 0 deletions tests/HydratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace PowerLinks\OpenRtb\Tests;

use PHPUnit_Framework_TestCase;
use PowerLinks\OpenRtb\BidRequest\Banner;
use PowerLinks\OpenRtb\BidRequest\BidRequest;
use PowerLinks\OpenRtb\BidRequest\Native;
use PowerLinks\OpenRtb\Hydrator;
Expand Down Expand Up @@ -95,6 +96,40 @@ public function testHydrateRecursive($json)
Hydrator::hydrate(json_decode($json, true), new BidRequest());
}

public function testHydrateWithCompanionad()
{
$json = <<< JSON
{
"id": "foo",
"imp": [
{
"id": "1",
"video": {
"companionad": [
{
"w": 0,
"h": 0,
"mimes": [
"image/gif",
"image/jpeg",
"image/png",
"video/x-flv"
]
}
]
}
}
]
}
JSON;

$object = new BidRequest();

Hydrator::hydrate(json_decode($json, true), $object);

$this->assertInstanceOf(Banner::class, $object->getImp()->current()->getVideo()->getCompanionad()->current());
}

public function jsonProvider()
{
return [
Expand Down