Skip to content

Commit

Permalink
Merge pull request #6040 from magento-engcom/2.4-develop-MC-36748
Browse files Browse the repository at this point in the history
[EngCom] MC-36748: strpos() expects parameter 1 to be string, bool given 2.4-develop
  • Loading branch information
sidolov authored Aug 20, 2020
2 parents 18da36b + d3dd40b commit eb50002
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/internal/Magento/Framework/App/ResourceConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function getTableName($modelEntity, $connectionName = self::DEFAULT_CONNE
list($modelEntity, $tableSuffix) = $modelEntity;
}

$tableName = $modelEntity;
$tableName = (string)$modelEntity;

$mappedTableName = $this->getMappedTableName($tableName);
if ($mappedTableName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testGetTablePrefixWithInjectedPrefix()

public function testGetTablePrefix()
{
$this->deploymentConfigMock->expects(self::once())
$this->deploymentConfigMock->expects($this->once())
->method('get')
->with(ConfigOptionsListConstants::CONFIG_PATH_DB_PREFIX)
->willReturn('pref_');
Expand All @@ -93,10 +93,10 @@ public function testGetTablePrefix()

public function testGetConnectionByName()
{
$this->deploymentConfigMock->expects(self::once())->method('get')
$this->deploymentConfigMock->expects($this->once())->method('get')
->with(ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTIONS . '/default')
->willReturn(['config']);
$this->connectionFactoryMock->expects(self::once())->method('create')
$this->connectionFactoryMock->expects($this->once())->method('create')
->with(['config'])
->willReturn('connection');

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

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

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

$this->unit->closeConnection('default');
}

public function testGetTableNameWithBoolParam()
{
$this->deploymentConfigMock->expects($this->at(0))
->method('get')
->with(ConfigOptionsListConstants::CONFIG_PATH_DB_PREFIX)
->willReturn('pref_');
$this->deploymentConfigMock->expects($this->at(1))->method('get')
->with('db/connection/default')
->willReturn(['config']);
$this->configMock->expects($this->atLeastOnce())
->method('getConnectionName')
->with('default')
->willReturn('default');

$connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)->getMock();
$connection->expects($this->once())->method('getTableName')->with('pref_1');
$this->connectionFactoryMock->expects($this->once())->method('create')
->with(['config'])
->willReturn($connection);

$this->unit->getTableName(true);
}
}

0 comments on commit eb50002

Please sign in to comment.