public function testThemeAndPluginInclusion()
    {
        App::build(array('Plugin' => array($this->_testFiles . 'Plugin' . DS), 'View' => array($this->_testFiles . 'View' . DS)));
        CakePlugin::load('TestAsset');
        $settings = array('paths' => array(), 'theme' => 'Red');
        $this->filter->settings($settings);
        $this->_themeDir = $this->_testFiles . DS . 'View' . DS . 'Themed' . DS . $settings['theme'] . DS;
        $content = file_get_contents($this->_themeDir . 'webroot' . DS . 'theme.js');
        $result = $this->filter->input('theme.js', $content);
        $expected = <<<TEXT
var Theme = new Class({

});
var ThemeInclude = new Class({

});

var Plugin = new Class({

});


TEXT;
        $this->assertTextEquals($expected, $result);
    }
示例#2
0
 public function links()
 {
     if (!CakePlugin::loaded('Menus')) {
         CakePlugin::load('Menus');
     }
     App::uses('View', 'View');
     App::uses('AppHelper', 'View/Helper');
     App::uses('MenusHelper', 'Menus.View/Helper');
     $Menus = new MenusHelper(new View());
     $Link = ClassRegistry::init('Menus.Link');
     $links = $Link->find('all', array('fields' => array('id', 'title', 'link')));
     $count = 0;
     foreach ($links as $link) {
         if (!strstr($link['Link']['link'], 'controller:')) {
             continue;
         }
         if (strstr($link['Link']['link'], 'plugin:')) {
             continue;
         }
         $url = $Menus->linkStringToArray($link['Link']['link']);
         if (isset($this->_controllerMap[$url['controller']])) {
             $url['plugin'] = $this->_controllerMap[$url['controller']];
             $linkString = $Menus->urlToLinkString($url);
             $Link->id = $link['Link']['id'];
             $this->out(__('Updating Link %s', $Link->id));
             $this->warn(__('- %s', $link['Link']['link']));
             $this->success(__('+ %s', $linkString), 2);
             $Link->saveField('link', $linkString, false);
             $count++;
         }
     }
     $this->out(__('Links updated: %d rows', $count));
 }
示例#3
0
 /**
  * Generates the base path to a set of tests based on the parameters.
  *
  * @param array $params
  * @return string The base path.
  */
 protected static function _basePath($params)
 {
     $result = null;
     if (!empty($params['core'])) {
         $result = CORE_TEST_CASES;
         // CUSTOMIZE ADD 2014/07/02 ryuring
         // >>>
     } elseif ($params['baser']) {
         $result = BASER_TEST_CASES;
         // <<<
     } elseif (!empty($params['plugin'])) {
         if (!CakePlugin::loaded($params['plugin'])) {
             try {
                 CakePlugin::load($params['plugin']);
                 $result = CakePlugin::path($params['plugin']) . 'Test' . DS . 'Case';
             } catch (MissingPluginException $e) {
             }
         } else {
             $result = CakePlugin::path($params['plugin']) . 'Test' . DS . 'Case';
         }
     } elseif (!empty($params['app'])) {
         $result = APP_TEST_CASES;
     }
     return $result;
 }
	public function setUp() {
		parent::setUp();
		$this->_pluginPath = App::pluginPath('AssetCompress');
		$this->testConfig = $this->_pluginPath . 'Test' . DS . 'test_files' . DS . 'Config' . DS . 'integration.ini';

		$map = array(
			'TEST_FILES/' => $this->_pluginPath . 'Test' . DS . 'test_files' . DS
		);
		App::build(array(
			'Plugin' => array($map['TEST_FILES/'] . 'Plugin' . DS )
		));
		CakePlugin::load('TestAssetIni');
		
		AssetConfig::clearAllCachedKeys();

		$config = AssetConfig::buildFromIniFile($this->testConfig, $map);
		$config->filters('js', null, array());
		$this->Compressor = $this->getMock('AssetCompressor', array('_getConfig'));
		$this->Compressor->expects($this->atLeastOnce())
			->method('_getConfig')
			->will($this->returnValue($config));

		$this->request = new CakeRequest(null, false);
		$this->response = $this->getMock('CakeResponse', array('checkNotModified', 'type', 'send'));
		Configure::write('debug', 2);
	}
 public function setUp()
 {
     App::build(array('View' => array(App::pluginPath('Asset') . 'Test' . DS . 'test_app' . DS . 'View' . DS), 'Plugin' => array(App::pluginPath('Asset') . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)), App::RESET);
     CakePlugin::load('Other', array());
     $this->path = App::pluginPath('Asset') . 'Test' . DS . 'test_app' . DS . 'webroot' . DS;
     $this->AssetEnvironment = new AssetEnvironment($this->path);
 }
示例#6
0
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Cache::delete('object_map', '_cake_core_');
     App::build(array('Locale' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Locale' . DS), 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)), App::RESET);
     CakePlugin::load(array('TestPlugin'));
 }
示例#7
0
 public function onActivation(&$controller)
 {
     CakePlugin::load('Sites');
     App::import('Model', 'CakeSchema');
     App::import('Model', 'ConnectionManager');
     App::uses('Sites', 'Sites.Lib');
     include_once APP . 'Plugin' . DS . 'Sites' . DS . 'Config' . DS . 'Schema' . DS . 'schema.php';
     $db = ConnectionManager::getDataSource('default');
     //Get all available tables
     $tables = $db->listSources();
     $CakeSchema = new CakeSchema();
     $SiteSchema = new SiteSchema();
     foreach ($SiteSchema->tables as $table => $config) {
         if (!in_array($table, $tables)) {
             $db->execute($db->createSchema($SiteSchema, $table));
         }
     }
     //Ignore the cache since the tables wont be inside the cache at this point
     //$db->cacheSources = false;
     @unlink(TMP . 'cache' . DS . 'models/cake_model_' . ConnectionManager::getSourceName($db) . '_' . $db->config["database"] . '_list');
     $db->listSources();
     //Insert "ALL SITES"
     $controller->loadModel('Sites.Site');
     $controller->Site->create();
     $data = array('Site' => array('id' => Sites::ALL_SITES, 'title' => 'All Sites', 'tagline' => Configure::read('Site.tagline'), 'email' => Configure::read('Site.email'), 'locale' => Configure::read('Site.locale'), 'status' => Configure::read('Site.status'), 'timezone' => Configure::read('Site.timezone'), 'theme' => Configure::read('Site.theme'), 'default' => 1), 'SiteDomain' => array(0 => array('site_id' => Sites::ALL_SITES, 'domain' => $_SERVER["HTTP_HOST"])));
     $controller->Site->id = Sites::ALL_SITES;
     if ($controller->Site->exists()) {
         $count = $controller->Site->SiteDomain->find('count', array('conditions' => array('SiteDomain.site_id' => Sites::ALL_SITES)));
         if ($count > 0) {
             unset($data['SiteDomain']);
         }
     }
     $controller->Site->saveAll($data);
 }
 public function setUp()
 {
     parent::setUp();
     App::build(array('Plugin' => array(App::pluginPath('TwigView') . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)));
     App::build(array('View' => array(App::pluginPath('TwigView') . 'Test' . DS . 'test_app' . DS . 'View' . DS)), App::RESET);
     CakePlugin::load('TestTwigView');
     $this->Loader = new Twig_Loader_Cakephp();
 }
示例#9
0
 public function setUp()
 {
     parent::setUp();
     CakePlugin::load('Translate');
     $this->View = new View(null);
     $this->AppHelper = new CroogoAppHelper($this->View);
     $this->AppHelper->request = new CakeRequest(null, false);
 }
示例#10
0
 public function setUp()
 {
     parent::setUp();
     CakePlugin::load('Translate', array('bootstrap' => true));
     $this->View = new View(null);
     $this->AppHelper = new AppHelper($this->View);
     $this->AppHelper->request = new CakeRequest(null, false);
 }
 /**
  * setUp
  */
 public function setUp()
 {
     parent::setUp();
     CakePlugin::load('Translate', array('bootstrap' => true));
     $this->TranslateController = $this->generate('Translate.Translate', array('methods' => array('redirect'), 'components' => array('Auth' => array('user'), 'Session')));
     $this->TranslateController->Auth->staticExpects($this->any())->method('user')->will($this->returnCallback(array($this, 'authUserCallback')));
     $this->TranslateController->Security->Session = $this->getMock('CakeSession');
 }
示例#12
0
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), 'Console/Command' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Console' . DS . 'Command' . DS)), App::RESET);
     CakePlugin::load(array('TestPlugin', 'TestPluginTwo'));
     $out = $this->getMock('ConsoleOutput', array(), array(), '', FALSE);
     $in = $this->getMock('ConsoleInput', array(), array(), '', FALSE);
     $this->CommandTask = $this->getMock('CommandTask', array('in', '_stop', 'clear'), array($out, $out, $in));
 }
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), 'Console/Command' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Console' . DS . 'Command' . DS)), App::RESET);
     CakePlugin::load(array('TestPlugin', 'TestPluginTwo'));
     $out = new TestStringOutput();
     $in = $this->getMock('ConsoleInput', array(), array(), '', false);
     $this->Shell = $this->getMock('CommandListShell', array('in', '_stop', 'clear'), array($out, $out, $in));
 }
 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->Node = ClassRegistry::init('Nodes.Node');
     if (!CakePlugin::loaded('Translate')) {
         CakePlugin::load('Translate');
     }
     $this->Node->Behaviors->attach('Translate.CroogoTranslate', array('fields' => array('title' => 'titleTranslation')));
 }
示例#15
0
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->request = new CakeRequest(null, false);
     $this->Controller = new ScaffoldViewMockController($this->request);
     $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
     App::build(array('View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS), 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)));
     CakePlugin::load('TestPlugin');
 }
 /**
  * testPathsPlugin
  */
 public function testPathsPlugin()
 {
     CakePlugin::load('ApiTestPlugin');
     $paths = $this->View->paths('ApiTestPlugin');
     foreach ($paths as &$path) {
         $path = str_replace(array($this->testAppPath, APP, CAKE), array('APP/', 'APP/', 'CAKE/'), $path);
     }
     $expected = array('APP/View/Plugin/ApiTestPlugin/', 'APP/Plugin/ApiTestPlugin/View/', 'APP/View/', 'CAKE/View/', 'CAKE/Console/Templates/skel/View/', 'APP/Plugin/Api/View/');
     $this->assertSame($expected, $paths);
 }
示例#17
0
 public static function suite()
 {
     $suite = new CakeTestSuite('All core plugins tests');
     $plugins = array('Acl', 'Blocks', 'Comments', 'Contacts', 'Nodes', 'Extensions', 'FileManager', 'Menus', 'Meta', 'Settings', 'Taxonomy', 'Tinymce', 'Translate', 'Users');
     foreach ($plugins as $plugin) {
         CakePlugin::load($plugin);
         $suite->addTestDirectoryRecursive(CakePlugin::path($plugin) . 'Test' . DS);
     }
     return $suite;
 }
 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)), App::RESET);
     CakePlugin::load(array('TestPlugin'));
     $reporter = new CakeBaseReporter();
     $reporter->params = array('app' => false, 'plugin' => false, 'group' => false);
     $coverage = array();
     $this->Coverage = new HtmlCoverageReport($coverage, $reporter);
 }
示例#19
0
 /**
  * testGetMapping method
  *
  * @return void
  */
 public function testGetMapping()
 {
     CakePlugin::load('TestMigrationPlugin');
     $result = $this->Version->getMapping('test_migration_plugin');
     $expected = array(1 => array('version' => 1, 'name' => '001_schema_dump', 'class' => 'M4af6d40056b04408808500cb58157726', 'type' => 'TestMigrationPlugin', 'migrated' => null), 2 => array('version' => 2, 'name' => '002_another_migration_plugin_test_migration', 'class' => 'AnotherMigrationPluginTestMigration', 'type' => 'TestMigrationPlugin', 'migrated' => null));
     $this->assertEqual($result, $expected);
     $result = $this->Version->getMapping('migrations');
     $expected = array(1 => array('version' => 1, 'name' => '001_init_migrations', 'class' => 'InitMigrations', 'type' => 'Migrations', 'migrated' => '2009-11-10 00:55:34'), 2 => array('version' => 2, 'name' => '002_convert_version_to_class_names', 'class' => 'ConvertVersionToClassNames', 'type' => 'Migrations', 'migrated' => '2011-11-18 13:53:32'), 3 => array('version' => 3, 'name' => '003_increase_class_name_length', 'class' => 'IncreaseClassNameLength', 'type' => 'Migrations', 'migrated' => null));
     $this->assertEqual($result, $expected);
 }
示例#20
0
 /**
  * Execution method always used for tasks
  * Removed options merge, ignore-model-validation, validation-domain, extract-core
  *
  * @return void
  */
 public function execute()
 {
     if (!empty($this->params['exclude'])) {
         $this->_exclude = explode(',', $this->params['exclude']);
     }
     // exclude Bancha plugins
     array_push($this->_exclude, App::pluginPath('Bancha') . DS . 'Test' . DS . 'JavaScriptUnitTest');
     if (isset($this->params['files']) && !is_array($this->params['files'])) {
         $this->_files = explode(',', $this->params['files']);
     }
     if (isset($this->params['paths'])) {
         $this->_paths = explode(',', $this->params['paths']);
     } elseif (isset($this->params['plugin'])) {
         $plugin = Inflector::camelize($this->params['plugin']);
         if (!CakePlugin::loaded($plugin)) {
             CakePlugin::load($plugin);
         }
         $this->_paths = array(CakePlugin::path($plugin));
         $this->params['plugin'] = $plugin;
     } else {
         $this->_getPaths();
     }
     $this->_extractCore = false;
     if (!empty($this->params['exclude-plugins']) && $this->_isExtractingApp()) {
         $this->_exclude = array_merge($this->_exclude, App::path('plugins'));
     }
     $this->_extractValidation = false;
     $this->_validationDomain = false;
     if (isset($this->params['output'])) {
         $this->_output = $this->params['output'];
     } elseif (isset($this->params['plugin'])) {
         $this->_output = $this->_paths[0] . DS . 'Locale';
     } else {
         $message = __d('cake_console', "What is the path you would like to output?\n[Q]uit", $this->_paths[0] . DS . 'Locale');
         while (true) {
             $response = $this->in($message, null, rtrim($this->_paths[0], DS) . DS . 'Locale');
             if (strtoupper($response) === 'Q') {
                 $this->out(__d('cake_console', 'Extract Aborted'));
                 $this->_stop();
             } elseif (is_dir($response)) {
                 $this->_output = $response . DS;
                 break;
             } else {
                 $this->err(__d('cake_console', 'The directory path you supplied was not found. Please try again.'));
             }
             $this->out();
         }
     }
     if (empty($this->_files)) {
         $this->_searchFiles();
     }
     $this->_output = rtrim($this->_output, DS) . DS;
     $this->_extract();
 }
示例#21
0
 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     App::build(array('Plugin' => array(TESTS . 'test_app' . DS . 'Plugin' . DS), 'View' => array(TESTS . 'test_app' . DS . 'View' . DS)), App::PREPEND);
     CakePlugin::unload('Install');
     CakePlugin::load('Example');
     Configure::write('Acl.database', 'test');
     $Setting = ClassRegistry::init('Setting');
     $Setting->settingsPath = TESTS . 'test_app' . DS . 'Config' . DS . 'settings.yml';
     $Setting->writeConfiguration();
 }
示例#22
0
 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $appDir = CakePlugin::path('Croogo') . 'Test' . DS . 'test_app' . DS;
     App::build(array('Plugin' => array($appDir . 'Plugin' . DS), 'View' => array($appDir . 'View' . DS)), App::PREPEND);
     $this->_paths = App::paths();
     CakePlugin::unload('Install');
     CakePlugin::load('Example');
     Configure::write('Acl.database', 'test');
     $this->setupSettings($appDir);
 }
 public function setup()
 {
     parent::setup();
     if (!CakePlugin::loaded('Search')) {
         try {
             CakePlugin::load('Search');
         } catch (MissingPluginException $e) {
             $this->markTestSkipped('Search plugin not available');
         }
     }
 }
示例#24
0
 public function runMigrations($plugin)
 {
     if (!CakePlugin::loaded($plugin)) {
         CakePlugin::load($plugin);
     }
     $CroogoPlugin = $this->_getCroogoPlugin();
     $result = $CroogoPlugin->migrate($plugin);
     if (!$result) {
         $this->log($CroogoPlugin->migrationErrors);
     }
     return $result;
 }
 function testResolvePluginPaths()
 {
     App::build(array('Plugin' => array($this->_testFiles . 'Plugin' . DS)));
     CakePlugin::load('TestAsset');
     $paths = array($this->_testFiles . 'css' . DS);
     $scanner = new AssetScanner($paths);
     $result = $scanner->find('p:TestAsset:plugin.css');
     $expected = $this->_testFiles . 'Plugin' . DS . 'TestAsset' . DS . 'webroot' . DS . 'plugin.css';
     $this->assertEqual($expected, $result);
     $result = $scanner->find('plugin:TestAsset:plugin.css');
     $this->assertEqual($expected, $result);
 }
示例#26
0
 /**
  * setUp method
  *
  */
 public function setUp()
 {
     parent::setUp();
     $this->View = $this->getMock('View', array('addScript'), array(new PartialTestController()));
     $this->Partial = new TestPartialHelper($this->View);
     $this->Partial->request = new CakeRequest(null, false);
     $this->Partial->request->webroot = '';
     App::build(array('plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)), true);
     CakePlugin::load(array('TestPlugin', 'TestPlugin', 'PluginJs'));
     Configure::write('debug', 2);
     Configure::write('Asset.timestamp', false);
 }
示例#27
0
 /**
  * onActivate will be called if this returns true
  *
  * @param  object $controller Controller
  * @return boolean
  */
 public function beforeActivation(&$controller)
 {
     if (!CakePlugin::loaded('Imagine')) {
         $plugins = App::objects('plugins');
         if (in_array('Imagine', $plugins)) {
             $plugin = new CroogoPlugin();
             $plugin->addBootstrap('Imagine');
             CakePlugin::load('Imagine');
             CakeLog::info('Imagine plugin added to bootstrap');
         }
     }
     return true;
 }
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     CakePlugin::load('Kickstart');
     $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
     $in = $this->getMock('ConsoleInput', array(), array(), '', false);
     $methods = array('in', 'out', 'err', 'error', 'hr', 'createFile', '__exec');
     $this->Shell = $this->getMock('KickstartShell', $methods, array($out, $out, $in));
     $this->Shell->KickstartCommand = $this->getMock('KickstartCommandTask', array('in', 'out', 'err', 'error', 'hr', 'createFile', '_exec', '_chdir'), array($out, $out, $in));
     $this->Shell->params['app'] = APP_DIR;
     $this->Shell->params['working'] = APP;
     $this->Shell->args = array('Kickstart.test');
 }
 /**
  * test importing loggers from app/libs and plugins.
  *
  * @return void
  */
 public function testImportingLoggers()
 {
     App::build(array('Lib' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS), 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)), App::RESET);
     CakePlugin::load('TestPlugin');
     $result = CakeLog::config('libtest', array('engine' => 'TestAppLog'));
     $this->assertTrue($result);
     $this->assertEquals(CakeLog::configured(), array('libtest'));
     $result = CakeLog::config('plugintest', array('engine' => 'TestPlugin.TestPluginLog'));
     $this->assertTrue($result);
     $this->assertEquals(CakeLog::configured(), array('libtest', 'plugintest'));
     App::build();
     CakePlugin::unload();
 }
示例#30
0
 public static function suite()
 {
     $suite = new CakeTestSuite('Croogo core plugins tests');
     $plugins = array('Acl', 'Blocks', 'Comments', 'Contacts', 'Croogo', 'Nodes', 'Extensions', 'FileManager', 'Menus', 'Meta', 'Settings', 'Taxonomy', 'Ckeditor', 'Translate', 'Users');
     if ((int) Configure::read('debug') > 0) {
         $plugins[] = 'Install';
     }
     foreach ($plugins as $plugin) {
         CakePlugin::load($plugin);
         $suite->addTestDirectoryRecursive(CakePlugin::path($plugin) . 'Test' . DS);
     }
     return $suite;
 }