Issue #2426533 by alexpott, Berdir: Random failures in tests that extend PhpStorageTestBase
parent
efc0e2e41d
commit
61cc921f89
|
@ -36,14 +36,12 @@ class FileStorageReadOnlyTest extends PhpStorageTestBase {
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$dir_path = sys_get_temp_dir() . '/php';
|
|
||||||
|
|
||||||
$this->standardSettings = array(
|
$this->standardSettings = array(
|
||||||
'directory' => $dir_path,
|
'directory' => $this->directory,
|
||||||
'bin' => 'test',
|
'bin' => 'test',
|
||||||
);
|
);
|
||||||
$this->readonlyStorage = array(
|
$this->readonlyStorage = array(
|
||||||
'directory' => $dir_path,
|
'directory' => $this->directory,
|
||||||
// Let this read from the bin where the other instance is writing.
|
// Let this read from the bin where the other instance is writing.
|
||||||
'bin' => 'test',
|
'bin' => 'test',
|
||||||
);
|
);
|
||||||
|
@ -102,7 +100,7 @@ class FileStorageReadOnlyTest extends PhpStorageTestBase {
|
||||||
$this->assertFalse($php_read->deleteAll());
|
$this->assertFalse($php_read->deleteAll());
|
||||||
|
|
||||||
// Make sure directory exists prior to removal.
|
// Make sure directory exists prior to removal.
|
||||||
$this->assertTrue(file_exists(sys_get_temp_dir() . '/php/test'), 'File storage directory does not exist.');
|
$this->assertTrue(file_exists($this->directory . '/test'), 'File storage directory does not exist.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,8 @@ class FileStorageTest extends PhpStorageTestBase {
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$dir_path = sys_get_temp_dir() . '/php';
|
|
||||||
|
|
||||||
$this->standardSettings = array(
|
$this->standardSettings = array(
|
||||||
'directory' => $dir_path,
|
'directory' => $this->directory,
|
||||||
'bin' => 'test',
|
'bin' => 'test',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +65,7 @@ class FileStorageTest extends PhpStorageTestBase {
|
||||||
public function testDeleteAll() {
|
public function testDeleteAll() {
|
||||||
|
|
||||||
// Make sure directory exists prior to removal.
|
// Make sure directory exists prior to removal.
|
||||||
$this->assertTrue(file_exists(sys_get_temp_dir() . '/php/test'), 'File storage directory does not exist.');
|
$this->assertTrue(file_exists($this->directory . '/test'), 'File storage directory does not exist.');
|
||||||
|
|
||||||
// Write out some files.
|
// Write out some files.
|
||||||
$php = new FileStorage($this->standardSettings);
|
$php = new FileStorage($this->standardSettings);
|
||||||
|
@ -87,7 +85,7 @@ class FileStorageTest extends PhpStorageTestBase {
|
||||||
|
|
||||||
$this->assertTrue($php->deleteAll());
|
$this->assertTrue($php->deleteAll());
|
||||||
$this->assertFalse($php->load($name));
|
$this->assertFalse($php->load($name));
|
||||||
$this->assertFalse(file_exists(sys_get_temp_dir() . '/php/test'), 'File storage directory still exists after call to deleteAll().');
|
$this->assertFalse(file_exists($this->directory . '/test'), 'File storage directory still exists after call to deleteAll().');
|
||||||
|
|
||||||
// Should still return TRUE if directory has already been deleted.
|
// Should still return TRUE if directory has already been deleted.
|
||||||
$this->assertTrue($php->deleteAll());
|
$this->assertTrue($php->deleteAll());
|
||||||
|
|
|
@ -38,7 +38,6 @@ abstract class MTimeProtectedFileStorageBase extends PhpStorageTestBase {
|
||||||
*/
|
*/
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->directory = sys_get_temp_dir() . '/php' . str_replace('\\','_', get_class($this));
|
|
||||||
|
|
||||||
$this->secret = $this->randomMachineName();
|
$this->secret = $this->randomMachineName();
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,21 @@ use Drupal\Tests\UnitTestCase;
|
||||||
*/
|
*/
|
||||||
abstract class PhpStorageTestBase extends UnitTestCase {
|
abstract class PhpStorageTestBase extends UnitTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A unique per test class directory path to test php storage.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $directory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
protected function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
$this->directory = sys_get_temp_dir() . '/php' . str_replace('\\','_', get_class($this));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assert that a PHP storage's load/save/delete operations work.
|
* Assert that a PHP storage's load/save/delete operations work.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue