/**
  * Test loading templates files from a plugin
  *
  * @return void
  */
 public function testAddPluginWidgetsFromConfigInConstuctor()
 {
     Plugin::load('TestPlugin');
     $widgets = ['text' => ['Cake\\View\\Widget\\BasicWidget'], 'TestPlugin.test_widgets'];
     $inputs = new WidgetRegistry($this->templates, $this->view, $widgets);
     $this->assertInstanceOf('Cake\\View\\Widget\\LabelWidget', $inputs->get('text'));
 }
 /**
  * reset environment.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('App.namespace', 'TestApp');
     Plugin::load(array('TestPlugin', 'TestPluginTwo'));
     $this->Case = $this->getMockForAbstractClass('Cake\\TestSuite\\ControllerTestCase');
     $this->Case->loadRoutes = false;
     DispatcherFactory::add('Routing');
     DispatcherFactory::add('ControllerFactory');
     Router::scope('/', function ($routes) {
         $routes->fallbacks();
     });
     Router::prefix('admin', function ($routes) {
         $routes->plugin('TestPlugin', function ($routes) {
             $routes->fallbacks();
         });
         $routes->fallbacks();
     });
     Router::plugin('TestPlugin', function ($routes) {
         $routes->fallbacks();
     });
     Router::plugin('TestPluginTwo', function ($routes) {
         $routes->fallbacks();
     });
     TableRegistry::clear();
 }
 /**
  * Test config() method with plugin syntax aliases
  *
  * @return void
  */
 public function testConfigPlugin()
 {
     Plugin::load('TestPlugin');
     $data = ['connection' => 'testing', 'entityClass' => 'TestPlugin\\Model\\Entity\\Comment'];
     $result = $this->_locator->config('TestPlugin.TestPluginComments', $data);
     $this->assertEquals($data, $result, 'Returns config data.');
 }
Exemple #4
0
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Plugin::load('TestPlugin', ['autoload' => true]);
     Plugin::load('Union/Core', ['path' => ROOT, 'routes' => true, 'bootstrap' => true]);
     $this->View = $this->getMock('Union\\Core\\View\\AppView', ['append']);
 }
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Plugin::load('TestPlugin');
     Configure::write('App.namespace', 'TestApp');
     $this->dispatcher = $this->getMockBuilder('Cake\\Console\\ShellDispatcher')->setMethods(['_stop'])->getMock();
 }
Exemple #6
0
 /**
  * @param $plugins
  * @param $options
  *
  * @throws \makallio85\YamlRoute\Exception\PluginException
  */
 public function load($plugins, $options)
 {
     $routes = isset($options['routes']) && $options['routes'] === true ? true : false;
     $options['routes'] = false;
     CakePlugin::load($plugins, $options);
     if ($routes) {
         if (!is_array($plugins)) {
             $plugins = [$plugins];
         }
         foreach ($plugins as $plugin) {
             if ($this->isLoaded($plugin)) {
                 throw new Exception\PluginException("Plugin {$plugin} is loaded already and should not be loaded twice.");
             }
             $path = Configure::read('plugins')[$plugin] . DS . 'config' . DS . 'routes.yml';
             if (!file_exists($path)) {
                 throw new Exception\PluginException("Yaml route configuration file not found in path {$path}.");
             }
             $route = Yaml::parse(file_get_contents($path));
             $data = ['name' => $plugin, 'route' => $route, 'file' => $path];
             $this->_addLoaded($plugin, $data);
             $data['route'] = $this->_loadRouteConfigs($route);
             Validator::run($data);
             $this->_updateLoaded($plugin, $data);
         }
     }
 }
Exemple #7
0
 public static function load($name)
 {
     $path = THREEPLUGINS . $name;
     if (file_exists($path . DS . 'plugin.ini')) {
         $basename = basename($path);
         $config = (new IniReader())->readFile($path . DS . 'plugin.ini')->toArray();
         if (array_key_exists('enabled', $config) && $config['enabled'] === true) {
             if (\Cake\Core\Plugin::loaded('ThreePlugins/' . $basename) === true) {
                 return true;
             }
             if (array_key_exists('depend', $config)) {
                 if (is_array($config['depend'])) {
                     foreach ($config['depend'] as $v) {
                         if (!\Cake\Core\Plugin::loaded($v) && self::load($v) !== true) {
                             throw new MissingDependencyException('Missing dependency ' . $v . ' for plugin ' . $name);
                         }
                     }
                 } else {
                     if (!\Cake\Core\Plugin::loaded($config['depend']) && self::load($config['depend']) !== true) {
                         throw new MissingDependencyException('Missing dependency ' . $config['depend'] . ' for plugin ' . $name);
                     }
                 }
             }
             \Cake\Core\Plugin::load('ThreePlugins/' . $basename, ['autoload' => true, 'bootstrap' => array_key_exists('bootstrap', $config) ? $config['bootstrap'] : false, 'routes' => array_key_exists('routes', $config) ? $config['routes'] : false]);
             $class = '\\ThreePlugins\\' . $basename . '\\' . $basename . 'Plugin';
             if (!class_exists($class)) {
                 throw new FileNotFoundException('Missing class ' . $class . ' into the plugin ' . $name);
             }
             (new $class())->initialize();
             return true;
         }
     }
     return false;
 }
Exemple #8
0
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Plugin::load('Union/Core', ['path' => ROOT, 'routes' => true, 'bootstrap' => true]);
     $this->View = new AppView();
     $this->Document = new DocumentHelper($this->View);
 }
 /**
  * Test the main with plugin.name method.
  *
  * @return void
  */
 public function testMainWithPlugin()
 {
     Plugin::load('SimpleBakeTest', ['path' => APP . 'Plugin' . DS . 'SimpleBakeTest' . DS]);
     $filename = $this->_normalizePath(APP . 'Plugin/SimpleBakeTest/src/Model/Behavior/ExampleBehavior.php');
     $this->Task->expects($this->once())->method('createFile')->with($filename, $this->stringContains('class ExampleBehavior extends Behavior'));
     $this->Task->Test->expects($this->once())->method('bake')->with('behavior', 'Example');
     $this->Task->main('SimpleBakeTest.Example');
 }
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     Plugin::load('TestPlugin', ['autoload' => true]);
     Router::plugin('TestPlugin', function ($routes) {
         $routes->fallbacks('DashedRoute');
     });
     Plugin::load('Union/Core', ['path' => ROOT, 'routes' => true, 'bootstrap' => true]);
 }
Exemple #11
0
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Plugin::load('Union/Core', ['path' => ROOT, 'routes' => true, 'bootstrap' => true]);
     $padding = ['Pages' => ['page' => 1, 'current' => 4, 'count' => 4, 'perPage' => 30, 'limit' => null, 'finder' => 'all', 'prevPage' => false, 'nextPage' => false, 'pageCount' => false, 'directionDefault' => 'DESC', 'direction' => 'DESC', 'sort' => 'Pages.id', 'sortDefault' => 'Pages.id']];
     $this->ViewAdmin = new AppView(new Request(['params' => ['pass' => [], 'prefix' => 'admin', 'paging' => $padding]]));
     $this->View = new AppView(new Request(['params' => ['pass' => [], 'paging' => $padding]]));
 }
Exemple #12
0
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Plugin::load('Union/Core', ['path' => ROOT, 'routes' => true, 'bootstrap' => true]);
     $this->View = $this->getMock('Union\\Core\\View\\AppView', ['append']);
     $this->Nav = new NavHelper($this->View);
     Nav::add('test_menu', 'dashboard', ['title' => __d('union', 'Dashboard'), 'weight' => 0, 'icon' => 'dashboard', 'url' => 'link', 'children' => ['link-1' => ['title' => __d('union', 'Children 1'), 'weight' => 0, 'url' => 'link-2']]]);
     Nav::add('test_menu_2', 'dashboard', ['title' => __d('union', 'Dashboard'), 'weight' => 0, 'class' => 'customClass', 'liClass' => 'customLiClass', 'icon' => 'dashboard', 'url' => 'link', 'children' => ['link-1' => ['title' => __d('union', 'Children 1'), 'weight' => 0, 'url' => 'link-2']]]);
 }
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Plugin::load(['TestPlugin', 'TestPluginTwo']);
     $this->out = new TestStringOutput();
     $io = new ConsoleIo($this->out);
     $this->Shell = $this->getMock('Cake\\Shell\\CommandListShell', ['in', 'err', '_stop', 'clear'], [$io]);
     $this->Shell->Command = $this->getMock('Cake\\Shell\\Task\\CommandTask', ['in', '_stop', 'err', 'clear'], [$io]);
 }
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Plugin::load(['TestPlugin', 'TestPluginTwo']);
     $this->out = new ConsoleOutput();
     $io = new ConsoleIo($this->out);
     $this->Shell = $this->getMockBuilder('Cake\\Shell\\CommandListShell')->setMethods(['in', 'err', '_stop', 'clear'])->setConstructorArgs([$io])->getMock();
     $this->Shell->Command = $this->getMockBuilder('Cake\\Shell\\Task\\CommandTask')->setMethods(['in', '_stop', 'err', 'clear'])->setConstructorArgs([$io])->getMock();
 }
Exemple #15
0
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('App.namespace', 'TestApp');
     Plugin::load(['TestPlugin', 'TestTheme']);
     $request = $this->getMock('Cake\\Network\\Request');
     $response = $this->getMock('Cake\\Network\\Response');
     $this->View = new \Cake\View\View($request, $response);
 }
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Plugin::load(array('TestPlugin', 'TestPluginTwo'));
     $this->out = new TestCompletionStringOutput();
     $io = new ConsoleIo($this->out);
     $this->Shell = $this->getMock('Cake\\Console\\Command\\CompletionShell', ['in', '_stop', 'clear'], [$io]);
     $this->Shell->Command = $this->getMock('Cake\\Console\\Command\\Task\\CommandTask', ['in', '_stop', 'clear'], [$io]);
 }
 /**
  * reset environment.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('App.namespace', 'TestApp');
     Plugin::load(array('TestPlugin', 'TestPluginTwo'));
     $this->Case = $this->getMockForAbstractClass('Cake\\TestSuite\\ControllerTestCase');
     Router::reload();
     TableRegistry::clear();
 }
Exemple #18
0
 /**
  * Register all available themes in the composer classloader and load them as plugin.
  *
  * @return void
  */
 public static function loadThemes()
 {
     $themesFolder = new Folder(ROOT . DS . 'themes');
     $themes = $themesFolder->read()[0];
     $loader = (require ROOT . DS . 'vendor' . DS . 'autoload.php');
     foreach ($themes as $theme) {
         $loader->addPsr4('WasabiTheme\\' . $theme . '\\', [$themesFolder->path . DS . $theme . DS . 'src']);
         Plugin::load('WasabiTheme/' . $theme, ['path' => $themesFolder->path . DS . $theme . DS, 'bootstrap' => true, 'routes' => false]);
     }
 }
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('App.namespace', 'TestApp');
     Plugin::load(['TestPlugin', 'TestPluginTwo']);
     $this->out = new TestCompletionStringOutput();
     $io = new ConsoleIo($this->out);
     $this->Shell = $this->getMockBuilder('Cake\\Shell\\CompletionShell')->setMethods(['in', '_stop', 'clear'])->setConstructorArgs([$io])->getMock();
     $this->Shell->Command = $this->getMockBuilder('Cake\\Shell\\Task\\CommandTask')->setMethods(['in', '_stop', 'clear'])->setConstructorArgs([$io])->getMock();
 }
 /**
  * Test loading app fixtures.
  *
  * @return void
  */
 public function testFixturizePlugin()
 {
     Plugin::load('TestPlugin');
     $test = $this->getMock('Cake\\TestSuite\\TestCase');
     $test->fixtures = ['plugin.test_plugin.articles'];
     $this->manager->fixturize($test);
     $fixtures = $this->manager->loaded();
     $this->assertCount(1, $fixtures);
     $this->assertArrayHasKey('plugin.test_plugin.articles', $fixtures);
     $this->assertInstanceOf('TestPlugin\\Test\\Fixture\\ArticlesFixture', $fixtures['plugin.test_plugin.articles']);
 }
Exemple #21
0
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Plugin::load('TestPlugin', ['autoload' => true]);
     Router::plugin('TestPlugin', function ($routes) {
         $routes->fallbacks('DashedRoute');
     });
     $this->Controller = new AppController(new Request(['session' => new Session()]));
     $componentRegistry = new ComponentRegistry($this->Controller);
     $this->App = new AppComponent($componentRegistry);
 }
 /**
  * test passwordhasher instance building
  *
  * @return void
  */
 public function testBuild()
 {
     $hasher = PasswordHasherFactory::build('Default');
     $this->assertInstanceof('Cake\\Auth\\DefaultPasswordHasher', $hasher);
     $hasher = PasswordHasherFactory::build(['className' => 'Default', 'hashOptions' => ['foo' => 'bar']]);
     $this->assertInstanceof('Cake\\Auth\\DefaultPasswordHasher', $hasher);
     $this->assertEquals(['foo' => 'bar'], $hasher->config('hashOptions'));
     Plugin::load('TestPlugin');
     $hasher = PasswordHasherFactory::build('TestPlugin.Legacy');
     $this->assertInstanceof('TestPlugin\\Auth\\LegacyPasswordHasher', $hasher);
 }
Exemple #23
0
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Plugin::load('Union/Core', ['path' => ROOT, 'routes' => true, 'bootstrap' => true]);
     Plugin::load('TestPlugin');
     Router::plugin('TestPlugin', function ($routes) {
         $routes->fallbacks('DashedRoute');
     });
     $this->View = $this->getMock('Union\\Core\\View\\AppView', ['append']);
     $this->Button = new ButtonHelper($this->View);
 }
Exemple #24
0
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Plugin::load('Union/Core', ['path' => ROOT, 'routes' => true, 'bootstrap' => true]);
     Plugin::load('TestPlugin');
     Router::plugin('TestPlugin', function ($routes) {
         $routes->fallbacks('DashedRoute');
     });
     $this->View = new AppView();
     $this->Form = new FormHelper($this->View, ['widgets' => ['_default' => 'Union\\Core\\View\\Widget\\BasicWidget', 'button' => 'Union\\Core\\View\\Widget\\ButtonWidget', 'textarea' => 'Union\\Core\\View\\Widget\\TextAreaWidget'], 'templates' => 'Union/Core.templates/form']);
 }
Exemple #25
0
 /**
  * Loads a plugin and optionally loads bootstrapping and routing files.
  *
  * This method is identical to CakePlugin::load() with extra functionality
  * that loads event configuration when Plugin/Config/events.php is present.
  *
  * @see CakePlugin::load()
  * @param mixed $plugin name of plugin, or array of plugin and its config
  * @return void
  */
 public static function load($plugin, $config = [])
 {
     Plugin::load($plugin, $config);
     if (is_string($plugin)) {
         $plugin = [$plugin => $config];
     }
     Cache::delete('EventHandlers', 'default');
     foreach ($plugin as $name => $conf) {
         list($name, $conf) = is_numeric($name) ? [$conf, $config] : [$name, $conf];
         Hook::applyHookConfigFiles('Hook.config_files', $name);
     }
 }
 public function testIfThemeFilesWereInstalled()
 {
     Plugin::load('ThemeInstallerTest', ['routes' => false, 'bootstrap' => false]);
     $starter = new PluginStarter();
     $starter->load('ThemeInstallerTest');
     $themeInstaller = new ThemeInstaller();
     $themeInstaller->installTheme('ThemeInstallerTest');
     $this->assertEquals(true, file_exists(WWW_ROOT . 'theme' . DS . 'ThemeInstallerTest' . DS . 'css' . DS . 'sample.css'));
     $this->assertEquals(true, file_exists(WWW_ROOT . 'theme' . DS . 'ThemeInstallerTest' . DS . 'js' . DS . 'sample.js'));
     $this->assertEquals(true, file_exists(WWW_ROOT . 'theme' . DS . 'ThemeInstallerTest' . DS . 'packages' . DS . 'sample_package' . DS . 'sample.css'));
     $this->assertEquals(true, file_exists(WWW_ROOT . 'theme' . DS . 'ThemeInstallerTest' . DS . 'packages' . DS . 'sample_package' . DS . 'sample.js'));
 }
Exemple #27
0
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Plugin::load('Union/Core', ['path' => ROOT, 'routes' => true, 'bootstrap' => true]);
     Plugin::load('TestPlugin');
     Router::plugin('TestPlugin', function ($routes) {
         $routes->fallbacks('DashedRoute');
     });
     $Request = new Request(['params' => ['plugin' => 'TestPlugin', 'controller' => 'Event', 'action' => 'view', 'pass' => []]]);
     $this->View = new AppView($Request);
     $this->ToolBar = new ToolBarHelper($this->View);
 }
Exemple #28
0
 /**
  * Test baking within a plugin.
  *
  * @return void
  */
 public function testBakePlugin()
 {
     Plugin::load('TestPlugin');
     $path = Plugin::path('TestPlugin');
     $this->Task->plugin = 'TestPlugin';
     $this->Task->expects($this->at(0))->method('createFile')->with($this->_normalizePath($path . 'src/Template/Cell/Example/display.ctp'), '');
     $this->Task->expects($this->at(1))->method('createFile')->with($this->_normalizePath($path . 'src/View/Cell/ExampleCell.php'), $this->stringContains('class ExampleCell extends Cell'));
     $result = $this->Task->bake('Example');
     $this->assertContains('namespace TestPlugin\\View\\Cell;', $result);
     $this->assertContains('use Cake\\View\\Cell;', $result);
     $this->assertContains('class ExampleCell extends Cell {', $result);
 }
 /**
  * Cria um plugin de teste e o carrega para conseguir rodar os testes.
  */
 public function setUp()
 {
     parent::setUp();
     $testPluginData = ['full_path' => ROOT . DS . 'plugins' . DS . 'PluginInstallerTest' . DS, 'config_folder' => ROOT . DS . 'plugins' . DS . 'PluginInstallerTest' . DS . 'config' . DS];
     $pluginFolder = new Folder($testPluginData['full_path'], self::CREATE_FOLDER_IF_NOT_EXISTS, self::PLUGIN_FOLDER_PERMISSIONS);
     $pluginFolder->create('config');
     $defaultSettingsFile = new File($testPluginData['config_folder'] . 'default_settings.php', true);
     $defaultSettingsFile->write("<?php \n\t\t\treturn [\n\t\t\t\t'MyApplication.Modules.PluginInstallerTest.Settings' => \n\t\t\t\t\t['Default' => true]\n\t\t\t\t]; \n\t\t?>");
     $defaultSettingsFile->close();
     $bootstrapFile = new File($testPluginData['config_folder'] . 'bootstrap.php', true);
     $bootstrapFile->close();
     Plugin::load('PluginInstallerTest', ['routes' => false, 'bootstrap' => false]);
 }
 /**
  * Setup test data.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Plugin::load('Union/Core', ['path' => ROOT, 'routes' => true, 'bootstrap' => true]);
     Plugin::load('TestPlugin', ['autoload' => true]);
     Router::plugin('TestPlugin', function ($routes) {
         $routes->fallbacks('DashedRoute');
     });
     Router::plugin('TestPlugin', ['path' => '/'], function (RouteBuilder $routeBuilder) {
         $routeBuilder->prefix('admin', function (RouteBuilder $routeBuilder) {
             $routeBuilder->connect('/:plugin/:controller/:action/*', []);
         });
     });
 }