$beeConfig = $configDir . '/bee.yml'; $config = $configDir . '/config.yml'; $fileSystemConfig = $configDir . '/filesystem-plugin.yml'; $multiChangeModeConfig = $configDir . '/filesystem-multi-change-mode.yml'; $dirTransferConfig = $configDir . '/filesystem-dir-transfer.yml'; function isPluginEnabled($beeConfig, $plugin) { if (!file_exists($beeConfig)) { throw new Exception('bee config file not found'); } $parser = sfYaml::load($beeConfig); $plugins = isset($parser['project']['bee']['enabled_plugins']) ? $parser['project']['bee']['enabled_plugins'] : array(); return in_array($plugin, $plugins); } $t = new lime_test(12); $cmd = new nbGenerateProjectCommand(); $t->ok($cmd->run(new nbCommandLineParser(), $projectDir), 'Command nbGenerateProjectCommand called successfully'); $t->ok(file_exists($beeConfig), 'bee.yml added to the destination dir :' . $beeConfig); $t->ok(file_exists($config), 'config.yml added to the destination dir :' . $config); $t->comment('enabling nbDummyPlugin'); $plugin = 'nbDummyPlugin'; $t->ok(!isPluginEnabled($beeConfig, $plugin), $plugin . ' not found'); $cmd = new nbEnablePluginCommand(); $t->ok($cmd->run(new nbCommandLineParser(), $plugin . ' ' . $projectDir), 'Plugin enabled successfully'); $t->ok(isPluginEnabled($beeConfig, $plugin), $plugin . ' found'); $t->comment('enabling a fake plugin'); $cmd = new nbEnablePluginCommand(); try { $cmd->run(new nbCommandLineParser(), 'nbNonExistentPlugin' . ' ' . $projectDir); $t->fail('plugin nbNonExistentPlugin exists ?'); } catch (Exception $e) {
<?php require_once dirname(__FILE__) . '/../../../../test/bootstrap/unit.php'; nbConfig::set('nb_command_dir', nbConfig::get('nb_sandbox_dir')); nbConfig::set('nb_plugins_dir', nbConfig::get('nb_test_plugins_dir')); $configDir = nbConfig::get('nb_sandbox_dir') . '/.bee'; $beeYaml = $configDir . '/bee.yml'; $configYaml = $configDir . '/config.yml'; $projectType = 'foo'; $t = new lime_test(32); $cmd = new nbGenerateProjectCommand(); $t->ok($cmd->run(new nbCommandLineParser(), nbConfig::get('nb_sandbox_dir')), 'Command nbGenerateProjectCommand called successfully'); $t->ok(file_exists($beeYaml), 'bee.yml added to the destination dir :' . $beeYaml); $t->ok(file_exists($configYaml), 'config.yml added to the destination dir :' . $configYaml); try { $cmd->run(new nbCommandLineParser(), nbConfig::get('nb_sandbox_dir')); $t->fail('Exception not thrown'); } catch (Exception $e) { $t->pass('Exception nbFileSystem::copy() thrown'); } $t->ok($cmd->run(new nbCommandLineParser(), '--force ' . nbConfig::get('nb_sandbox_dir')), 'Command nbGenerateProjectCommand called successfully'); $t->ok(file_exists($beeYaml), 'bee.yml added to the destination dir :' . $beeYaml); $t->ok(file_exists($configYaml), 'config.yml added to the destination dir :' . $configYaml); // Tear down $fs = nbFileSystem::getInstance(); $fs->delete($beeYaml); $fs->delete($configYaml); $fs->rmdir($configDir); $t->ok($cmd->run(new nbCommandLineParser(), sprintf('--type=%s %s', $projectType, nbConfig::get('nb_sandbox_dir')), 'Command nbGenerateProjectCommand called successfully')); $t->ok(file_exists($beeYaml), 'bee.yml added to the destination dir :' . $beeYaml); $t->ok(file_exists($configYaml), 'config.yml added to the destination dir :' . $configYaml);