function MediaLibraryStateTest::providerFromRequest

Same name in other branches
  1. 8.9.x core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryStateTest::providerFromRequest()
  2. 10 core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryStateTest::providerFromRequest()
  3. 11.x core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryStateTest::providerFromRequest()

Data provider for testFromRequest().

Return value

array The data sets to test.

File

core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php, line 316

Class

MediaLibraryStateTest
Tests the media library state value object.

Namespace

Drupal\Tests\media_library\Kernel

Code

public function providerFromRequest() {
    $test_data = [];
    // Assert no exception is thrown when we use valid state parameters.
    $test_data['valid parameters'] = [
        [],
        FALSE,
    ];
    // Assert no exception is thrown when we override all query parameters with
    // the same data.
    $test_data['changed with same values'] = [
        [
            'media_library_opener_id' => 'test',
            'media_library_allowed_types' => [
                'file',
                'image',
            ],
            'media_library_selected_type' => 'image',
            'media_library_remaining' => 2,
        ],
        FALSE,
    ];
    // Assert an exception is thrown when we change the opener ID parameter.
    $test_data['changed opener ID'] = [
        [
            'media_library_opener_id' => 'fail',
        ],
        TRUE,
    ];
    // Assert an exception is thrown when we change the allowed types parameter.
    $test_data['changed allowed types'] = [
        [
            'media_library_allowed_types' => [
                'audio',
                'image',
            ],
        ],
        TRUE,
    ];
    // Assert an exception is thrown when we change the selected type parameter.
    $test_data['changed selected type'] = [
        [
            'media_library_selected_type' => 'file',
        ],
        TRUE,
    ];
    // Assert an exception is thrown when we change the remaining slots
    // parameter.
    $test_data['changed remaining'] = [
        [
            'media_library_remaining' => 4,
        ],
        TRUE,
    ];
    // Assert an exception is thrown when we change the actual hash.
    $test_data['changed hash'] = [
        [
            'hash' => 'fail',
        ],
        TRUE,
    ];
    return $test_data;
}

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