From e2ff6e81523c1915af2c14ac3c95cec99ba63033 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 18 Aug 2015 11:42:29 +0100 Subject: [PATCH] Issue #2550311 by chx: Allow extending PhpStorageTestBase --- .../Component/PhpStorage/PhpStorageTestBase.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php b/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php index 9abc86bb493..0c90019021d 100644 --- a/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php +++ b/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php @@ -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. + } + }