Skip to content

Commit

Permalink
typo
Browse files Browse the repository at this point in the history
  • Loading branch information
janpecha committed Nov 21, 2015
1 parent c362d2a commit 6372c0b
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/LeanMapperExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ protected function processEntityProviders(ServiceDefinition $mapper, array $conf
$mappings = $extension->getEntityMappings();

if (!is_array($mappings) && !is_null($mappings)) {
throw new \InvalidArgumentException('Mappings must be array or NULL, '. gettype($mapping) . ' given.');
throw new \InvalidArgumentException('Mappings must be array or NULL, '. gettype($mappings) . ' given.');
}

if (is_array($mappings)) {
foreach ($mappings as $mapping) {
if (!is_array($mappings) && !is_null($mappings)) {
if (!is_array($mapping) && !is_null($mapping)) {
throw new \InvalidArgumentException('Entity mapping must be array or NULL, '. gettype($mapping) . ' given.');
}
$this->registerInMapper($mapper, $mapping);
Expand Down
36 changes: 36 additions & 0 deletions tests/LeanMapperExtension/Extension.entityProviders.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,28 @@ namespace Foo\DI {
);
}
}


class FooBrokenExtension extends CompilerExtension implements IEntityProvider
{
// from IEntityProvider
function getEntityMappings()
{
return 'broken';
}
}


class FooBrokenMappingExtension extends CompilerExtension implements IEntityProvider
{
// from IEntityProvider
function getEntityMappings()
{
return array(
'broken',
);
}
}
}

namespace {
Expand All @@ -55,4 +77,18 @@ namespace {
Assert::same('foo_articles', $mapper->getTable('Foo\Model\Article'));
Assert::same('article_id', $mapper->getPrimaryKey('foo_articles'));
});


test(function () {
Assert::exception(function () {
$container = createContainer('addons.broken');
}, 'InvalidArgumentException', 'Mappings must be array or NULL, string given.');
});


test(function () {
Assert::exception(function () {
$container = createContainer('addons.broken-mapping');
}, 'InvalidArgumentException', 'Entity mapping must be array or NULL, string given.');
});
}
11 changes: 11 additions & 0 deletions tests/LeanMapperExtension/config/addons.broken-mapping.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

extensions:
foo: Foo\DI\FooBrokenMappingExtension

leanmapper:
# database connection
user: foo
password: bar
database: foobar

driver: fakeMysql
11 changes: 11 additions & 0 deletions tests/LeanMapperExtension/config/addons.broken.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

extensions:
foo: Foo\DI\FooBrokenExtension

leanmapper:
# database connection
user: foo
password: bar
database: foobar

driver: fakeMysql

0 comments on commit 6372c0b

Please sign in to comment.