function MediaLibraryStateTest::providerCreate

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

Data provider for testCreate().

Return value

array The data sets to test.

File

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

Class

MediaLibraryStateTest
Tests the media library state value object.

Namespace

Drupal\Tests\media_library\Kernel

Code

public static function providerCreate() {
    $test_data = [];
    // Assert no exception is thrown when we add the parameters as expected.
    $test_data['valid parameters'] = [
        'test',
        [
            'document',
            'image',
        ],
        'image',
        2,
    ];
    // Assert an exception is thrown when the opener ID parameter is empty.
    $test_data['empty opener ID'] = [
        '',
        [
            'document',
            'image',
        ],
        'image',
        2,
        'The opener ID parameter is required and must be a string.',
    ];
    // Assert an exception is thrown when the opener ID parameter is not a
    // valid string.
    $test_data['integer opener ID'] = [
        1,
        [
            'document',
            'image',
        ],
        'image',
        2,
        'The opener ID parameter is required and must be a string.',
    ];
    $test_data['boolean opener ID'] = [
        TRUE,
        [
            'document',
            'image',
        ],
        'image',
        2,
        'The opener ID parameter is required and must be a string.',
    ];
    $test_data['spaces opener ID'] = [
        '   ',
        [
            'document',
            'image',
        ],
        'image',
        2,
        'The opener ID parameter is required and must be a string.',
    ];
    // Assert an exception is thrown when the allowed types parameter is empty.
    $test_data['empty allowed types'] = [
        'test',
        [],
        'image',
        2,
        'The allowed types parameter is required and must be an array of strings.',
    ];
    // It is not possible to assert a non-array allowed types parameter, since
    // that would throw a TypeError which is not a subclass of Exception.
    // Continue asserting an exception is thrown when the allowed types
    // parameter contains elements that are not a valid string.
    $test_data['integer in allowed types'] = [
        'test',
        [
            1,
            'image',
        ],
        'image',
        2,
        'The allowed types parameter is required and must be an array of strings.',
    ];
    $test_data['boolean in allowed types'] = [
        'test',
        [
            TRUE,
            'image',
        ],
        'image',
        2,
        'The allowed types parameter is required and must be an array of strings.',
    ];
    $test_data['spaces in allowed types'] = [
        'test',
        [
            '   ',
            'image',
        ],
        'image',
        2,
        'The allowed types parameter is required and must be an array of strings.',
    ];
    // Assert an exception is thrown when the selected type parameter is empty.
    $test_data['empty selected type'] = [
        'test',
        [
            'document',
            'image',
        ],
        '',
        2,
        'The selected type parameter is required and must be a string.',
    ];
    // Assert an exception is thrown when the selected type parameter is not a
    // valid string.
    $test_data['numeric selected type'] = [
        'test',
        [
            'document',
            'image',
        ],
        1,
        2,
        'The selected type parameter is required and must be a string.',
    ];
    $test_data['boolean selected type'] = [
        'test',
        [
            'document',
            'image',
        ],
        TRUE,
        2,
        'The selected type parameter is required and must be a string.',
    ];
    $test_data['spaces selected type'] = [
        'test',
        [
            'document',
            'image',
        ],
        '   ',
        2,
        'The selected type parameter is required and must be a string.',
    ];
    // Assert an exception is thrown when the selected type parameter is not in
    // the list of allowed types.
    $test_data['non-present selected type'] = [
        'test',
        [
            'document',
            'image',
        ],
        'video',
        2,
        'The selected type parameter must be present in the list of allowed types.',
    ];
    // Assert an exception is thrown when the remaining slots parameter is
    // empty.
    $test_data['empty remaining slots'] = [
        'test',
        [
            'document',
            'image',
        ],
        'image',
        '',
        'The remaining slots parameter is required and must be numeric.',
    ];
    // Assert an exception is thrown when the remaining slots parameter is
    // not numeric.
    $test_data['string remaining slots'] = [
        'test',
        [
            'document',
            'image',
        ],
        'image',
        'fail',
        'The remaining slots parameter is required and must be numeric.',
    ];
    $test_data['boolean remaining slots'] = [
        'test',
        [
            'document',
            'image',
        ],
        'image',
        TRUE,
        'The remaining slots parameter is required and must be numeric.',
    ];
    return $test_data;
}

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