#1072 DDC-3191 - test cleanup: reflection is better than mixing up I/O operations and global state
This commit is contained in:
parent
e2acd74cb4
commit
8b223c5c83
@ -246,23 +246,18 @@ class FileLockRegionTest extends AbstractRegionTest
|
||||
/**
|
||||
* @group 1072
|
||||
* @group DDC-3191
|
||||
*
|
||||
* Note that this test will only fail on some OSs. Attempts to write this test using `open_basedir` failed
|
||||
* due to the inability to restore `open_basedir` on cleanup
|
||||
*/
|
||||
public function testHandlesScanErrorsGracefullyOnEvictAll()
|
||||
{
|
||||
$baseDir = sys_get_temp_dir() . '/doctrine_lock_'. uniqid();
|
||||
$subDir = $baseDir . '/foo/bar';
|
||||
$region = new FileLockRegion(new DefaultRegion('concurren_region_test', $this->cache), $subDir, 60);
|
||||
$region = $this->createRegion();
|
||||
$reflectionDirectory = new \ReflectionProperty($region, 'directory');
|
||||
|
||||
$this->cleanTestDirectory($baseDir);
|
||||
$reflectionDirectory->setAccessible(true);
|
||||
$reflectionDirectory->setValue($region, str_repeat('a', 10000));
|
||||
|
||||
rmdir($baseDir);
|
||||
|
||||
$region->evictAll();
|
||||
|
||||
$this->assertFalse(is_dir($baseDir));
|
||||
set_error_handler(function () {}, E_WARNING);
|
||||
$this->assertTrue($region->evictAll());
|
||||
restore_error_handler();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -289,4 +284,4 @@ class FileLockRegionTest extends AbstractRegionTest
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user