/** * @covers Xoops\Core\Text\Sanitizer\DefaultConfiguration::buildDefaultConfiguration * @covers Xoops\Core\Text\Sanitizer\DefaultConfiguration::registerComponent * @covers Xoops\Core\Text\Sanitizer\SanitizerComponent::getDefaultConfig */ public function testBuildDefaultConfiguration() { $defaultConfig = $this->object->buildDefaultConfiguration(); $this->assertTrue(is_array($defaultConfig)); $this->assertArrayHasKey('sanitizer', $defaultConfig); $this->assertArrayHasKey('xoopscode', $defaultConfig); }
/** * Tests a user configured temporary directory */ public function testSetConfiguredTempDirectory() { $directory = "/root"; $configuration = new DefaultConfiguration(); $configuration->setTempDirectory($directory); $fileUtil = new FileUtil($configuration); $this->assertEquals($directory, $fileUtil->getTempDirectory()); }
/** * Used to initialize the application * * Initializes objects needed by the application * Sets application configuration * * @since 1.0.0 * @throws object Exception an exception is thrown if the plugin name was not given in the user configuration * @throws object Excepton an exception is thrown if the plugin version was not given in user configuration */ protected function Initialize() { /** The configuration object for the current object is set */ $this->SetConfigurationObject($this); /** User configuration settings are merged with default configuration settings */ $default_configuration = new DefaultConfiguration(); /** The default configuration is merged with user configuration and the result is returned */ $this->configuration = $default_configuration->GetUpdatedConfiguration($this->user_configuration); /** The application authentication and error handling is enabled */ $this->EnableAuthenticationAndErrorHandling(); /** All required classes are included */ $this->IncludeRequiredClasses(); /** Php Sessions are enabled if user requested sessions */ $this->EnableSessions(); /** The function to call after the plugin is loaded is registered. It loads the translation information */ $this->GetComponent("application")->WP_AddAction('plugins_loaded', $this->GetComponent("application"), 'WP_LoadPluginTextDomain'); /** The css files for admin pages are registered */ $this->GetComponent("application")->WP_AddAction('admin_enqueue_scripts', $this->GetComponent("application"), 'WP_AdminEnqueueStyles'); /** The javascript files for admin pages are registered */ $this->GetComponent("application")->WP_AddAction('admin_enqueue_scripts', $this->GetComponent("application"), 'WP_AdminEnqueueScripts'); /** The javascript files for public pages are registered */ $this->GetComponent("application")->WP_AddAction('wp_enqueue_scripts', $this->GetComponent("application"), 'WP_EnqueueScripts'); /** The css files for public pages are registered */ $this->GetComponent("application")->WP_AddAction('wp_enqueue_scripts', $this->GetComponent("application"), 'WP_EnqueueStyles'); /** If the plugin should have a settings page and the admin user is logged in then the admin page is initialized and the settings page is created */ if (is_admin() && $this->GetConfig('wordpress', 'use_settings')) { $this->GetComponent("application")->WP_AddAction('admin_menu', $this->GetComponent("application"), 'WP_DisplaySettings'); $this->GetComponent("application")->WP_AddAction('admin_init', $this->GetComponent("application"), 'WP_InitAdmin'); } /** The custom actions */ $custom_actions = $this->GetConfig('wordpress', 'custom_actions'); /** The custom filters */ $custom_filters = $this->GetConfig('wordpress', 'custom_filters'); /** The custom actions and filters */ $custom_actions_filters = array("actions" => $custom_actions, "filters" => $custom_filters); /** All the custom actions and filters are registered */ foreach ($custom_actions_filters as $hook_name => $hooks) { for ($count = 0; $count < count($hooks); $count++) { /** A custom action or filter */ $custom_hook = $custom_actions_filters[$hook_name][$count]; /** The name of the custom hook */ $name = $custom_hook['name']; /** The callback of the custom hook */ $callback = $custom_hook['callback']; /** The object used in callback function is fetched */ $custom_callback = array($this->GetComponent($callback[0]), $callback[1]); /** If the custom callback is not callable then an exception is thrown */ if (!is_callable($custom_callback)) { throw new \Exception("Invalid custom callback function given. Details: " . var_export($callback, true)); } /** If the current hook type is action then the custom action is registered */ if ($hook_name == "actions") { /** The custom action is registered */ $this->GetComponent("application")->WP_AddAction($custom_hook['name'], $custom_callback[0], $custom_callback[1]); } else { if ($hook_name == "filters") { /** The custom filter is registered */ $this->GetComponent("application")->WP_AddFilter($custom_hook['name'], $custom_callback[0], $custom_callback[1]); } } } } }
<?php namespace malkusch\bav; require_once __DIR__ . '/../../config.php'; $configuration = new DefaultConfiguration(); $pdo = new \PDO('mysql:host=' . DB_URL . ';dbname=' . DB_NAME, DB_USERNAME, DB_PASSWD); $configuration->setDataBackendContainer(new PDODataBackendContainer($pdo)); $configuration->setUpdatePlan(new AutomaticUpdatePlan()); return $configuration;
<?php namespace malkusch\bav; $configuration = new DefaultConfiguration(); $configuration->setTempDirectory("test"); return $configuration;