File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
src/Dflydev/Pimple/Provider/DoctrineOrm
tests/Dflydev/Pimple/Provider/DoctrineOrm Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,12 @@ public function register(\Pimple $app)
116116
117117 $ chain = $ app ['orm.mapping_driver_chain.locator ' ]($ name );
118118 foreach ((array ) $ options ['mappings ' ] as $ entity ) {
119+ if (!is_array ($ entity )) {
120+ throw new \InvalidArgumentException (
121+ "The 'orm.em.options' option 'mappings' should be an array of arrays. "
122+ );
123+ }
124+
119125 if (!empty ($ entity ['resources_namespace ' ])) {
120126 $ entity ['path ' ] = $ app ['psr0_resource_locator ' ]->findFirstDirectory ($ entity ['resources_namespace ' ]);
121127 }
Original file line number Diff line number Diff line change @@ -258,4 +258,28 @@ public function testNameFromParamKey()
258258 $ this ->assertEquals ('foo ' , $ app ['orm.em_name_from_param_key ' ]('my.bar ' ));
259259 $ this ->assertEquals ('baz ' , $ app ['orm.em_name_from_param_key ' ]('my.baz ' ));
260260 }
261+
262+ /**
263+ * Test specifying an invalid mapping configuration (not an array of arrays)
264+ *
265+ * @expectedException InvalidArgumentException
266+ * @expectedExceptionMessage The 'orm.em.options' option 'mappings' should be an array of arrays.
267+ */
268+ public function testInvalidMappingAsOption ()
269+ {
270+ $ app = $ this ->createMockDefaultApp ();
271+
272+ $ doctrineOrmServiceProvider = new DoctrineOrmServiceProvider ;
273+ $ doctrineOrmServiceProvider ->register ($ app );
274+
275+ $ app ['orm.em.options ' ] = array (
276+ 'mappings ' => array (
277+ 'type ' => 'annotation ' ,
278+ 'namespace ' => 'Foo\Entities ' ,
279+ 'path ' => __DIR__ .'/src/Foo/Entities ' ,
280+ ),
281+ );
282+
283+ $ app ['orm.ems.config ' ];
284+ }
261285}
You can’t perform that action at this time.
0 commit comments