Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 12c59b91 authored by Andreas Hennings's avatar Andreas Hennings
Browse files

OEL-1281: Document assertion strategy in InstallTest.

parent d7fa5d6f
No related branches found
No related tags found
5 merge requests!121OEL-1421: Fix cosmetic changes.,!116OEL-1394: Merge 1.x into EPIC-1293-Project, align with new version of card:search pattern,!115Upate the EPIC-1293-project,!105EPIC: OEL-1255: Migrate paragraphs,!97[OEL-1255] OEL-1281: Upgrade path from oe_bootstrap_theme_paragraphs
...@@ -180,6 +180,8 @@ class InstallTest extends BrowserTestBase { ...@@ -180,6 +180,8 @@ class InstallTest extends BrowserTestBase {
], ],
]; ];
// Produce reports instead of many individual assertions. This is less
// simple in code, but produces more useful output on test failure.
$actual_updated = []; $actual_updated = [];
$actual_deleted = []; $actual_deleted = [];
foreach ($ids as $name => $id) { foreach ($ids as $name => $id) {
...@@ -187,8 +189,11 @@ class InstallTest extends BrowserTestBase { ...@@ -187,8 +189,11 @@ class InstallTest extends BrowserTestBase {
self::assertNotNull($updated_paragraph); self::assertNotNull($updated_paragraph);
foreach ($expected_created[$name] as $field_name => $value) { foreach ($expected_created[$name] as $field_name => $value) {
if (!$updated_paragraph->hasField($field_name)) { if (!$updated_paragraph->hasField($field_name)) {
// The expected field was not created.
// Omit this entry in $actual_updated, to cause a fail below.
continue; continue;
} }
// The expected field was created, but the value might be wrong.
$actual_updated[$name][$field_name] = $updated_paragraph->get($field_name)->value; $actual_updated[$name][$field_name] = $updated_paragraph->get($field_name)->value;
} }
foreach ($expected_deleted[$name] as $field_name => $deleted) { foreach ($expected_deleted[$name] as $field_name => $deleted) {
...@@ -196,6 +201,7 @@ class InstallTest extends BrowserTestBase { ...@@ -196,6 +201,7 @@ class InstallTest extends BrowserTestBase {
} }
} }
// Compare the reports to the expected values.
self::assertSame($expected_created, $actual_updated); self::assertSame($expected_created, $actual_updated);
self::assertSame($expected_deleted, $actual_deleted); self::assertSame($expected_deleted, $actual_deleted);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment