You are here

StringBaseTest.php in Drupal 8

Same filename and directory in other branches
  1. 9 core/modules/locale/tests/src/Unit/StringBaseTest.php

File

core/modules/locale/tests/src/Unit/StringBaseTest.php
View source
<?php

namespace Drupal\Tests\locale\Unit;

use Drupal\locale\SourceString;
use Drupal\locale\StringStorageException;
use Drupal\Tests\UnitTestCase;

/**
 * @coversDefaultClass \Drupal\locale\StringBase
 * @group locale
 */
class StringBaseTest extends UnitTestCase {

  /**
   * @covers ::save
   */
  public function testSaveWithoutStorage() {
    $string = new SourceString([
      'source' => 'test',
    ]);
    $this
      ->expectException(StringStorageException::class);
    $this
      ->expectExceptionMessage('The string cannot be saved because its not bound to a storage: test');
    $string
      ->save();
  }

  /**
   * @covers ::delete
   */
  public function testDeleteWithoutStorage() {
    $string = new SourceString([
      'lid' => 1,
      'source' => 'test',
    ]);
    $this
      ->expectException(StringStorageException::class);
    $this
      ->expectExceptionMessage('The string cannot be deleted because its not bound to a storage: test');
    $string
      ->delete();
  }

}

Classes

Namesort descending Description
StringBaseTest @coversDefaultClass \Drupal\locale\StringBase @group locale