| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
include dirname(__FILE__).'/../../bootstrap/unit.php'; |
|---|
| 4 |
|
|---|
| 5 |
$t = new task_extra_lime_test(37, new lime_output_color()); |
|---|
| 6 |
|
|---|
| 7 |
$t->diag('sfGeneratePluginTask'); |
|---|
| 8 |
$t->task_ok('sfGeneratePluginTask', array('sfTest*Plugin'), array(), false, '"sfGeneratePluginTask" fails when plugin name includes bad characters'); |
|---|
| 9 |
$t->task_ok('sfGeneratePluginTask', array('sfTest'), array(), false, '"sfGeneratePluginTask" fails when plugin name ends other than "Plugin"'); |
|---|
| 10 |
$t->task_ok('sfGeneratePluginTask', array('sfTestPlugin')); |
|---|
| 11 |
$t->task_ok('sfGeneratePluginTask', array('sfTestPlugin'), array(), false, '"sfGeneratePluginTask" fails when plugin already exists'); |
|---|
| 12 |
|
|---|
| 13 |
mkdir(sfConfig::get('sf_plugins_dir').'/anotherPlugin'); |
|---|
| 14 |
$t->task_ok('sfGeneratePluginTask', array('anotherPlugin'), array(), true, '"sfGeneratePluginTask" runs on an empty plugin directory'); |
|---|
| 15 |
|
|---|
| 16 |
$plugin_dir = sfConfig::get('sf_plugins_dir').'/sfTestPlugin'; |
|---|
| 17 |
$config_file = $plugin_dir.'/config/sfTestPluginConfiguration.class.php'; |
|---|
| 18 |
$test_project = $plugin_dir.'/test/fixtures/project'; |
|---|
| 19 |
$test_app = $test_project.'/apps/frontend'; |
|---|
| 20 |
|
|---|
| 21 |
$t->ok(is_dir($plugin_dir), '"sfGeneratePluginTask" creates the plugin directory'); |
|---|
| 22 |
$t->ok(file_exists($config_file), '"sfGeneratePluginTask" creates a plugin configuration file'); |
|---|
| 23 |
$t->like(@file_get_contents($config_file), '/class sfTestPluginConfiguration extends sfPluginConfiguration/', '"sfGeneratePluginTask" creates the plugin configuration class'); |
|---|
| 24 |
$t->like(@file_get_contents($plugin_dir.'/test/bootstrap/unit.php'), '/new sfTestPluginConfiguration/', '"sfGeneratePluginTask" includes the plugin config in the unit test bootstrapper'); |
|---|
| 25 |
$t->ok(file_exists($test_project.'/config/ProjectConfiguration.class.php'), '"sfGeneratePluginTask" creates a test project'); |
|---|
| 26 |
$t->like(@file_get_contents($test_project.'/config/ProjectConfiguration.class.php'), '/sfTestPlugin/', '"sfGeneratePluginTask" includes a customized ProjectConfiguration'); |
|---|
| 27 |
$t->ok(file_exists($test_app.'/config/frontendConfiguration.class.php'), '"sfGeneratePluginTask" creates a test app'); |
|---|
| 28 |
|
|---|
| 29 |
$t->task_ok('sfGeneratePluginTask', array('sfTestPlugin'), array(), false, '"sfGeneratePluginTask" fails if plugin already exists'); |
|---|
| 30 |
|
|---|
| 31 |
$t->diag('sfGeneratePluginModuleTask'); |
|---|
| 32 |
$t->task_ok('sfGeneratePluginModuleTask', array('nonexistantPlugin', 'example'), array(), false, '"sfGeneratePluginModuleTask" fails when plugin does not exist'); |
|---|
| 33 |
$t->task_ok('sfGeneratePluginModuleTask', array('sfTestPlugin', 'example*'), array(), false, '"sfGeneratePluginModuleTask" fails when module name includes bad characters'); |
|---|
| 34 |
$t->task_ok('sfGeneratePluginModuleTask', array('sfTestPlugin', 'example')); |
|---|
| 35 |
|
|---|
| 36 |
$module_dir = $plugin_dir.'/modules/example'; |
|---|
| 37 |
$actions_file = $module_dir.'/actions/actions.class.php'; |
|---|
| 38 |
$base_actions_file = $module_dir.'/lib/BaseexampleActions.class.php'; |
|---|
| 39 |
|
|---|
| 40 |
$t->ok(is_dir($module_dir), '"sfGeneratePluginModuleTask" creates a module directory'); |
|---|
| 41 |
$t->ok(file_exists($actions_file), '"sfGeneratePluginModuleTask" creates an actions file'); |
|---|
| 42 |
$t->like(@file_get_contents($actions_file), '/class exampleActions extends BaseexampleActions/', '"sfGeneratePluginModuleTask" creates an actions class'); |
|---|
| 43 |
$t->ok(file_exists($base_actions_file), '"sfGeneratePluginModuleTask" creates a base actions file'); |
|---|
| 44 |
$t->like(@file_get_contents($base_actions_file), '/class BaseexampleActions extends sfActions/', '"sfGeneratePluginModuleTask" creates a base actions class'); |
|---|
| 45 |
$t->ok(file_exists($plugin_dir.'/test/functional/exampleActionsTest.php'), '"sfGeneratePluginModuleTask" creates a functional test file'); |
|---|
| 46 |
$t->like(@file_get_contents($test_project.'/config/settings.yml'), '/\bexample\b/', '"sfGeneratePluginModuleTask" enabled module in test project'); |
|---|
| 47 |
|
|---|
| 48 |
$t->diag('sfGeneratePluginTask --module option'); |
|---|
| 49 |
$t->task_ok('sfGeneratePluginTask', array('sfTestAgainPlugin'), array('--module=one', '--module=two')); |
|---|
| 50 |
$t->ok(is_dir(sfConfig::get('sf_plugins_dir').'/sfTestAgainPlugin/modules/one'), '"sfGeneratePluginTask" creates modules when "--module" is used'); |
|---|
| 51 |
$t->ok(is_dir(sfConfig::get('sf_plugins_dir').'/sfTestAgainPlugin/modules/two'), '"sfGeneratePluginTask" creates modules when "--module" is used'); |
|---|
| 52 |
$t->like(@file_get_contents(sfConfig::get('sf_plugins_dir').'/sfTestAgainPlugin/test/fixtures/project/config/settings.yml'), '/\bone\b/', '"sfGeneratePluginTask" enables modules when "--module" is used'); |
|---|
| 53 |
$t->like(@file_get_contents(sfConfig::get('sf_plugins_dir').'/sfTestAgainPlugin/test/fixtures/project/config/settings.yml'), '/\btwo\b/', '"sfGeneratePluginTask" enables modules when "--module" is used'); |
|---|
| 54 |
|
|---|
| 55 |
$t->diag('sfGeneratePluginTask --skip-test-dir option'); |
|---|
| 56 |
$t->task_ok('sfGeneratePluginTask', array('sfTestYetAgainPlugin'), array('--skip-test-dir', '--module=another')); |
|---|
| 57 |
$t->ok(!is_dir(sfConfig::get('sf_plugins_dir').'/sfTestYetAgainPlugin/test'), '"sfGeneratePluginTask" does not generate a test directory when "--skip-test-dir" is used'); |
|---|
| 58 |
|
|---|
| 59 |
$t->diag('sfGenerateTestsTask'); |
|---|
| 60 |
$t->task_ok('sfGenerateTestsTask', array(), array(), true); |
|---|
| 61 |
$t->ok(file_exists(sfConfig::get('sf_test_dir').'/unit/form/FormTest.php'), '"sfGenerateTestsTask" creates test files'); |
|---|
| 62 |
|
|---|
| 63 |
$t->diag('sfGenerateTestTask'); |
|---|
| 64 |
$t->task_ok('sfGenerateTestTask', array('Form'), array(), false, '"sfGenerateTestTask" fails if test script exists'); |
|---|
| 65 |
$t->task_ok('sfGenerateTestTask', array('Form'), array('--force'), true, '"sfGenerateTestTask" succeeds with existing file and --force option'); |
|---|
| 66 |
$t->like(@file_get_contents(sfConfig::get('sf_test_dir').'/unit/form/FormTest.php'), '/getWidgetSchema\(\)/', '"sfGenerateTestTask" detects appropriate template'); |
|---|
| 67 |
$t->unlike(@file_get_contents(sfConfig::get('sf_test_dir').'/unit/form/FormTest.php'), '/__construct\(\)/', '"sfGenerateTestTask" detects appropriate template'); |
|---|
| 68 |
$t->like(@file_get_contents(sfConfig::get('sf_test_dir').'/unit/util/ToolkitTest.php'), '/doXYZ\(\)/', '"sfGenerateTestTask" creates method test stubs'); |
|---|
| 69 |
|
|---|