/** * @covers Xoops\Core\Yaml::saveWrapped * @covers Xoops\Core\Yaml::readWrapped */ public function testSaveAndReadWrapped() { $tmpfname = tempnam(sys_get_temp_dir(), 'TEST'); $inputArray = array('one' => 1, 'two' => array(1, 2), 'three' => ''); $byteCount = Yaml::saveWrapped($inputArray, $tmpfname); $this->assertFalse($byteCount === false); $this->assertGreaterThan(0, $byteCount); $outputArray = Yaml::readWrapped($tmpfname); $this->assertTrue(is_array($outputArray)); $this->assertSame($inputArray, $outputArray); unlink($tmpfname); }
/** * Create a default configuration file, used in installation * * When using Windows NTFS, PHP has a maximum path length of 260 bytes. Each key level in a * Stash hierarchical key corresponds to a directory, and is normalized as an md5 hash. Also, * Stash uses 2 levels for its own integrity ad locking mechanisms. The full key length used * in XoopCore can reach 202 charachters. * * If the combined path length would excede 260, we will try and switch to SQLite driver if * it is available when running on a Windows system. * * @return void */ public static function createDefaultConfig() { $configFile = \XoopsBaseConfig::get('var-path') . '/configs/cache.php'; if (file_exists($configFile)) { return; } $defaults = self::getDefaults(); if (false !== stripos(PHP_OS, 'WIN')) { $pathLen = strlen($defaults['default']['options']['path']); if (260 <= $pathLen + 202) { // try alternative driver as filesystem has max path length issues on Windows if (array_key_exists("SQLite", \Stash\DriverList::getAvailableDrivers())) { $defaults['default']['driver'] = 'SQLite'; unset($defaults['default']['options']['dirSplit']); @mkdir($defaults['default']['options']['path']); } else { trigger_error("Manual cache configuration required."); } } } Yaml::saveWrapped($defaults, $configFile); }
/** * This builds a config file suitable for travis-ci.org * * @param string $configFile fully qualified path to YAML configuration file * @param string $baseDir base directory * @return integer|false */ protected function createConfigFile($configFile, $baseDir) { $url = 'http://localhost'; $configs = array('root-path' => $baseDir, 'lib-path' => $baseDir . '/xoops_lib', 'var-path' => $baseDir . '/xoops_data', 'trust-path' => $baseDir . '/xoops_lib', 'url' => $url, 'prot' => 'http://', 'asset-path' => $baseDir . '/assets', 'asset-url' => $url . '/assets', 'themes-path' => $baseDir . '/themes', 'themes-url' => $url . '/themes', 'adminthemes-path' => $baseDir . '/modules/system/themes', 'adminthemes-url' => $url . '/modules/system/themes', 'media-path' => $baseDir . '/media', 'media-url' => $url . '/media', 'uploads-path' => $baseDir . '/uploads', 'uploads-url' => $url . '/uploads', 'cookie-domain' => '', 'cookie-path' => '/', 'smarty-cache' => $baseDir . '/xoops_data/caches/smarty_cache', 'smarty-compile' => $baseDir . '/xoops_data/caches/smarty_compile', 'smarty-xoops-plugins' => $baseDir . '/xoops_lib/smarty/xoops_plugins', 'db-type' => 'pdo_mysql', 'db-charset' => 'utf8', 'db-prefix' => 'x300', 'db-host' => 'localhost', 'db-user' => 'travis', 'db-pass' => '', 'db-name' => 'xoops_test', 'db-pconnect' => 0, 'db-parameters' => array('driver' => 'pdo_mysql', 'charset' => 'utf8', 'dbname' => 'xoops_test', 'host' => 'localhost', 'user' => 'travis', 'password' => '')); Yaml::saveWrapped($configs, $configFile); }