You are here

public function SophronApiTest::testGetType in Sophron 8

@covers ::listTypes @covers ::getType

File

tests/src/Kernel/SophronApiTest.php, line 56

Class

SophronApiTest
Tests for Sophron API.

Namespace

Drupal\Tests\sophron\Kernel

Code

public function testGetType() : void {
  $manager = \Drupal::service('sophron.mime_map.manager');
  $this
    ->assertContains('application/atomserv+xml', $manager
    ->listTypes());
  $this
    ->assertEquals([
    'atomsrv',
  ], $manager
    ->getType('application/atomserv+xml')
    ->getExtensions());

  // No extensions for type.
  $this
    ->expectException(MappingException::class);
  $manager
    ->getType('a/b')
    ->getExtensions();

  // Malformed MIME type.
  $this
    ->expectException(MalformedTypeException::class);
  $manager
    ->getType('application/');
}