Commit f5108737 authored by Mike Ryan's avatar Mike Ryan

#77: Belated style checks.

parent 14af2e71
Pipeline #59197934 passed with stage
in 2 minutes and 28 seconds
......@@ -173,8 +173,7 @@ class DBAL extends KeyMapBase
if (!$this->tableExists()) {
try {
$schema = $this->connection()->getSchemaManager();
}
catch (DBALException $e) {
} catch (DBALException $e) {
throw new KeyMapException('Unable to connect to database.', 0, $e);
}
try {
......@@ -224,8 +223,7 @@ class DBAL extends KeyMapBase
{
try {
$schema = $this->connection()->getSchemaManager();
}
catch (DBALException $e) {
} catch (DBALException $e) {
throw new KeyMapException('Unable to connect to database.', 0, $e);
}
return $schema->tablesExist([$this->getConfigurationValue('table')]);
......
......@@ -36,31 +36,31 @@ abstract class RecordTestBase extends TestCase
*/
public function recordDataProvider() : array
{
$basic_data = [
$basicData = [
'string_property' => 'value1',
'int_property' => 0,
'null_property' => null,
];
$data['string property'] = [
$basic_data, // Data for initializing a record.
$basicData, // Data for initializing a record.
'string_property', // Property to get.
'value1', // Expected value of the property.
true, // Expected existence of the property.
];
$data['int property'] = [
$basic_data,
$basicData,
'int_property',
0,
true,
];
$data['null property'] = [
$basic_data,
$basicData,
'null_property',
null,
true,
];
$data['missing property'] = [
$basic_data,
$basicData,
'i_do_not_exist',
null,
false,
......@@ -90,10 +90,16 @@ abstract class RecordTestBase extends TestCase
$factory = new $this->recordFactoryClass($propertyFactory);
$record = $factory->create($data);
$this->assertEquals($data, $record->toArray(), 'Record retrieved');
$this->assertEquals($expectedPropertyValue,
$record->getProperty($propertyName)->getValue(), 'Property retrieved');
$this->assertEquals($expectedPropertyExists,
$record->propertyExists($propertyName), "Property existence identified");
$this->assertEquals(
$expectedPropertyValue,
$record->getProperty($propertyName)->getValue(),
'Property retrieved'
);
$this->assertEquals(
$expectedPropertyExists,
$record->propertyExists($propertyName),
"Property existence identified"
);
}
/**
......@@ -103,18 +109,18 @@ abstract class RecordTestBase extends TestCase
*/
public function setPropertyDataProvider() : array
{
$basic_data = [
$basicData = [
'string_property' => 'value1',
'int_property' => 0,
'null_property' => null,
];
$data['overwrite existing property'] = [
$basic_data, // Data for initializing a record.
$basicData, // Data for initializing a record.
'string_property', // Property to set.
'value2', // Value to set it to.
];
$data['new property'] = [
$basic_data,
$basicData,
'new_property',
5,
];
......@@ -148,10 +154,15 @@ abstract class RecordTestBase extends TestCase
$factory = new $this->recordFactoryClass($propertyFactory);
$record = $factory->create($data);
$record->setProperty($propertyName, $propertyFactory->create($propertyValue));
$this->assertEquals($propertyValue,
$record->getProperty($propertyName)->getValue(), 'Property retrieved');
$this->assertEquals(true,
$record->propertyExists($propertyName), "Property existence identified");
$this->assertEquals(
$propertyValue,
$record->getProperty($propertyName)->getValue(),
'Property retrieved'
);
$this->assertEquals(
true,
$record->propertyExists($propertyName),
"Property existence identified"
);
}
}
......@@ -479,8 +479,8 @@ abstract class KeyMapTestBase extends TestCase
array $mapData,
array $loadedKeysToLookup,
array $expectedExtractedKeys
) : void
{
) : void {
// Populate the key map.
$configuration = array_merge($this->configuration, $keyMetadata);
/** @var KeyMap $keyMap */
......@@ -492,8 +492,10 @@ abstract class KeyMapTestBase extends TestCase
$this->assertEquals(count($mapData), $keyMap->count());
// Iterate and make sure we get back the same keys.
foreach ($keyMap->iterate() as $index => $mapRecord) {
$this->assertEquals(array_values($mapData[$index]['extracted_key']),
array_values($mapRecord));
$this->assertEquals(
array_values($mapData[$index]['extracted_key']),
array_values($mapRecord)
);
}
}
}
......@@ -249,7 +249,6 @@ class DBALExtractorTest extends CountableExtractorTestBase
$this->expectException(ExtractorException::class);
$this->expectExceptionMessage('Unable to connect to database.');
foreach ($extractor->extractAll() as $record) {
}
}
......@@ -267,8 +266,6 @@ class DBALExtractorTest extends CountableExtractorTestBase
$this->expectException(ExtractorException::class);
$this->expectExceptionMessage("Error executing query 'SELECT * FROM not_an_actual_table'.");
foreach ($extractor->extractAll() as $record) {
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment