Issue #2550311 by chx: Allow extending PhpStorageTestBase

8.0.x
Alex Pott 2015-08-18 11:42:29 +01:00
parent 3b2fd07bcf
commit e2ff6e8152
1 changed files with 17 additions and 0 deletions

View File

@ -7,6 +7,7 @@
namespace Drupal\Tests\Component\PhpStorage;
use Drupal\Component\PhpStorage\PhpStorageInterface;
use Drupal\Tests\UnitTestCase;
use org\bovigo\vfs\vfsStream;
@ -49,6 +50,9 @@ abstract class PhpStorageTestBase extends UnitTestCase {
$php->load($name);
$this->assertTrue($GLOBALS[$random], 'File saved correctly with correct value');
// Run additional asserts.
$this->additionalAssertCRUD($php, $name);
// If the file was successfully loaded, it must also exist, but ensure the
// exists() method returns that correctly.
$this->assertTrue($php->exists($name), 'Exists works correctly');
@ -63,4 +67,17 @@ abstract class PhpStorageTestBase extends UnitTestCase {
unset($GLOBALS[$random]);
}
/**
* Additional asserts to be run.
*
* @param \Drupal\Component\PhpStorage\PhpStorageInterface $php
* The PHP storage object.
* @param string $name
* The name of an object. It should exist in the storage.
*/
protected function additionalAssertCRUD(PhpStorageInterface $php, $name) {
// By default do not do any additional asserts. This is a way of extending
// tests in contrib.
}
}