/** * 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'); }