Skip to content

Commit eb50002

Browse files
authored
Merge pull request #6040 from magento-engcom/2.4-develop-MC-36748
[EngCom] MC-36748: strpos() expects parameter 1 to be string, bool given 2.4-develop
2 parents 18da36b + d3dd40b commit eb50002

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

lib/internal/Magento/Framework/App/ResourceConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public function getTableName($modelEntity, $connectionName = self::DEFAULT_CONNE
178178
list($modelEntity, $tableSuffix) = $modelEntity;
179179
}
180180

181-
$tableName = $modelEntity;
181+
$tableName = (string)$modelEntity;
182182

183183
$mappedTableName = $this->getMappedTableName($tableName);
184184
if ($mappedTableName) {

lib/internal/Magento/Framework/Test/Unit/App/ResourceConnectionTest.php

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function testGetTablePrefixWithInjectedPrefix()
8484

8585
public function testGetTablePrefix()
8686
{
87-
$this->deploymentConfigMock->expects(self::once())
87+
$this->deploymentConfigMock->expects($this->once())
8888
->method('get')
8989
->with(ConfigOptionsListConstants::CONFIG_PATH_DB_PREFIX)
9090
->willReturn('pref_');
@@ -93,10 +93,10 @@ public function testGetTablePrefix()
9393

9494
public function testGetConnectionByName()
9595
{
96-
$this->deploymentConfigMock->expects(self::once())->method('get')
96+
$this->deploymentConfigMock->expects($this->once())->method('get')
9797
->with(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS . '/default')
9898
->willReturn(['config']);
99-
$this->connectionFactoryMock->expects(self::once())->method('create')
99+
$this->connectionFactoryMock->expects($this->once())->method('create')
100100
->with(['config'])
101101
->willReturn('connection');
102102

@@ -112,15 +112,38 @@ public function testGetExistingConnectionByName()
112112
'connections' => ['default_process_' . getmypid() => 'existing_connection']
113113
]
114114
);
115-
$this->deploymentConfigMock->expects(self::never())->method('get');
115+
$this->deploymentConfigMock->expects($this->never())->method('get');
116116

117117
self::assertEquals('existing_connection', $unit->getConnectionByName('default'));
118118
}
119119

120120
public function testCloseConnection()
121121
{
122-
$this->configMock->expects(self::once())->method('getConnectionName')->with('default');
122+
$this->configMock->expects($this->once())->method('getConnectionName')->with('default');
123123

124124
$this->unit->closeConnection('default');
125125
}
126+
127+
public function testGetTableNameWithBoolParam()
128+
{
129+
$this->deploymentConfigMock->expects($this->at(0))
130+
->method('get')
131+
->with(ConfigOptionsListConstants::CONFIG_PATH_DB_PREFIX)
132+
->willReturn('pref_');
133+
$this->deploymentConfigMock->expects($this->at(1))->method('get')
134+
->with('db/connection/default')
135+
->willReturn(['config']);
136+
$this->configMock->expects($this->atLeastOnce())
137+
->method('getConnectionName')
138+
->with('default')
139+
->willReturn('default');
140+
141+
$connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)->getMock();
142+
$connection->expects($this->once())->method('getTableName')->with('pref_1');
143+
$this->connectionFactoryMock->expects($this->once())->method('create')
144+
->with(['config'])
145+
->willReturn($connection);
146+
147+
$this->unit->getTableName(true);
148+
}
126149
}

0 commit comments

Comments
 (0)