Skip to content

Commit bc03413

Browse files
author
Ben Roberts
committed
Merge branch 'master' into guzzle_5_backport
2 parents 64a91e7 + b7c7eba commit bc03413

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/Renderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ protected function createJobs()
235235
return array_map(function (\WF\Hypernova\Job $job) {
236236
foreach ($this->plugins as $plugin) {
237237
try {
238-
$job = new Job($job->name, $plugin->getViewData($job->name, (array) $job->data));
238+
$job = new Job($job->name, $plugin->getViewData($job->name, (array) $job->data), $job->metadata);
239239
} catch (\Exception $e) {
240240
$plugin->onError($e, $this->incomingJobs);
241241
}

tests/RendererTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,23 @@ public function testCreateJobs()
6666
$this->assertArrayHasKey('id1', $this->callInternalMethodOfThing($this->renderer, 'createJobs'));
6767
}
6868

69+
public function testCreateJobsWithMetadata()
70+
{
71+
$plugin = $this->createMock(BasePlugin::class);
72+
73+
$job = ['name' => 'foo', 'data' => ['someData' => []], 'metadata' => ['some_other' => 'foo']];
74+
75+
$plugin->expects($this->once())
76+
->method('getViewData')
77+
->with($this->equalTo($job['name']), $this->equalTo($job['data']))
78+
->willReturn($job['data']);
79+
$this->renderer->addPlugin($plugin);
80+
$this->renderer->addJob('id1', $job);
81+
$createdJobs = $this->callInternalMethodOfThing($this->renderer, 'createJobs');
82+
$this->assertObjectHasAttribute('metadata', $createdJobs['id1']);
83+
$this->assertEquals('foo', $createdJobs['id1']->metadata['some_other']);
84+
}
85+
6986
public function testMultipleJobsGetCreated()
7087
{
7188
$plugin = $this->createMock(BasePlugin::class);

0 commit comments

Comments
 (0)