/** * __construct * @param string|string[] $config fully qualified name of configuration file * or configuration array * @throws Exception */ private final function __construct($config) { if (!class_exists('XoopsLoad', false)) { include __DIR__ . '/xoopsload.php'; } if (is_string($config)) { $yamlString = file_get_contents($config); if ($yamlString === false) { throw new \Exception('XoopsBaseConfig failed to load configuration.'); } $loaderPath = $this->extractLibPath($yamlString) . '/vendor/autoload.php'; if (file_exists($loaderPath)) { include_once $loaderPath; } self::$configs = Yaml::loadWrapped($yamlString); \XoopsLoad::startAutoloader(self::$configs['lib-path']); } elseif (is_array($config)) { self::$configs = $config; \XoopsLoad::startAutoloader(self::$configs['lib-path']); } if (!isset(self::$configs['lib-path'])) { throw new \Exception('XoopsBaseConfig lib-path not defined.'); return; } \XoopsLoad::startAutoloader(self::$configs['lib-path']); }
/** * @covers Xoops\Core\Yaml::dumpWrapped * @covers Xoops\Core\Yaml::loadWrapped */ public function testDumpAndLoadWrapped() { $inputArray = array('one' => 1, 'two' => array(1, 2), 'three' => ''); $string = Yaml::dumpWrapped($inputArray); $this->assertTrue(!empty($string)); $this->assertTrue(is_string($string)); $outputArray = Yaml::loadWrapped((string) $string); $this->assertTrue(is_array($outputArray)); $this->assertSame($inputArray, $outputArray); }