function CrudTest::testTranslators

Test crud operations of translators.

File

tests/src/Kernel/CrudTest.php, line 32

Class

CrudTest
Basic crud operations for jobs and translators

Namespace

Drupal\Tests\tmgmt\Kernel

Code

function testTranslators() {
  $translator = $this
    ->createTranslator();
  $loaded_translator = Translator::load($translator
    ->id());
  $this
    ->assertEquals($translator
    ->id(), $loaded_translator
    ->id());
  $this
    ->assertEquals($translator
    ->label(), $loaded_translator
    ->label());
  $this
    ->assertEquals($translator
    ->getSettings(), $loaded_translator
    ->getSettings());

  // Update the settings.
  $translator
    ->setSetting('new_key', $this
    ->randomString());
  $translator
    ->save();
  $loaded_translator = Translator::load($translator
    ->id());
  $this
    ->assertEquals($translator
    ->id(), $loaded_translator
    ->id());
  $this
    ->assertEquals($translator
    ->label(), $loaded_translator
    ->label());
  $this
    ->assertEquals($translator
    ->getSettings(), $loaded_translator
    ->getSettings());

  // Delete the translator, make sure the translator is gone.
  $translator
    ->delete();
  $this
    ->assertNull(Translator::load($translator
    ->id()));
}