Skip to content

Commit a3c768a

Browse files
committed
test: add test
1 parent b482774 commit a3c768a

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

tests/system/Config/FactoriesTest.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ public function testCanLoadTwoCellsWithSameShortName()
321321
$this->assertNotSame($cell1, $cell2);
322322
}
323323

324-
public function testDefineTwice()
324+
public function testDefineSameAliasTwiceWithDifferentClasses()
325325
{
326326
$this->expectException(InvalidArgumentException::class);
327327
$this->expectExceptionMessage(
@@ -340,6 +340,24 @@ public function testDefineTwice()
340340
);
341341
}
342342

343+
public function testDefineSameAliasAndSameClassTwice()
344+
{
345+
Factories::define(
346+
'models',
347+
'CodeIgniter\Shield\Models\UserModel',
348+
UserModel::class
349+
);
350+
Factories::define(
351+
'models',
352+
'CodeIgniter\Shield\Models\UserModel',
353+
UserModel::class
354+
);
355+
356+
$model = model('CodeIgniter\Shield\Models\UserModel');
357+
358+
$this->assertInstanceOf(UserModel::class, $model);
359+
}
360+
343361
public function testDefineNonExistentClass()
344362
{
345363
$this->expectException(InvalidArgumentException::class);

0 commit comments

Comments
 (0)