Skip to content

Commit ab85062

Browse files
committed
MAGETWO-69240: Unit Tests have different behavior between run for a bunch and a single test
- Mocked ObjectManager should return mocks
1 parent 768261d commit ab85062

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/internal/Magento/Framework/TestFramework/Unit/Listener/ReplaceObjectManager.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ public function startTest(\PHPUnit_Framework_Test $test)
3232
if ($test instanceof \PHPUnit_Framework_TestCase) {
3333
$objectManagerMock = $test->getMockBuilder(ObjectManagerInterface::class)
3434
->getMockForAbstractClass();
35+
$createMockCallback = function ($type) use ($test) {
36+
return $test->getMockBuilder($type)
37+
->disableOriginalConstructor()
38+
->getMockForAbstractClass();
39+
};
40+
$objectManagerMock->method('create')->willReturnCallback($createMockCallback);
41+
$objectManagerMock->method('get')->willReturnCallback($createMockCallback);
3542
ObjectManager::setInstance($objectManagerMock);
3643
}
3744
}

0 commit comments

Comments
 (0)