Skip to content
Snippets Groups Projects
Verified Commit fc25e33d authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3469163 by catch: Speed up ContentModerationStateTest

parent 77686992
No related branches found
No related tags found
20 merge requests!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8736Update the Documention As per the Function uses.,!8513Issue #3453786: DefaultSelection should document why values for target_bundles NULL and [] behave as they do,!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2062Issue #3246454: Add weekly granularity to views date sort,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #262683 passed with warnings
Pipeline: drupal

#262709

    Pipeline: drupal

    #262701

      Pipeline: drupal

      #262689

        ...@@ -111,10 +111,18 @@ protected function setUp(): void { ...@@ -111,10 +111,18 @@ protected function setUp(): void {
        /** /**
        * Tests basic monolingual content moderation through the API. * Tests basic monolingual content moderation through the API.
        *
        * @dataProvider basicModerationTestCases
        */ */
        public function testBasicModeration($entity_type_id): void { public function testBasicModeration(): void {
        foreach (static::basicModerationTestCases() as $case) {
        [$entity_type_id] = $case;
        $this->doTestBasicModeration($entity_type_id);
        }
        }
        /**
        * Tests basic monolingual content moderation through the API.
        */
        protected function doTestBasicModeration($entity_type_id): void {
        $entity = $this->createEntity($entity_type_id, 'draft'); $entity = $this->createEntity($entity_type_id, 'draft');
        $entity = $this->reloadEntity($entity); $entity = $this->reloadEntity($entity);
        $this->assertEquals('draft', $entity->moderation_state->value); $this->assertEquals('draft', $entity->moderation_state->value);
        ...@@ -201,10 +209,18 @@ public static function basicModerationTestCases() { ...@@ -201,10 +209,18 @@ public static function basicModerationTestCases() {
        /** /**
        * Tests removal of content moderation state entity. * Tests removal of content moderation state entity.
        *
        * @dataProvider basicModerationTestCases
        */ */
        public function testContentModerationStateDataRemoval($entity_type_id): void { public function testContentModerationStateDataRemoval(): void {
        foreach (static::basicModerationTestCases() as $case) {
        [$entity_type_id] = $case;
        $this->doTestContentModerationStateDataRemoval($entity_type_id);
        }
        }
        /**
        * Tests removal of content moderation state entity.
        */
        public function doTestContentModerationStateDataRemoval($entity_type_id): void {
        /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
        $entity = $this->createEntity($entity_type_id); $entity = $this->createEntity($entity_type_id);
        $entity = $this->reloadEntity($entity); $entity = $this->reloadEntity($entity);
        ...@@ -215,10 +231,18 @@ public function testContentModerationStateDataRemoval($entity_type_id): void { ...@@ -215,10 +231,18 @@ public function testContentModerationStateDataRemoval($entity_type_id): void {
        /** /**
        * Tests removal of content moderation state entity revisions. * Tests removal of content moderation state entity revisions.
        *
        * @dataProvider basicModerationTestCases
        */ */
        public function testContentModerationStateRevisionDataRemoval($entity_type_id): void { public function testContentModerationStateRevisionDataRemoval(): void {
        foreach (static::basicModerationTestCases() as $case) {
        [$entity_type_id] = $case;
        $this->doTestContentModerationStateRevisionDataRemoval($entity_type_id);
        }
        }
        /**
        * Tests removal of content moderation state entity revisions.
        */
        public function doTestContentModerationStateRevisionDataRemoval($entity_type_id): void {
        /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
        $entity = $this->createEntity($entity_type_id); $entity = $this->createEntity($entity_type_id);
        $revision_1 = clone $entity; $revision_1 = clone $entity;
        ...@@ -250,10 +274,18 @@ public function testContentModerationStateRevisionDataRemoval($entity_type_id): ...@@ -250,10 +274,18 @@ public function testContentModerationStateRevisionDataRemoval($entity_type_id):
        /** /**
        * Tests removal of content moderation state pending entity revisions. * Tests removal of content moderation state pending entity revisions.
        *
        * @dataProvider basicModerationTestCases
        */ */
        public function testContentModerationStatePendingRevisionDataRemoval($entity_type_id): void { public function testContentModerationStatePendingRevisionDataRemoval(): void {
        foreach (static::basicModerationTestCases() as $case) {
        [$entity_type_id] = $case;
        $this->doTestContentModerationStatePendingRevisionDataRemoval($entity_type_id);
        }
        }
        /**
        * Tests removal of content moderation state pending entity revisions.
        */
        public function doTestContentModerationStatePendingRevisionDataRemoval($entity_type_id): void {
        $entity = $this->createEntity($entity_type_id, 'published'); $entity = $this->createEntity($entity_type_id, 'published');
        $entity->setNewRevision(TRUE); $entity->setNewRevision(TRUE);
        $entity->moderation_state = 'draft'; $entity->moderation_state = 'draft';
        ...@@ -296,10 +328,18 @@ public function testExistingContentModerationStateDataRemoval(): void { ...@@ -296,10 +328,18 @@ public function testExistingContentModerationStateDataRemoval(): void {
        /** /**
        * Tests removal of content moderation state translations. * Tests removal of content moderation state translations.
        *
        * @dataProvider basicModerationTestCases
        */ */
        public function testContentModerationStateTranslationDataRemoval($entity_type_id): void { public function testContentModerationStateTranslationDataRemoval(): void {
        foreach (static::basicModerationTestCases() as $case) {
        [$entity_type_id] = $case;
        $this->doTestContentModerationStateTranslationDataRemoval($entity_type_id);
        }
        }
        /**
        * Tests removal of content moderation state translations.
        */
        public function doTestContentModerationStateTranslationDataRemoval($entity_type_id): void {
        // Test content moderation state translation deletion. // Test content moderation state translation deletion.
        if ($this->entityTypeManager->getDefinition($entity_type_id)->isTranslatable()) { if ($this->entityTypeManager->getDefinition($entity_type_id)->isTranslatable()) {
        /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
        ...@@ -673,15 +713,23 @@ public function testWorkflowNonConfigBundleDependencies(): void { ...@@ -673,15 +713,23 @@ public function testWorkflowNonConfigBundleDependencies(): void {
        ], $workflow->getDependencies()); ], $workflow->getDependencies());
        } }
        /**
        * Tests the revision default state of the moderation state entity revisions.
        */
        public function testRevisionDefaultState(): void {
        foreach (static::basicModerationTestCases() as $case) {
        [$entity_type_id] = $case;
        $this->doTestRevisionDefaultState($entity_type_id);
        }
        }
        /** /**
        * Tests the revision default state of the moderation state entity revisions. * Tests the revision default state of the moderation state entity revisions.
        * *
        * @param string $entity_type_id * @param string $entity_type_id
        * The ID of entity type to be tested. * The ID of entity type to be tested.
        *
        * @dataProvider basicModerationTestCases
        */ */
        public function testRevisionDefaultState($entity_type_id): void { public function doTestRevisionDefaultState($entity_type_id): void {
        // Check that the revision default state of the moderated entity and the // Check that the revision default state of the moderated entity and the
        // content moderation state entity always match. // content moderation state entity always match.
        $entity = $this->createEntity($entity_type_id, 'published'); $entity = $this->createEntity($entity_type_id, 'published');
        ......
        ...@@ -19,6 +19,10 @@ trait ContentModerationTestTrait { ...@@ -19,6 +19,10 @@ trait ContentModerationTestTrait {
        * The editorial workflow entity. * The editorial workflow entity.
        */ */
        protected function createEditorialWorkflow() { protected function createEditorialWorkflow() {
        // Allow this method to be called twice from the same test method.
        if ($workflow = Workflow::load('editorial')) {
        return $workflow;
        }
        $workflow = Workflow::create([ $workflow = Workflow::create([
        'type' => 'content_moderation', 'type' => 'content_moderation',
        'id' => 'editorial', 'id' => 'editorial',
        ......
        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