Skip to content

Commit

Permalink
Fix decorating (#16)
Browse files Browse the repository at this point in the history
Decorating wasn't setting an array correctly...
  • Loading branch information
rickselby committed May 14, 2018
1 parent cef315c commit 056bb1d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/AutoPresenterMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ public function map($class, $presenter = null)
*/
public function decorate($class)
{
$this->map($class, null);
if (is_array($class)) {
foreach ($class as $model) {
$this->mappings->put($model, null);
}
} else {
$this->mappings->put($class, null);
}
}

/**
Expand Down
11 changes: 11 additions & 0 deletions tests/AutoPresenterMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public function testDecoratingReturnsNoClass()
$this->assertNull($this->autoPresenterMapper->getPresenter(new MappedStub()));
}

public function testDecoratingAsArray()
{
$this->setDecoratingAsArray();
$this->assertTrue($this->autoPresenterMapper->hasPresenter(new MappedStub()));
}

protected function getMappedStub()
{
return new MappedStub();
Expand All @@ -85,4 +91,9 @@ protected function setDecorating()
{
$this->autoPresenterMapper->decorate(MappedStub::class);
}

protected function setDecoratingAsArray()
{
$this->autoPresenterMapper->decorate([MappedStub::class]);
}
}

0 comments on commit 056bb1d

Please sign in to comment.