Skip to content

Commit 6731ba1

Browse files
committed
refactor: Improve XML fixture formatting and error handling in TestCase class.
1 parent 98e8303 commit 6731ba1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/TestCase.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ protected function buildFlatXMLDataSet(array $dataSet): string
192192
throw new RuntimeException('Failed to save XML from DOM.');
193193
}
194194

195-
// Replace the tags with 4 spaces
195+
// Manually indent child elements with 4 spaces for consistent fixture formatting.
196+
// DOM's formatOutput doesn't provide control over indentation depth.
196197
return str_replace(
197198
[
198199
'<tree', '<multiple_tree'],
@@ -224,6 +225,7 @@ protected function createDatabase(): void
224225
try {
225226
$this->runMigrate('down', ['all']);
226227
} catch (RuntimeException) {
228+
// Ignore errors when rolling back migrations on a potentially fresh database
227229
}
228230

229231
foreach ($dropTables as $table) {
@@ -303,7 +305,7 @@ protected function generateFixtureTree(): void
303305
$command = $this->getDb()->createCommand();
304306

305307
// Load XML fixture data into database tables
306-
$xml = new SimpleXMLElement("{$this->fixtureDirectory}/test.xml", 0, true);
308+
$xml = $this->loadFixtureXML('test.xml');
307309

308310
$children = $xml->children() ?? [];
309311

0 commit comments

Comments
 (0)