function ContentModerationRouteSubscriberTest::setLatestRevisionFlagTestCases

Same name and namespace in other branches
  1. 8.9.x core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php \Drupal\Tests\content_moderation\Unit\ContentModerationRouteSubscriberTest::setLatestRevisionFlagTestCases()
  2. 10 core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php \Drupal\Tests\content_moderation\Unit\ContentModerationRouteSubscriberTest::setLatestRevisionFlagTestCases()
  3. 11.x core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php \Drupal\Tests\content_moderation\Unit\ContentModerationRouteSubscriberTest::setLatestRevisionFlagTestCases()

Data provider for ::testSetLatestRevisionFlag.

File

core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php, line 69

Class

ContentModerationRouteSubscriberTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21content_moderation%21src%21Routing%21ContentModerationRouteSubscriber.php/class/ContentModerationRouteSubscriber/9" title="Subscriber for moderated revisionable entity forms." class="local">\Drupal\content_moderation\Routing\ContentModerationRouteSubscriber</a>

Namespace

Drupal\Tests\content_moderation\Unit

Code

public function setLatestRevisionFlagTestCases() {
    return [
        'Entity parameter not on an entity form' => [
            [],
            [
                'entity_test' => [
                    'type' => 'entity:entity_test_rev',
                ],
            ],
        ],
        'Entity parameter on an entity form' => [
            [
                '_entity_form' => 'entity_test_rev.edit',
            ],
            [
                'entity_test_rev' => [
                    'type' => 'entity:entity_test_rev',
                ],
            ],
            [
                'entity_test_rev' => [
                    'type' => 'entity:entity_test_rev',
                    'load_latest_revision' => TRUE,
                ],
            ],
        ],
        'Entity form with no operation' => [
            [
                '_entity_form' => 'entity_test_rev',
            ],
            [
                'entity_test_rev' => [
                    'type' => 'entity:entity_test_rev',
                ],
            ],
            [
                'entity_test_rev' => [
                    'type' => 'entity:entity_test_rev',
                    'load_latest_revision' => TRUE,
                ],
            ],
        ],
        'Non-moderated entity form' => [
            [
                '_entity_form' => 'entity_test_mulrev',
            ],
            [
                'entity_test_mulrev' => [
                    'type' => 'entity:entity_test_mulrev',
                ],
            ],
        ],
        'Multiple entity parameters on an entity form' => [
            [
                '_entity_form' => 'entity_test_rev.edit',
            ],
            [
                'entity_test_rev' => [
                    'type' => 'entity:entity_test_rev',
                ],
                'node' => [
                    'type' => 'entity:node',
                ],
            ],
            [
                'entity_test_rev' => [
                    'type' => 'entity:entity_test_rev',
                    'load_latest_revision' => TRUE,
                ],
                'node' => [
                    'type' => 'entity:node',
                ],
            ],
        ],
        'Overridden load_latest_revision flag does not change' => [
            [
                '_entity_form' => 'entity_test_rev.edit',
            ],
            [
                'entity_test_rev' => [
                    'type' => 'entity:entity_test_rev',
                    'load_latest_revision' => FALSE,
                ],
            ],
        ],
        'Non-revisionable entity type will not change' => [
            [
                '_entity_form' => 'entity_test.edit',
            ],
            [
                'entity_test' => [
                    'type' => 'entity:entity_test',
                ],
            ],
            FALSE,
            FALSE,
        ],
        'Overridden load_latest_revision flag does not change with multiple parameters' => [
            [
                '_entity_form' => 'entity_test_rev.edit',
            ],
            [
                'entity_test_rev' => [
                    'type' => 'entity:entity_test_rev',
                ],
                'node' => [
                    'type' => 'entity:node',
                    'load_latest_revision' => FALSE,
                ],
            ],
            [
                'entity_test_rev' => [
                    'type' => 'entity:entity_test_rev',
                    'load_latest_revision' => TRUE,
                ],
                'node' => [
                    'type' => 'entity:node',
                    'load_latest_revision' => FALSE,
                ],
            ],
        ],
        'Parameter without type is unchanged' => [
            [
                '_entity_form' => 'entity_test_rev.edit',
            ],
            [
                'entity_test_rev' => [
                    'type' => 'entity:entity_test_rev',
                ],
                'unrelated_param' => [
                    'foo' => 'bar',
                ],
            ],
            [
                'entity_test_rev' => [
                    'type' => 'entity:entity_test_rev',
                    'load_latest_revision' => TRUE,
                ],
                'unrelated_param' => [
                    'foo' => 'bar',
                ],
            ],
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.