Skip to content

Commit 8629fdd

Browse files
committed
test: update failed test
1 parent 510c73f commit 8629fdd

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎tests/system/Test/FabricatorTest.php‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace CodeIgniter\Test;
1313

14-
use CodeIgniter\Database\ModelFactory;
14+
use CodeIgniter\Config\Factories;
1515
use Tests\Support\Models\EntityModel;
1616
use Tests\Support\Models\EventModel;
1717
use Tests\Support\Models\FabricatorModel;
@@ -98,12 +98,16 @@ public function testConstructorUsesProvidedLocale()
9898

9999
public function testModelUsesNewInstance()
100100
{
101-
// Inject the wrong model for UserModel to show it is ignored by Fabricator
101+
// Inject the wrong model for UserModel
102102
$mock = new FabricatorModel();
103-
ModelFactory::injectMock(UserModel::class, $mock);
103+
Factories::injectMock('models', UserModel::class, $mock);
104104

105105
$fabricator = new Fabricator(UserModel::class);
106-
$this->assertInstanceOf(UserModel::class, $fabricator->getModel());
106+
107+
// Fabricator gets the instance from Factories, so it is FabricatorModel.
108+
$this->assertInstanceOf(FabricatorModel::class, $fabricator->getModel());
109+
// But Fabricator creates a new instance.
110+
$this->assertNotSame($mock, $fabricator->getModel());
107111
}
108112

109113
public function testGetModelReturnsModel()

0 commit comments

Comments
 (0)