Skip to content

Commit e62c267

Browse files
committed
MC-31920: Let Magento\Framework\Lock\Backend\Database have 2 locks in single connection
- Update unit test;
1 parent d35fcab commit e62c267

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

lib/internal/Magento/Framework/Lock/Backend/Database.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
use Magento\Framework\App\DeploymentConfig;
1111
use Magento\Framework\App\ResourceConnection;
1212
use Magento\Framework\Config\ConfigOptionsListConstants;
13-
use Magento\Framework\Exception\AlreadyExistsException;
14-
use Magento\Framework\Phrase;
1513
use Magento\Framework\DB\ExpressionConverter;
14+
use Magento\Framework\Exception\FileSystemException;
15+
use Magento\Framework\Exception\RuntimeException;
1616

1717
/**
1818
* Implementation of the lock manager on the basis of MySQL.
@@ -68,7 +68,8 @@ public function __construct(
6868
* @param string $name lock name
6969
* @param int $timeout How long to wait lock acquisition in seconds, negative value means infinite timeout
7070
* @return bool
71-
* @throws AlreadyExistsException
71+
* @throws FileSystemException
72+
* @throws RuntimeException
7273
* @throws \Zend_Db_Statement_Exception
7374
*/
7475
public function lock(string $name, int $timeout = -1): bool

lib/internal/Magento/Framework/Lock/Test/Unit/Backend/DatabaseTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ protected function setUp()
8585
}
8686

8787
/**
88-
* @throws \Magento\Framework\Exception\AlreadyExistsException
8988
* @throws \Zend_Db_Statement_Exception
9089
*/
9190
public function testLock()
@@ -102,7 +101,6 @@ public function testLock()
102101
}
103102

104103
/**
105-
* @throws \Magento\Framework\Exception\AlreadyExistsException
106104
* @throws \Zend_Db_Statement_Exception
107105
*/
108106
public function testlockWithTooLongName()
@@ -119,9 +117,7 @@ public function testlockWithTooLongName()
119117
}
120118

121119
/**
122-
* @throws \Magento\Framework\Exception\AlreadyExistsException
123120
* @throws \Zend_Db_Statement_Exception
124-
* @expectedException \Magento\Framework\Exception\AlreadyExistsException
125121
*/
126122
public function testlockWithAlreadyAcquiredLockInSameSession()
127123
{
@@ -133,12 +129,11 @@ public function testlockWithAlreadyAcquiredLockInSameSession()
133129
->method('fetchColumn')
134130
->willReturn(true);
135131

136-
$this->database->lock('testLock');
137-
$this->database->lock('differentLock');
132+
$this->assertTrue($this->database->lock('testLock'));
133+
$this->assertTrue($this->database->lock('differentLock'));
138134
}
139135

140136
/**
141-
* @throws \Magento\Framework\Exception\AlreadyExistsException
142137
* @throws \Zend_Db_Statement_Exception
143138
*/
144139
public function testLockWithUnavailableDeploymentConfig()

0 commit comments

Comments
 (0)