/** * @covers Xoops\Core\Yaml::dump * @covers Xoops\Core\Yaml::load */ public function testDumpAndLoad() { $inputArray = array('one' => 1, 'two' => array(1, 2), 'three' => ''); $string = Yaml::dump($inputArray); $this->assertTrue(!empty($string)); $this->assertTrue(is_string($string)); $outputArray = Yaml::load((string) $string); $this->assertTrue(is_array($outputArray)); $this->assertSame($inputArray, $outputArray); }
// of our schema, so we can serialize it. $export = new ExportVisitor(); $newSchema->visit($export); $schemaArray = $export->getSchemaArray(); // enforce utf8mb4 for MySQL foreach ($schemaArray['tables'] as $tableName => $table) { $schemaArray['tables'][$tableName]['options']['charset'] = 'utf8mb4'; $schemaArray['tables'][$tableName]['options']['collate'] = 'utf8mb4_unicode_ci'; foreach ($table['columns'] as $column => $data) { if (array_key_exists('collation', $data)) { $schemaArray['tables'][$tableName]['columns'][$column]['collation'] = 'utf8mb4_unicode_ci'; } } } echo '<h2>' . _MI_SCHEMATOOL_EXPORT_SCHEMA . '</h2>'; $yamldump = Yaml::dump($schemaArray, 5); //echo '<div contenteditable><pre>' . $yamldump . '</pre></div>'; $schemadump = <<<EOT1 <section> <div id="container"> <div contenteditable><pre>{$yamldump}</pre></div> <input type="text" value="schema.yml" placeholder="schema.yml"> <button onclick="downloadFile()">Create file</button> <output></output> </div> </section> EOT1; $script = <<<EOT2 <script> var container = document.querySelector('#container'); var typer = container.querySelector('[contenteditable]'); var output = container.querySelector('output');
$schemaManager = $xoops->db()->getSchemaManager(); // create schema from the current database $schema = $schemaManager->createSchema(); // invoke our RemovePrefixes visitor with list of core tables $visitor = new RemovePrefixes(); $visitor->setTableFilter($table_list); $schema->visit($visitor); // Get the schema we built with the RemovePrefixes visitor. // Should be just core tables with no prefix $newSchema = $visitor->getNewSchema(); // Invoke an ExportVisitor that will build a clean array version // of our schema, so we can serialize it. $export = new ExportVisitor(); $newSchema->visit($export); echo '<h2>' . _MI_SCHEMATOOL_EXPORT_SCHEMA . '</h2>'; $yamldump = Yaml::dump($export->getSchemaArray(), 5); //echo '<div contenteditable><pre>' . $yamldump . '</pre></div>'; $schemadump = <<<EOT1 <section> <div id="container"> <div contenteditable><pre>{$yamldump}</pre></div> <input type="text" value="schema.yml" placeholder="schema.yml"> <button onclick="downloadFile()">Create file</button> <output></output> </div> </section> EOT1; $script = <<<EOT2 <script> var container = document.querySelector('#container'); var typer = container.querySelector('[contenteditable]'); var output = container.querySelector('output');