} } FileUtilities::removeFolderAndAllContents($otherAssetsFolderPath); } // cleanup LfMerge 'syncqueue', 'webwork' and 'state' folders if ($testProject->appName == LexProjectModel::LEXICON_APP) { $syncQueuePath = SendReceiveCommands::getLFMergePaths()->syncQueuePath; foreach (glob("{$syncQueuePath}/*") as $file) { if (is_file($file)) { unlink($file); } } $workPath = SendReceiveCommands::getLFMergePaths()->workPath; FileUtilities::removeFolderAndAllContents($workPath . DIRECTORY_SEPARATOR . $constants['srProjectCode']); FileUtilities::removeFolderAndAllContents($workPath . DIRECTORY_SEPARATOR . 'mock-id4'); $stateFilePath = SendReceiveCommands::getLFMergePaths()->statePath . DIRECTORY_SEPARATOR . 'mock-id4.state'; if (is_file($stateFilePath)) { unlink($stateFilePath); } } // cleanup mocked uploaded zip import (jpg file) $tmpFilePath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $constants['testMockJpgImportFile']['name']; @unlink($tmpFilePath); // cleanup mocked uploaded zip import (zip file) $tmpFilePath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $constants['testMockZipImportFile']['name']; @unlink($tmpFilePath); // cleanup mock uploaded audio (png file) $tmpFilePath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $constants['testMockPngUploadFile']['name']; @unlink($tmpFilePath); // cleanup mock uploaded audio (mp3 file) $tmpFilePath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $constants['testMockMp3UploadFile']['name'];
/** * Cleanup associated project files */ protected function cleanup() { parent::cleanup(); if (!is_null($this->projectCode)) { $projectFilename = strtolower($this->projectCode); $stateFilename = strtolower($this->projectCode) . '.state'; $lfmergePaths = SendReceiveCommands::getLFMergePaths(); foreach ($lfmergePaths as $key => $path) { if (!is_null($path)) { if ($key == "workPath") { FileUtilities::removeFolderAndAllContents($lfmergePaths->workPath . DIRECTORY_SEPARATOR . $projectFilename); } if (file_exists($path . DIRECTORY_SEPARATOR . $projectFilename)) { unlink($path . DIRECTORY_SEPARATOR . $projectFilename); } if (file_exists($path . DIRECTORY_SEPARATOR . $stateFilename)) { unlink($path . DIRECTORY_SEPARATOR . $stateFilename); } } } } }
public function testNotificationSendRequest_HasSendReceiveAndHasUncommittedEntry_Notified() { self::$environ->clean(); $project = self::$environ->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE); $project->sendReceiveProjectIdentifier = 'sr_id'; $project->sendReceiveProject = new SendReceiveProjectModel('sr_name', '', 'manager'); $project->write(); $tmpTestPath = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'notifiedTest'; $lfmergePaths = SendReceiveCommands::getLFMergePaths(true, $tmpTestPath); $projectStatePath = $lfmergePaths->statePath . DIRECTORY_SEPARATOR . strtolower($project->projectCode) . '.state'; FileUtilities::createAllFolders($tmpTestPath); FileUtilities::createAllFolders($lfmergePaths->sendQueuePath); FileUtilities::createAllFolders($lfmergePaths->statePath); file_put_contents($projectStatePath, '{"state": "SENDING", "uncommittedEditCount": 1}'); $mockPidFilePath = sys_get_temp_dir() . '/mockLFMerge.pid'; $mockCommand = 'php ' . __DIR__ . '/mockLFMergeExe.php'; $isNotified = SendReceiveCommands::notificationSendRequest($project->projectCode, $lfmergePaths->statePath, $lfmergePaths->sendQueuePath, $mockPidFilePath, $mockCommand); $queueFileNames = scandir($lfmergePaths->sendQueuePath); $this->assertTrue($isNotified); $this->assertCount(3, $queueFileNames); FileUtilities::removeFolderAndAllContents($tmpTestPath); }