Skip to content

Commit b54e58f

Browse files
committed
MC-31920: Let Magento\Framework\Lock\Backend\Database have 2 locks in single connection
- Fix integration tests with creation of DB lock manager via new instead of dummy locker;
1 parent a172c46 commit b54e58f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

dev/tests/integration/testsuite/Magento/Framework/Lock/Backend/DatabaseTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
namespace Magento\Framework\Lock\Backend;
99

10+
use Magento\Framework\App\ResourceConnection;
11+
use Magento\Framework\App\DeploymentConfig;
12+
1013
/**
1114
* \Magento\Framework\Lock\Backend\Database test case
1215
*/
@@ -25,7 +28,10 @@ class DatabaseTest extends \PHPUnit\Framework\TestCase
2528
protected function setUp()
2629
{
2730
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
28-
$this->model = $this->objectManager->create(\Magento\Framework\Lock\Backend\Database::class);
31+
$resourceConnection = $this->objectManager->create(ResourceConnection::class);
32+
$deploymentConfig = $this->objectManager->create(DeploymentConfig::class);
33+
// create object with new otherwise dummy locker is created because of di.xml preference for integration tests
34+
$this->model = new Database($resourceConnection, $deploymentConfig);
2935
}
3036

3137
public function testLockAndUnlock()

dev/tests/integration/testsuite/Magento/MessageQueue/Model/Cron/ConsumersRunnerTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\MessageQueue\Model\Cron;
77

8+
use Magento\Framework\App\DeploymentConfig;
9+
use Magento\Framework\App\ResourceConnection;
10+
use Magento\Framework\Lock\Backend\Database;
811
use Magento\Framework\MessageQueue\Consumer\ConfigInterface as ConsumerConfigInterface;
912
use Magento\Framework\Lock\LockManagerInterface;
1013
use Magento\Framework\App\DeploymentConfig\FileReader;
@@ -83,7 +86,10 @@ protected function setUp()
8386
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
8487
$this->shellMock = $this->getMockBuilder(ShellInterface::class)
8588
->getMockForAbstractClass();
86-
$this->lockManager = $this->objectManager->get(LockManagerInterface::class);
89+
$resourceConnection = $this->objectManager->create(ResourceConnection::class);
90+
$deploymentConfig = $this->objectManager->create(DeploymentConfig::class);
91+
// create object with new otherwise dummy locker is created because of di.xml preference for integration tests
92+
$this->lockManager = new Database($resourceConnection, $deploymentConfig);
8793
$this->consumerConfig = $this->objectManager->get(ConsumerConfigInterface::class);
8894
$this->reader = $this->objectManager->get(FileReader::class);
8995
$this->filesystem = $this->objectManager->get(Filesystem::class);

0 commit comments

Comments
 (0)