From b85bc954fc65f1082a68fff42331373e3c1a101b Mon Sep 17 00:00:00 2001 From: Claudiu Cristea <clau.cristea@gmail.com> Date: Tue, 12 Nov 2024 18:33:23 +0000 Subject: [PATCH] ISAICP-9218: Re-synchonize terms for some tests. --- tests/features/adms_ap_compliance.feature | 2 +- tests/src/Context/RdfContext.php | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/features/adms_ap_compliance.feature b/tests/features/adms_ap_compliance.feature index a23d6ae8c4..77c94c12d5 100644 --- a/tests/features/adms_ap_compliance.feature +++ b/tests/features/adms_ap_compliance.feature @@ -1,4 +1,4 @@ -@api +@api @rdf_sync Feature: Interoperable Europe Portal should be ADMS-AP compliant. Scenario: Validate the entities in the published graph. diff --git a/tests/src/Context/RdfContext.php b/tests/src/Context/RdfContext.php index c2402a2c45..f3aedf0b4e 100644 --- a/tests/src/Context/RdfContext.php +++ b/tests/src/Context/RdfContext.php @@ -6,6 +6,7 @@ use Behat\Gherkin\Node\TableNode; use Drupal\DrupalExtension\Context\RawDrupalContext; +use Drupal\rdf_sync\Model\SyncMethod; use PHPUnit\Framework\Assert; use PHPUnit\Framework\ExpectationFailedException; use function PHPUnit\Framework\assertCount; @@ -235,6 +236,26 @@ public function assertValidPublishedGraph(): void { Assert::assertTrue($result->isSuccessful(), 'The published graph is not ADMS-AP compliant.'); } + /** + * Re-synchronizes terms. + * + * Used in Digit QA pipeline. The terms are installed and synchronized in + * clean-install job but are not preserved between jobs. Tests requiring RDF + * synchronized terms, should be tagged with @rdf_sync. + * + * @BeforeScenario @rdf_sync&&@api + */ + public function reSynchronizeTerms(): void { + $info = \Drupal::getContainer()->get('entity_type.bundle.info')->getBundleInfo('taxonomy_term'); + $vids = array_filter($info, fn(array $bundle): bool => isset($bundle['rdf_sync'])); + $tids = \Drupal::entityQuery('taxonomy_term')->accessCheck(FALSE) + ->condition('vid', array_keys($vids), 'IN') + ->execute(); + /** @var \Drupal\taxonomy\TermInterface[] $terms */ + $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadMultiple($tids); + \Drupal::getContainer()->get('rdf_sync.synchronizer')->synchronize(SyncMethod::UPDATE, $terms); + } + /** * Updates an entity, given its RDF resource (URI). * -- GitLab