本文整理汇总了PHP中eZClusterFileHandler::cleanupGeneratingFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP eZClusterFileHandler::cleanupGeneratingFiles方法的具体用法?PHP eZClusterFileHandler::cleanupGeneratingFiles怎么用?PHP eZClusterFileHandler::cleanupGeneratingFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZClusterFileHandler
的用法示例。
在下文中一共展示了eZClusterFileHandler::cleanupGeneratingFiles方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testShutdownHandler
/**
* Tests the cluster shutdown handler.
* Handlers that support stalecache should cleanup their generating files if any
*/
public function testShutdownHandler()
{
// Call the cleanup handler called by eZExecution::cleanExit()
self::assertFalse(eZClusterFileHandler::cleanupGeneratingFiles());
$path1 = 'var/tests/' . __FUNCTION__ . '/uncleanfile1.txt';
$path2 = 'var/tests/' . __FUNCTION__ . '/uncleanfile2.txt';
$path3 = 'var/tests/' . __FUNCTION__ . '/uncleanfile3.txt';
// start generation of a couple files
$file1 = eZClusterFileHandler::instance($path1);
$file1->startCacheGeneration();
$file1->storeContents(__METHOD__);
$file2 = eZClusterFileHandler::instance($path2);
$file2->startCacheGeneration();
$file2->storeContents(__METHOD__);
$file3 = eZClusterFileHandler::instance($path3);
$file3->startCacheGeneration();
$file3->storeContents(__METHOD__);
// terminate one of them
$file2->endCacheGeneration();
// check that the generating status is as expected
self::assertStringEndsWith('.generating', $file1->filePath, '$file1 is not generating');
self::assertStringEndsNotWith('.generating', $file2->filePath, '$file2 is generating');
self::assertStringEndsWith('.generating', $file3->filePath, '$file3 is not generating');
// Call the cleanup handler called by eZExecution::cleanExit()
self::assertTrue(eZClusterFileHandler::cleanupGeneratingFiles(), 'eZClusterFileHandler::cleanupGeneratingFiles() returned false');
// Check that all files are no longer marked as generating
self::assertStringEndsNotWith('.generating', $file1->filePath, '$file1 is still generating');
self::assertStringEndsNotWith('.generating', $file2->filePath, '$file2 is still generating');
self::assertStringEndsNotWith('.generating', $file3->filePath, '$file3 is still generating');
}