for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
class PdoCrudMock extends \Mezon\PdoCrud\PdoCrud
{
public $selectResult = [];
public function select(
string $fields,
string $tableNames,
string $where = '1 = 1',
int $from = 0,
int $limit = 1000000): array
return $this->selectResult;
}
class CustomFieldsModelMock extends \Mezon\Service\CustomFieldsModel
public function getConnection(string $connectionName = 'default-db-connection')
$connectionName
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function getConnection(/** @scrutinizer ignore-unused */ string $connectionName = 'default-db-connection')
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
$mock = new \PdoCrudMock();
$mock->selectResult = $this->selectResult;
return $mock;
class CustomFieldsModelUnitTest extends \PHPUnit\Framework\TestCase
/**
* Data provider
*
* @return array testing data
*/
public function getFieldForObjectDataProvider(): array
return [
[
[],
'default'
],
'field_value' => '111'
]
'111'
];
* Testing getFieldForObject
* @param array $data custom fields of the object
* @param string $expectedResult expected result of the call getFieldForObject
* @dataProvider getFieldForObjectDataProvider
public function testGetExistingCustomField(array $data, string $expectedResult): void
// setup
$model = new \CustomFieldsModelMock('entity');
$model->selectResult = $data;
// test body
$actualResult = $model->getFieldForObject(1, 'id', 'default');
// assertions
$this->assertEquals($expectedResult, $actualResult);
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.