You are here

public function MediaLibraryStateTest::testMethods in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media_library/tests/src/Kernel/MediaLibraryStateTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryStateTest::testMethods()

Tests the media library state methods.

File

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

Class

MediaLibraryStateTest
Tests the media library state value object.

Namespace

Drupal\Tests\media_library\Kernel

Code

public function testMethods() {
  $opener_id = 'test';
  $allowed_media_type_ids = [
    'document',
    'image',
  ];
  $selected_media_type_id = 'image';
  $remaining_slots = 2;
  $state = MediaLibraryState::create($opener_id, $allowed_media_type_ids, $selected_media_type_id, $remaining_slots);
  $this
    ->assertSame($opener_id, $state
    ->getOpenerId());
  $this
    ->assertSame($allowed_media_type_ids, $state
    ->getAllowedTypeIds());
  $this
    ->assertSame($selected_media_type_id, $state
    ->getSelectedTypeId());
  $this
    ->assertSame($remaining_slots, $state
    ->getAvailableSlots());
  $this
    ->assertTrue($state
    ->hasSlotsAvailable());
  $state = MediaLibraryState::create($opener_id, $allowed_media_type_ids, $selected_media_type_id, 0);
  $this
    ->assertFalse($state
    ->hasSlotsAvailable());
}