Issue #2421133 by penyaskito: Undefined variables in core/modules/locale/src/StringBase.php
parent
29c7efa1df
commit
2524d8d5ba
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Drupal\locale;
|
||||
|
||||
use Drupal\Component\Utility\String;
|
||||
|
||||
/**
|
||||
* Defines the locale string base class.
|
||||
*
|
||||
|
@ -188,8 +190,8 @@ abstract class StringBase implements StringInterface {
|
|||
$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 @@ abstract class StringBase implements StringInterface {
|
|||
$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(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?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();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue