Commit 2524d8d5 authored by alexpott's avatar alexpott

Issue #2421133 by penyaskito: Undefined variables in core/modules/locale/src/StringBase.php

parent 29c7efa1
......@@ -7,6 +7,8 @@
namespace Drupal\locale;
use Drupal\Component\Utility\String;
/**
* Defines the locale string base class.
*
......@@ -188,8 +190,8 @@ public function save() {
$storage->save($this);
}
else {
throw new StringStorageException(format_string('The string cannot be saved because its not bound to a storage: @string', array(
'@string' => $string->getString(),
throw new StringStorageException(String::format('The string cannot be saved because its not bound to a storage: @string', array(
'@string' => $this->getString(),
)));
}
return $this;
......@@ -204,8 +206,8 @@ public function delete() {
$storage->delete($this);
}
else {
throw new StringStorageException(format_string('The string cannot be deleted because its not bound to a storage: @string', array(
'@string' => $string->getString(),
throw new StringStorageException(String::format('The string cannot be deleted because its not bound to a storage: @string', array(
'@string' => $this->getString(),
)));
}
}
......
<?php
/**
* @file
* Contains \Drupal\Tests\locale\Unit\StringBaseTest.
*/
namespace Drupal\Tests\locale\Unit;
use Drupal\locale\SourceString;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\locale\StringBase
* @group locale
*/
class StringBaseTest extends UnitTestCase {
/**
* @covers ::save
* @expectedException \Drupal\locale\StringStorageException
* @expectedExceptionMessage The string cannot be saved because its not bound to a storage: test
*/
public function testSaveWithoutStorage() {
$string = new SourceString(['source' => 'test']);
$string->save();
}
/**
* @covers ::delete
* @expectedException \Drupal\locale\StringStorageException
* @expectedExceptionMessage The string cannot be deleted because its not bound to a storage: test
*/
public function testDeleteWithoutStorage() {
$string = new SourceString(['lid' => 1, 'source' => 'test']);
$string->delete();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment