1
0
mirror of synced 2025-03-25 17:33:55 +03:00

#1072 DDC-3191 - test cleanup: reflection is better than mixing up I/O operations and global state

This commit is contained in:
Marco Pivetta 2015-01-15 00:54:25 +01:00
parent e2acd74cb4
commit 8b223c5c83

View File

@ -246,23 +246,18 @@ class FileLockRegionTest extends AbstractRegionTest
/** /**
* @group 1072 * @group 1072
* @group DDC-3191 * @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() public function testHandlesScanErrorsGracefullyOnEvictAll()
{ {
$baseDir = sys_get_temp_dir() . '/doctrine_lock_'. uniqid(); $region = $this->createRegion();
$subDir = $baseDir . '/foo/bar'; $reflectionDirectory = new \ReflectionProperty($region, 'directory');
$region = new FileLockRegion(new DefaultRegion('concurren_region_test', $this->cache), $subDir, 60);
$this->cleanTestDirectory($baseDir); $reflectionDirectory->setAccessible(true);
$reflectionDirectory->setValue($region, str_repeat('a', 10000));
rmdir($baseDir); set_error_handler(function () {}, E_WARNING);
$this->assertTrue($region->evictAll());
$region->evictAll(); restore_error_handler();
$this->assertFalse(is_dir($baseDir));
} }
/** /**
@ -289,4 +284,4 @@ class FileLockRegionTest extends AbstractRegionTest
} }
} }
} }
} }