<?php require_once dirname(__FILE__) . '/../bootstrap/unit.php'; $t = new lime_test(32); $fs = nbFileSystem::getInstance(); $sourceDir = nbConfig::get('filesystem_dir-transfer_source-dir'); $targetDir = nbFileSystem::sanitizeDir(nbConfig::get('filesystem_dir-transfer_target-dir')); $fileToSync = $targetDir . '/' . nbConfig::get('filesystem_test_file-to-sync'); $folderToExclude = $targetDir . '/' . nbConfig::get('filesystem_test_folder-to-exclude'); $fileToExclude = $targetDir . '/' . nbConfig::get('filesystem_test_file-to-exclude'); $fileToInclude = $targetDir . '/' . nbConfig::get('filesystem_test_file-to-include'); $otherFileToSync = $targetDir . '/' . nbConfig::get('filesystem_test_other-file-to-sync'); $fileToDelete = $targetDir . '/fileToDelete'; $excludeFile = nbConfig::get('filesystem_dir-transfer_exclude-from'); $includeFile = nbConfig::get('filesystem_dir-transfer_include-from'); $cmd = new nbDirTransferCommand(); $fs->touch($fileToDelete); $commandLine = sprintf('--delete %s %s', $sourceDir, $targetDir); $t->ok($cmd->run(new nbCommandLineParser(), $commandLine), 'Command nbDirTransfer called successfully dry run'); $t->ok(!file_exists($fileToSync), 'fileToSync wasn\'t synchronized in the target site because doit option was not set'); $t->ok(!file_exists($otherFileToSync), 'otherFileToSyn wasn\'t synchronized in the target folder'); $t->ok(!file_exists($folderToExclude), 'folderToExclude wasn\'t synchronized in the target folder'); $t->ok(!file_exists($fileToExclude), 'fileToExclude wasn\'t synchronized in the target folder'); $t->ok(!file_exists($fileToInclude), 'fileToInclude wasn\'t synchronized in the target folder'); $t->ok(file_exists($fileToDelete), 'fileToDelete wasn\'t deleted in the target folder'); $t->ok($cmd->run(new nbCommandLineParser(), '--doit ' . $commandLine), 'Command nbDirTransfer called successfully doit option set'); $t->ok(file_exists($fileToSync), 'fileToSync was synchronized in the target folder'); $t->ok(file_exists($otherFileToSync), 'otherFileToSync was synchronized in the target folder'); $t->ok(file_exists($folderToExclude), 'folderToExclude was synchronized in the target folder'); $t->ok(file_exists($fileToExclude), 'fileToEclude was synchronized in the target folder'); $t->ok(file_exists($fileToInclude), 'fileToInclude was synchronized in the target folder');
protected function execute(array $arguments = array(), array $options = array()) { $this->logLine('Diem Deploy'); $configParser = new nbYamlConfigParser(); $configParser->parseFile($arguments['config-file']); $symfonyExePath = nbConfig::get('symfony_project-deploy_symfony-root-dir'); // Put website offline if (nbConfig::has('symfony_project-deploy_site-applications')) { foreach (nbConfig::get('symfony_project-deploy_site-applications') as $key => $value) { $cmd = new nbSymfonyGoOfflineCommand(); $application = nbConfig::get('symfony_project-deploy_site-applications_' . $key . "_name"); $environment = nbConfig::get('symfony_project-deploy_site-applications_' . $key . "_env"); $cmd->run(new nbCommandLineParser(), sprintf('%s %s %s', $symfonyExePath, $application, $environment)); } } // Archive site directory if (nbConfig::has('archive_inflate-dir')) { $cmd = new nbInflateDirCommand(); $commandLine = '--config-file=' . $arguments['config-file']; $cmd->run(new nbCommandLineParser(), $commandLine); } // Dump database if (nbConfig::has('mysql_dump')) { $cmd = new nbMysqlDumpCommand(); $commandLine = '--config-file=' . $arguments['config-file']; $cmd->run(new nbCommandLineParser(), $commandLine); } // Sync project if (nbConfig::has('filesystem_dir-transfer')) { $cmd = new nbDirTransferCommand(); $commandLine = '--doit --delete --config-file=' . $arguments['config-file']; $cmd->run(new nbCommandLineParser(), $commandLine); } // Check dirs $cmd = new nbSymfonyCheckDirsCommand(); $commandLine = $symfonyExePath; $cmd->run(new nbCommandLineParser(), $commandLine); // Check permissions $cmd = new nbSymfonyCheckPermissionsCommand(); $commandLine = $symfonyExePath; $cmd->run(new nbCommandLineParser(), $commandLine); // Change ownership $cmd = new nbSymfonyChangeOwnershipCommand(); $commandLine = sprintf('%s %s %s', nbConfig::get('symfony_project-deploy_site-dir'), nbConfig::get('symfony_project-deploy_site-user'), nbConfig::get('symfony_project-deploy_site-group')); $cmd->run(new nbCommandLineParser(), $commandLine); // Restore database if (nbConfig::has('mysql_restore')) { $cmd = new nbMysqlRestoreCommand(); $commandLine = '--config-file=' . $arguments['config-file']; $cmd->run(new nbCommandLineParser(), $commandLine); } // Diem setup $cmd = new nbSymfonyDiemSetupCommand(); $commandLine = $symfonyExePath; $cmd->run(new nbCommandLineParser(), $commandLine); // Clear cache $cmd = new nbSymfonyClearCacheCommand(); $commandLine = $symfonyExePath; $cmd->run(new nbCommandLineParser(), $commandLine); // Put site online if (nbConfig::has('symfony_project-deploy_site-applications')) { foreach (nbConfig::get('symfony_project-deploy_site-applications') as $key => $value) { $cmd = new nbSymfonyGoOnlineCommand(); $application = nbConfig::get('symfony_project-deploy_site-applications_' . $key . "_name"); $environment = nbConfig::get('symfony_project-deploy_site-applications_' . $key . "_env"); $cmd->run(new nbCommandLineParser(), sprintf('%s %s %s', $symfonyExePath, $application, $environment)); } } $this->logLine('Done - Diem Deploy'); return true; }