You are here

public function SophronApiTest::testGetExtension in Sophron 8

@covers ::getMapClass @covers ::setMapClass @covers ::listExtensions @covers ::getExtension

File

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

Class

SophronApiTest
Tests for Sophron API.

Namespace

Drupal\Tests\sophron\Kernel

Code

public function testGetExtension() : void {
  $manager = \Drupal::service('sophron.mime_map.manager');
  $this
    ->assertEquals(DrupalMap::class, $manager
    ->getMapClass());
  $this
    ->assertContains('atomsrv', $manager
    ->listExtensions());
  $this
    ->assertEquals('application/atomserv+xml', $manager
    ->getExtension('atomsrv')
    ->getDefaultType());
  $manager
    ->setMapClass(DefaultMap::class);
  $this
    ->assertEquals('application/octet-stream', $manager
    ->getExtension('atomsrv')
    ->getDefaultType(FALSE));

  // No type for extension.
  $this
    ->expectException(MappingException::class);
  $manager
    ->getExtension('atomsrv')
    ->getDefaultType();
}