Beispiel #1
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Plugin::unload('TestPlugin');
     Plugin::unload('TestTheme');
     unset($this->View);
 }
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Plugin::unload();
     ConnectionManager::drop('test_variant');
     ConnectionManager::dropAlias('other_name');
 }
Beispiel #3
0
 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->Shell);
     Configure::write('App.namespace', 'App');
     Plugin::unload();
 }
 /**
  * Builds asset file path based off url
  *
  * @param string $url Asset URL
  * @return string Absolute path for asset file
  */
 protected function _getAssetFile($url)
 {
     //Brood unload hack cause vendor plugin loaded for some reason
     Plugin::unload('Garderobe');
     $parts = explode('/', $url);
     $fileType = array_shift($parts);
     $fileFragment = implode(DS, $parts);
     $allowedExtensions = ComponentInstallerConfigureTrait::getSupportedExtensions();
     $registeredComponents = (require ROOT . DS . 'vendor' . DS . 'cakephp-components.php');
     foreach ($registeredComponents as $component) {
         $extensions = implode('|', $allowedExtensions);
         if (preg_match("/({$extensions})\$/i", $fileFragment)) {
             foreach ($component as $type => $chunk) {
                 if ($fileType != $type) {
                     continue;
                 }
                 $path = ROOT . DS . Configure::read('App.webroot') . DS . $chunk . DS;
                 if (Configure::read('debug') == false && !strpos($fileFragment, 'min')) {
                     $fileFragment = preg_replace("/(css|js)\$/i", "min.\$1", $fileFragment);
                 }
                 if (file_exists($path . $fileFragment)) {
                     return $path . $fileFragment;
                 }
             }
         }
     }
 }
Beispiel #5
0
 /**
  * Tear down method.
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Plugin::unload('Union/Core');
     Plugin::unload('TestPlugin');
     unset($this->Controller, $this->App);
 }
Beispiel #6
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Configure::delete('Asset');
     Plugin::unload();
     unset($this->Helper, $this->View);
 }
 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Plugin::unload();
     DispatcherFactory::clear();
     $this->Case->controller = null;
 }
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     $_SESSION = array();
     unset($this->View, $this->Session);
     Plugin::unload();
     parent::tearDown();
 }
Beispiel #9
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     unset($this->Task);
     TableRegistry::clear();
     parent::tearDown();
     Plugin::unload('ControllerTest');
 }
Beispiel #10
0
 /**
  * Tear down method.
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Plugin::unload('Union/Core');
     Plugin::unload('TestPlugin');
     unset($this->ToolBar, $this->View);
 }
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->shell);
     Plugin::unload();
     $bootstrap = new File($this->bootstrap, false);
     $bootstrap->write($this->originalBootstrapContent);
 }
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->Task);
     $Folder = new Folder($this->path);
     $Folder->delete();
     Plugin::unload();
 }
Beispiel #13
0
 /**
  * Tear down method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     I18n::clear();
     I18n::defaultFormatter('default');
     I18n::locale($this->locale);
     Plugin::unload();
     Cache::clear(false, '_cake_core_');
 }
 public function tearDown()
 {
     parent::tearDown();
     Plugin::unload('ThemeInstallerTest');
     $testPluginFolder = new Folder(ROOT . DS . 'plugins' . DS . 'ThemeInstallerTest');
     $testPluginFolder->delete();
     $testPluginConfigFolder = new Folder(ROOT . DS . 'config' . DS . 'Plugins' . DS . 'ThemeInstallerTest');
     $testPluginConfigFolder->delete();
     $webrootThemeFolder = new Folder(WWW_ROOT . 'theme' . DS . 'ThemeInstallerTest');
     $webrootThemeFolder->delete();
 }
Beispiel #15
0
 /**
  * test loading a plugin helper.
  *
  * @return void
  */
 public function testLoadPluginTask()
 {
     $dispatcher = $this->getMockBuilder('Cake\\Console\\ShellDispatcher')->disableOriginalConstructor()->getMock();
     $shell = $this->getMockBuilder('Cake\\Console\\Shell')->disableOriginalConstructor()->getMock();
     Plugin::load('TestPlugin');
     $this->Tasks = new TaskRegistry($shell, $dispatcher);
     $result = $this->Tasks->load('TestPlugin.OtherTask');
     $this->assertInstanceOf('TestPlugin\\Shell\\Task\\OtherTaskTask', $result, 'Task class is wrong.');
     $this->assertInstanceOf('TestPlugin\\Shell\\Task\\OtherTaskTask', $this->Tasks->OtherTask, 'Class is wrong');
     Plugin::unload();
 }
 /**
  * test loading a plugin helper.
  *
  * @return void
  */
 public function testLoadPluginTask()
 {
     $dispatcher = $this->getMock('Cake\\Console\\ShellDispatcher', array(), array(), '', false);
     $shell = $this->getMock('Cake\\Console\\Shell', array(), array(), '', false);
     Plugin::load('TestPlugin');
     $this->Tasks = new TaskRegistry($shell, $dispatcher);
     $result = $this->Tasks->load('TestPlugin.OtherTask');
     $this->assertInstanceOf('TestPlugin\\Console\\Command\\Task\\OtherTaskTask', $result, 'Task class is wrong.');
     $this->assertInstanceOf('TestPlugin\\Console\\Command\\Task\\OtherTaskTask', $this->Tasks->OtherTask, 'Class is wrong');
     Plugin::unload();
 }
Beispiel #17
0
 /**
  * Tests unloading plugins
  *
  * @return void
  */
 public function testUnload()
 {
     Plugin::load('TestPlugin');
     $expected = ['TestPlugin'];
     $this->assertEquals($expected, Plugin::loaded());
     Plugin::unload('TestPlugin');
     $this->assertEquals([], Plugin::loaded());
     Plugin::load('TestPlugin');
     $expected = ['TestPlugin'];
     $this->assertEquals($expected, Plugin::loaded());
     Plugin::unload('TestFakePlugin');
     $this->assertEquals($expected, Plugin::loaded());
 }
Beispiel #18
0
 /**
  * test configuring CacheEngines in App/libs
  *
  * @return void
  */
 public function testConfigWithLibAndPluginEngines()
 {
     Configure::write('App.namespace', 'TestApp');
     Plugin::load('TestPlugin');
     $config = ['engine' => 'TestAppCache', 'path' => TMP, 'prefix' => 'cake_test_'];
     Cache::config('libEngine', $config);
     $engine = Cache::engine('libEngine');
     $this->assertInstanceOf('\\TestApp\\Cache\\Engine\\TestAppCacheEngine', $engine);
     $config = ['engine' => 'TestPlugin.TestPluginCache', 'path' => TMP, 'prefix' => 'cake_test_'];
     $result = Cache::config('pluginLibEngine', $config);
     $engine = Cache::engine('pluginLibEngine');
     $this->assertInstanceOf('\\TestPlugin\\Cache\\Engine\\TestPluginCacheEngine', $engine);
     Cache::drop('libEngine');
     Cache::drop('pluginLibEngine');
     Plugin::unload();
 }
Beispiel #19
0
 /**
  * test importing loggers from app/libs and plugins.
  *
  * @return void
  */
 public function testImportingLoggers()
 {
     Configure::write('App.namespace', 'TestApp');
     Plugin::load('TestPlugin');
     Log::config('libtest', ['engine' => 'TestApp']);
     Log::config('plugintest', ['engine' => 'TestPlugin.TestPlugin']);
     $result = Log::engine('libtest');
     $this->assertInstanceOf('TestApp\\Log\\Engine\\TestAppLog', $result);
     $this->assertContains('libtest', Log::configured());
     $result = Log::engine('plugintest');
     $this->assertInstanceOf('TestPlugin\\Log\\Engine\\TestPluginLog', $result);
     $this->assertContains('libtest', Log::configured());
     $this->assertContains('plugintest', Log::configured());
     Log::write(LOG_INFO, 'TestPluginLog is not a BaseLog descendant');
     Plugin::unload();
 }
Beispiel #20
0
 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Plugin::unload();
 }
Beispiel #21
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->Task);
     Plugin::unload();
 }
 /**
  * Test getPath with plugins.
  *
  * @return void
  */
 public function testGetPathPlugin()
 {
     $this->Task->controllerName = 'Posts';
     $pluginPath = APP . 'Plugin/TestTemplate/';
     Plugin::load('TestTemplate', ['path' => $pluginPath]);
     $this->Task->params['plugin'] = $this->Task->plugin = 'TestTemplate';
     $result = $this->Task->getPath();
     $this->assertPathEquals($pluginPath . 'src/Template/Posts/', $result);
     $this->Task->params['prefix'] = 'admin';
     $result = $this->Task->getPath();
     $this->assertPathEquals($pluginPath . 'src/Template/Admin/Posts/', $result);
     Plugin::unload('TestTemplate');
 }
Beispiel #23
0
 /**
  * test using custom route class in PluginDot notation
  *
  * @return void
  */
 public function testUsingCustomRouteClassPluginDotSyntax()
 {
     Plugin::load('TestPlugin');
     Router::connect('/:slug', array('controller' => 'posts', 'action' => 'view'), array('routeClass' => 'TestPlugin.TestRoute', 'slug' => '[a-z_-]+'));
     $this->assertTrue(true);
     // Just to make sure the connect do not throw exception
     Plugin::unload('TestPlugin');
 }
Beispiel #24
0
 /**
  * Test reading from plugins.
  *
  * @return void
  */
 public function testReadPluginValue()
 {
     Plugin::load('TestPlugin');
     $engine = new PhpConfig($this->path);
     $result = $engine->read('TestPlugin.load');
     $this->assertTrue(isset($result['plugin_load']));
     Plugin::unload();
 }
 /**
  * Test reading from plugins.
  *
  * @return void
  */
 public function testReadPluginValue()
 {
     Plugin::load('TestPlugin');
     $engine = new IniConfig($this->path);
     $result = $engine->read('TestPlugin.nested');
     $this->assertTrue(isset($result['database']['db']['username']));
     $this->assertEquals('bar', $result['database']['db']['username']);
     $this->assertFalse(isset($result['database.db.username']));
     $this->assertFalse(isset($result['database']['db.username']));
     $result = $engine->read('TestPlugin.nested');
     $this->assertEquals('foo', $result['database']['db']['password']);
     Plugin::unload();
 }
Beispiel #26
0
 /**
  * Tests that aco sync works correctly with nested plugins
  *
  * @return void
  */
 public function testSyncWithNestedPlugin()
 {
     Plugin::unload();
     Plugin::load('Nested/TestPluginTwo');
     $this->_clean();
     $this->Task->expects($this->atLeast(2))->method('getControllerList')->will($this->returnCallback(function ($plugin, $prefix) {
         if ($prefix !== null) {
             return [];
         }
         switch ($plugin) {
             case 'Nested/TestPluginTwo':
                 return ['PluginTwoController.php'];
             default:
                 return ['CommentsController.php', 'PostsController.php', 'BigLongNamesController.php'];
         }
     }));
     $this->Task->startup();
     $this->Task->acoUpdate();
     $Aco = $this->Task->Acl->Aco;
     $originalNode = $Aco->node('controllers/Nested\\TestPluginTwo/PluginTwo')->first();
     $cleanTask = $this->getMock('Acl\\AclExtras', ['in', 'out', 'hr', 'createFile', 'error', 'err', 'clear', 'getControllerList']);
     $cleanTask->expects($this->atLeast(2))->method('getControllerList')->will($this->returnCallback(function ($plugin, $prefix) {
         if ($prefix !== null) {
             return [];
         }
         switch ($plugin) {
             case 'Nested/TestPluginTwo':
                 return ['PluginTwoController.php'];
             default:
                 return ['CommentsController.php', 'PostsController.php', 'BigLongNamesController.php'];
         }
     }));
     $cleanTask->startup();
     $cleanTask->acoSync();
     $updatedNode = $Aco->node('controllers/Nested\\TestPluginTwo/PluginTwo')->first();
     $this->assertSame($originalNode->id, $updatedNode->id);
 }
 /**
  * test engine override
  */
 public function testEngineOverride()
 {
     $Number = new NumberHelperTestObject($this->View, ['engine' => 'TestAppEngine']);
     $this->assertInstanceOf('TestApp\\Utility\\TestAppEngine', $Number->engine());
     Plugin::load('TestPlugin');
     $Number = new NumberHelperTestObject($this->View, ['engine' => 'TestPlugin.TestPluginEngine']);
     $this->assertInstanceOf('TestPlugin\\Utility\\TestPluginEngine', $Number->engine());
     Plugin::unload('TestPlugin');
 }
Beispiel #28
0
 /**
  * testLoad method
  *
  * @return void
  */
 public function testLoadPlugin()
 {
     Configure::config('test', new PhpConfig());
     Plugin::load('TestPlugin');
     $result = Configure::load('TestPlugin.load', 'test');
     $this->assertTrue($result);
     $expected = '/test_app/Plugin/TestPlugin/Config/load.php';
     $config = Configure::read('plugin_load');
     $this->assertEquals($expected, $config);
     $result = Configure::load('TestPlugin.more.load', 'test');
     $this->assertTrue($result);
     $expected = '/test_app/Plugin/TestPlugin/Config/more.load.php';
     $config = Configure::read('plugin_more_load');
     $this->assertEquals($expected, $config);
     Plugin::unload();
 }
Beispiel #29
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Plugin::unload();
     unset($this->View);
     unset($this->PostsController);
     unset($this->Controller);
     unset($this->ThemeView);
     unset($this->ThemePostsController);
     unset($this->ThemeController);
 }
 /**
  * test that plugin scripts added with uses() are only ever included once.
  * test script tag generation with plugin syntax
  *
  * @return void
  */
 public function testPluginScript()
 {
     Plugin::load('TestPlugin');
     $result = $this->Html->script('TestPlugin.foo');
     $expected = array('script' => array('src' => 'test_plugin/js/foo.js'));
     $this->assertTags($result, $expected);
     $result = $this->Html->script(array('TestPlugin.foobar', 'TestPlugin.bar'));
     $expected = array(array('script' => array('src' => 'test_plugin/js/foobar.js')), '/script', array('script' => array('src' => 'test_plugin/js/bar.js')), '/script');
     $this->assertTags($result, $expected);
     $result = $this->Html->script('TestPlugin.jquery-1.3');
     $expected = array('script' => array('src' => 'test_plugin/js/jquery-1.3.js'));
     $this->assertTags($result, $expected);
     $result = $this->Html->script('TestPlugin.test.json');
     $expected = array('script' => array('src' => 'test_plugin/js/test.json.js'));
     $this->assertTags($result, $expected);
     $result = $this->Html->script('TestPlugin./jquery-1.3.2.js?someparam=foo');
     $expected = array('script' => array('src' => 'test_plugin/jquery-1.3.2.js?someparam=foo'));
     $this->assertTags($result, $expected);
     $result = $this->Html->script('TestPlugin.test.json.js?foo=bar');
     $expected = array('script' => array('src' => 'test_plugin/js/test.json.js?foo=bar'));
     $this->assertTags($result, $expected);
     $result = $this->Html->script('TestPlugin.foo');
     $this->assertNull($result, 'Script returned upon duplicate inclusion %s');
     $result = $this->Html->script(array('TestPlugin.foo', 'TestPlugin.bar', 'TestPlugin.baz'));
     $this->assertNotRegExp('/test_plugin\\/js\\/foo.js/', $result);
     $result = $this->Html->script('TestPlugin.foo', array('once' => false));
     $this->assertNotNull($result);
     $result = $this->Html->script('TestPlugin.jquery-1.3.2', array('defer' => true, 'encoding' => 'utf-8'));
     $expected = array('script' => array('src' => 'test_plugin/js/jquery-1.3.2.js', 'defer' => 'defer', 'encoding' => 'utf-8'));
     $this->assertTags($result, $expected);
     Plugin::unload('TestPlugin');
 }