diff options
Diffstat (limited to 'srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test')
13 files changed, 2776 insertions, 0 deletions
diff --git a/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/DataTest.php b/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/DataTest.php new file mode 100644 index 0000000..c12f576 --- /dev/null +++ b/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/DataTest.php @@ -0,0 +1,74 @@ +<?php +declare(strict_types = 1); +namespace Williamdes\MariaDBMySQLKBS\Test; + +use \PHPUnit\Framework\TestCase; +use \Swaggest\JsonSchema\Schema; +use \Swaggest\JsonSchema\Context; +use \stdClass; + +class DataTest extends TestCase +{ + + /** + * Validate json data + * + * @param stdClass $contents The file contents + * @param string $id The schema id + * @example validate($slimData, "urn:williamdes:mariadb-mysql-kbs:slimdata"); + * @return bool + */ + public static function validate(stdClass $contents, string $id): bool + { + $options = new Context(); + $options->setRemoteRefProvider(new RefProvider()); + $schema = Schema::import($id, $options); + $schema->in($contents); + return true;// No exception occured + } + + /** + * test files + * + * @return void + */ + public function testFileSample(): void + { + $slimDataTestData = json_decode((string) file_get_contents(__DIR__."/data/ultraSlimDataTestWithVariables.json")); + $this->assertTrue(self::validate($slimDataTestData, "urn:williamdes:mariadb-mysql-kbs:ultraslimdata")); + } + + /** + * test slim data + * + * @return void + */ + public function testFileSlim(): void + { + $slimData = json_decode((string) file_get_contents(__DIR__."/../dist/merged-slim.json")); + $this->assertTrue(self::validate($slimData, "urn:williamdes:mariadb-mysql-kbs:slimdata")); + } + + /** + * test ultra slim data + * + * @return void + */ + public function testFileUltraSlim(): void + { + $slimData = json_decode((string) file_get_contents(__DIR__."/../dist/merged-ultraslim.json")); + $this->assertTrue(self::validate($slimData, "urn:williamdes:mariadb-mysql-kbs:ultraslimdata")); + } + + /** + * test ultra slim data + * + * @return void + */ + public function testFileRaw(): void + { + $slimData = json_decode((string) file_get_contents(__DIR__."/../dist/merged-raw.json")); + $this->assertTrue(self::validate($slimData, "urn:williamdes:mariadb-mysql-kbs:rawdata")); + } + +} diff --git a/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/RefProvider.php b/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/RefProvider.php new file mode 100644 index 0000000..50b25cc --- /dev/null +++ b/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/RefProvider.php @@ -0,0 +1,50 @@ +<?php +declare(strict_types = 1); +namespace Williamdes\MariaDBMySQLKBS\Test; + +use \Swaggest\JsonSchema\RemoteRefProvider; + +class RefProvider implements RemoteRefProvider +{ + + /** + * Preloaded urn schemas + * + * @var \stdClass[] + */ + private $urnSchemas = []; + + /** + * Create a new RefProvider instance + */ + public function __construct() + { + $files = glob(__DIR__ . "/../schemas/*.json"); + if ($files === false) { + return; + } else { + foreach ($files as $filename) { + $schema = json_decode((string) file_get_contents($filename)); + if (isset($schema) && isset($schema->{'$id'}) && $schema !== null) { + $this->urnSchemas[$schema->{'$id'}] = $schema; + } + } + } + } + + /** + * @param string $url The file url + * @return \stdClass|false json_decode of $url resource content + */ + public function getSchemaData($url) + { + if (isset($this->urnSchemas[$url])) {// Handle urn: urls + return $this->urnSchemas[$url]; + } elseif (is_file($url)) {// Handle file + return json_decode((string) file_get_contents($url)); + } else {// Handle URL + return json_decode((string) file_get_contents(rawurldecode($url))); + } + } + +} diff --git a/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/SearchTest.php b/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/SearchTest.php new file mode 100644 index 0000000..cc15ac9 --- /dev/null +++ b/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/SearchTest.php @@ -0,0 +1,178 @@ +<?php +declare(strict_types = 1); +namespace Williamdes\MariaDBMySQLKBS\Test; + +use \PHPUnit\Framework\TestCase; +use \Williamdes\MariaDBMySQLKBS\SlimData; +use \Williamdes\MariaDBMySQLKBS\Search; +use \Williamdes\MariaDBMySQLKBS\KBException; + +class SearchTest extends TestCase +{ + + /** + * Load slim data + * + * @return void + */ + public static function setUpBeforeClass(): void + { + $sd = new SlimData(); + $sd->addVariable("variable-1", "boolean", true); + $sd->addVariable("variable-2", null, null); + $sd->addVariable("variable-3", null, true); + $variable4 = $sd->addVariable("variable-4", null, false); + $variable4->addDocumentation("https://mariadb.com/testurl/for/variable/4", "myanchor"); + $variable4->addDocumentation("https://dev.mysql.com/testurl_for-variable/4", "my_anchor"); + Search::loadTestData($sd); + } + + /** + * test get by name + * + * @return void + */ + public function testGetByName(): void + { + $found = Search::getByName("variable-4"); + $this->assertEquals("https://mariadb.com/testurl/for/variable/4#myanchor", $found); + } + + /** + * test get by name for MySQL + * + * @return void + */ + public function testGetByNameMYSQL(): void + { + $found = Search::getByName("variable-4", Search::MYSQL); + $this->assertEquals("https://dev.mysql.com/testurl_for-variable/4#my_anchor", $found); + } + + /** + * test get by name for MARIADB + * + * @return void + */ + public function testGetByNameMARIADB(): void + { + $found = Search::getByName("variable-4", Search::MARIADB); + $this->assertEquals("https://mariadb.com/testurl/for/variable/4#myanchor", $found); + } + + /** + * test get by name + * + * + * @return void + */ + public function testException(): void + { + $this->expectException(KBException::class); + $this->expectExceptionCode(0); + $this->expectExceptionMessageRegExp('/(.+) does not exist for this type of documentation !/'); + Search::getByName("variable-3", Search::MARIADB); + } + + /** + * test get by name not found variable + * + * + * @return void + */ + public function testExceptionNoFoundGetVariableType(): void + { + $this->expectException(KBException::class); + $this->expectExceptionCode(0); + $this->expectExceptionMessageRegExp('/(.+) does not exist !/'); + Search::getVariableType("acbdefghi0202"); + } + + /** + * test get by name not found variable + * + * + * @return void + */ + public function testExceptionNoFound(): void + { + $this->expectException(KBException::class); + $this->expectExceptionCode(0); + $this->expectExceptionMessageRegExp('/(.+) does not exist !/'); + Search::getByName("acbdefghi0202", Search::MARIADB); + } + + /** + * test get by name not found variable + * + * + * @return void + */ + public function testExceptionNoFoundGetVariable(): void + { + $this->expectException(KBException::class); + $this->expectExceptionCode(0); + $this->expectExceptionMessageRegExp('/(.+) does not exist !/'); + Search::getVariable("acbdefghi0202"); + } + + /** + * test load data fail + * + * @runInSeparateProcess + * + * @return void + */ + public function testExceptionLoadData(): void + { + $this->expectException(KBException::class); + $this->expectExceptionCode(0); + $this->expectExceptionMessageRegExp('/(.+) does not exist !/'); + Search::$DATA_DIR = "."; + Search::$loaded = false; + Search::loadData(); + } + + /** + * test get variables with dynamic status + * + * @return void + */ + public function testGetVariablesWithDynamic(): void + { + $dynamic = Search::getVariablesWithDynamic(true); + $this->assertEquals($dynamic, Search::getDynamicVariables()); + $static = Search::getVariablesWithDynamic(false); + $this->assertEquals($static, Search::getStaticVariables()); + $this->assertEquals(2, count($dynamic)); + $this->assertEquals(1, count($static)); + $common = \array_intersect($dynamic, $static); + $this->assertEquals(0, count($common));// Impossible to be dynamic and not + } + + /** + * test Exception get variable type has no type + * + * + * @return void + */ + public function testExceptionGetVariableType(): void + { + $this->expectException(KBException::class); + $this->expectExceptionCode(0); + $this->expectExceptionMessageRegExp('/(.+) does have a known type !/'); + Search::getVariableType("variable-2"); + } + + /** + * test get variable type + * + * @return void + */ + public function testGetVariableType(): void + { + $type = Search::getVariableType("variable-1"); + $this->assertEquals("boolean", $type); + } + +} diff --git a/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/SlimDataTest.php b/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/SlimDataTest.php new file mode 100644 index 0000000..30a1d18 --- /dev/null +++ b/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/SlimDataTest.php @@ -0,0 +1,59 @@ +<?php +declare(strict_types = 1); +namespace Williamdes\MariaDBMySQLKBS\Test; + +use \PHPUnit\Framework\TestCase; +use \Williamdes\MariaDBMySQLKBS\SlimData; + +class SlimDataTest extends TestCase +{ + + /** + * Create an instance of SlimData + * + * @return SlimData + */ + public function testCreateInstance(): SlimData + { + $slimData = new SlimData(); + $this->assertInstanceOf(SlimData::class, $slimData); + return $slimData; + } + + /** + * Test json_encode empty object + * + * @param SlimData $slimData SlimData instance + * @depends testCreateInstance + * @return void + */ + public function testToJsonEmpty(SlimData $slimData): void + { + $this->assertEquals('{"version":1}', json_encode($slimData)); + } + + /** + * Test json_encode with variables + * + * @param SlimData $slimData SlimData instance + * @depends testCreateInstance + * @return void + */ + public function testToJsonWithVariables(SlimData $slimData): void + { + $slimData->addVariable("Test_var", "boolean", true); + $slimData->addVariable("another-variable", "string", false); + $kbe = $slimData->addVariable("doc-variable_ok", "integer", true); + $kbe->addDocumentation("https://example.org/williamdes/mariadb-mysql-kbs", "a_doc-variable_ok"); + $kbe->addDocumentation("https://example.org/williamdes/mariadb-mysql-kbs", "a_href_ok"); + $kbe->addDocumentation("https://example.org/williamdes/mariadb-mysql-kbs/_doc-variable_ok"); + $kbe->addDocumentation("https://dev.mysql.com/"); + $kbe->addDocumentation("https://mariadb.com/"); + $kbe->addDocumentation("https://mariadb.com/", "anchorname"); + $this->assertEquals( + file_get_contents(__DIR__."/data/ultraSlimDataTestWithVariables.json"), + json_encode($slimData, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) + ); + } + +} diff --git a/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/cleaner.js b/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/cleaner.js new file mode 100644 index 0000000..007207e --- /dev/null +++ b/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/cleaner.js @@ -0,0 +1,193 @@ +'use strict'; + +const expect = require('chai').expect; +const cleaner = require(__dirname + '/../src/cleaner'); + +module.exports = function() { + suite('cleaner', function() { + test('clean cli html code', function(done) { + const cli = cleaner.cleanCli('<code>--test-argument</code>'); + expect(cli).to.equal('--test-argument'); + done(); + }); + test('clean cli html code not closed', function(done) { + const cli = cleaner.cleanCli('<code>--test-argument'); + expect(cli).to.equal('--test-argument'); + done(); + }); + test('clean cli nothing to clean', function(done) { + const cli = cleaner.cleanCli('--test-argument'); + expect(cli).to.equal('--test-argument'); + done(); + }); + test('clean cli undefined', function(done) { + const cli = cleaner.cleanCli(undefined); + expect(cli).to.equal(undefined); + done(); + }); + test('clean range undefined', function(done) { + const range = cleaner.cleanRange(undefined); + expect(range).to.deep.equal(undefined); + done(); + }); + test('clean range.from typeof object (dataset-1)', function(done) { + const range = cleaner.cleanRange({ + from: null, + to: null, + }); + expect(range).to.deep.equal({}); + done(); + }); + test('clean range.from typeof object (dataset-2)', function(done) { + const range = cleaner.cleanRange({ + to: null, + }); + expect(range).to.deep.equal({}); + done(); + }); + test('clean range.from typeof object (dataset-3)', function(done) { + const range = cleaner.cleanRange({ + from: null, + }); + expect(range).to.deep.equal({}); + done(); + }); + test('clean range.from typeof object (dataset-4)', function(done) { + const range = cleaner.cleanRange({ + from: undefined, + to: undefined, + }); + expect(range).to.deep.equal({}); + done(); + }); + test('clean range.from typeof object (dataset-5)', function(done) { + const range = cleaner.cleanRange({ + to: undefined, + }); + expect(range).to.deep.equal({}); + done(); + }); + test('clean range.from typeof object (dataset-6)', function(done) { + const range = cleaner.cleanRange({ + from: undefined, + }); + expect(range).to.deep.equal({}); + done(); + }); + test('clean range.from typeof object (dataset-7)', function(done) { + const range = cleaner.cleanRange({ + from: NaN, + to: NaN, + }); + expect(range).to.deep.equal({}); + done(); + }); + test('clean range.from typeof int', function(done) { + const range = cleaner.cleanRange({ + from: 1024, + }); + expect(range).to.deep.equal({ + from: 1024, + }); + done(); + }); + test('clean range.from typeof string', function(done) { + const range = cleaner.cleanRange({ + from: '1024', + }); + expect(range).to.deep.equal({}); + done(); + }); + test('clean range.to typeof int', function(done) { + const range = cleaner.cleanRange({ + to: 1024, + }); + expect(range).to.deep.equal({ + to: 1024, + }); + done(); + }); + test('clean range.to typeof string', function(done) { + const range = cleaner.cleanRange({ + to: '1024', + }); + expect(range).to.deep.equal({}); + done(); + }); + test('clean range.to typeof object', function(done) { + const range = cleaner.cleanRange({ + to: {}, + }); + expect(range).to.deep.equal({}); + done(); + }); + test('clean range to upwards', function(done) { + const range = cleaner.cleanRange({ + to: 'upwards', + }); + expect(range).to.deep.equal({ + to: 'upwards', + }); + done(); + }); + test('clean range to upwards match', function(done) { + const range = cleaner.cleanRange({ + to: '(128KB) upwards', + }); + expect(range).to.deep.equal({ + to: 'upwards', + }); + done(); + }); + test('clean binary types in bytes', function(done) { + const type = cleaner.cleanType('in bytes'); + expect(type).to.deep.equal('byte'); + done(); + }); + test('clean binary types size in mb', function(done) { + const type = cleaner.cleanType('size in mb'); + expect(type).to.deep.equal('byte'); + done(); + }); + test('clean binary types number of bytes', function(done) { + const type = cleaner.cleanType('number of bytes'); + expect(type).to.deep.equal('byte'); + done(); + }); + test('clean binary types number of', function(done) { + const type = cleaner.cleanType('number of'); + expect(type).to.deep.equal('integer'); + done(); + }); + test('clean binary types size of', function(done) { + const type = cleaner.cleanType('size of'); + expect(type).to.deep.equal('integer'); + done(); + }); + test('clean binary types in microseconds', function(done) { + const type = cleaner.cleanType('in microseconds'); + expect(type).to.deep.equal('integer'); + done(); + }); + test('clean binary types in seconds', function(done) { + const type = cleaner.cleanType('in seconds'); + expect(type).to.deep.equal('integer'); + done(); + }); + test('clean wtf type', function(done) { + const type = cleaner.cleanType('wtf'); + expect(type).to.deep.equal(undefined); + done(); + }); + test('clean enumeration type', function(done) { + const type = cleaner.cleanType('enumeration'); + expect(type).to.deep.equal('enumeration'); + done(); + }); + test('clean undefined type', function(done) { + const type = cleaner.cleanType(undefined); + expect(type).to.deep.equal(undefined); + done(); + }); + }); +}; diff --git a/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/data/mysql_test_case_1.html b/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/data/mysql_test_case_1.html new file mode 100644 index 0000000..5855c10 --- /dev/null +++ b/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/data/mysql_test_case_1.html @@ -0,0 +1,235 @@ +<html> + +<div class="itemizedlist"> + <ul class="itemizedlist" style="list-style-type: disc; "> + <li class="listitem"> + <p><a name="option_mysqld_ndbcluster"></a> + <a class="indexterm" name="idm139716308207376"></a> + + <a class="indexterm" name="idm139716308205888"></a> + + <a class="link" href="mysql-cluster-options-variables.html#option_mysqld_ndbcluster"><code + class="option">--ndbcluster</code></a> + </p> + <div class="table"> + <a name="ndbcluster-detailtable"></a> + <p class="title"><b>Table 21.207 + Type and value information for ndbcluster</b></p> + <div class="table-contents"> + <table> + <colgroup> + <col width="35%"> + <col width="65%"> + </colgroup> + <thead> + <tr> + <th scope="col">Property</th> + <th scope="col">Value</th> + </tr> + </thead> + <tbody> + <tr> + <td scope="row">Name</td> + <td><code + class="literal"><a class="link" href="mysql-cluster-options-variables.html#option_mysqld_ndbcluster">ndbcluster</a></code> + </td> + </tr> + <tr> + <td scope="row">Command Line</td> + <td>Yes</td> + </tr> + <tr> + <td scope="row">System Variable</td> + <td>No</td> + </tr> + <tr> + <td scope="row">Status Variable</td> + <td>No</td> + </tr> + <tr> + <td scope="row">Option File</td> + <td>Yes</td> + </tr> + <tr> + <td scope="row">Scope</td> + <td></td> + </tr> + <tr> + <td scope="row">Dynamic</td> + <td>No</td> + </tr> + <tr> + <td scope="row">Type</td> + <td></td> + </tr> + <tr> + <td scope="row">Default, Range</td> + <td>FALSE (Version: NDB 7.5-7.6)</td> + </tr> + <tr> + <td scope="row">Notes</td> + <td> + <p> + DESCRIPTION: Enable NDB Cluster (if this version + of MySQL supports it) + </p> + <p> + Disabled by + <a class="link" + href="mysql-cluster-options-variables.html#option_mysqld_skip-ndbcluster"><code + class="option">--skip-ndbcluster</code></a>. + </p> + </td> + </tr> + </tbody> + </table> + </div> + <div class="table-contents"> + <table cellpadding="0" cellspacing="0" + style="position: fixed; top: 0px; display: none; left: 431px; width: 705px;"> + <thead> + <tr> + <th scope="col" style="width: 247px;">Property</th> + <th scope="col" style="width: 457px;">Value</th> + </tr> + </thead> + </table> + </div> + + </div> + <br class="table-break"> + <p> + The <a class="link" href="mysql-cluster.html" + title="Chapter 21 MySQL NDB Cluster 7.5 and NDB Cluster 7.6"><code + class="literal">NDBCLUSTER</code></a> storage engine + is necessary for using NDB Cluster. If a + <a class="link" href="mysqld.html" title="4.3.1 mysqld — The MySQL Server"><span + class="command"><strong>mysqld</strong></span></a> binary includes support for the + <a class="link" href="mysql-cluster.html" + title="Chapter 21 MySQL NDB Cluster 7.5 and NDB Cluster 7.6"><code + class="literal">NDBCLUSTER</code></a> storage engine, + the engine is disabled by default. Use the + <a class="link" href="mysql-cluster-options-variables.html#option_mysqld_ndbcluster"><code + class="option">--ndbcluster</code></a> option to + enable it. Use <code class="option">--skip-ndbcluster</code> to + explicitly disable the engine. + </p> + <p> + It is not necessary or desirable to use this option + together with <a class="link" href="server-options.html#option_mysqld_initialize"><code + class="option">--initialize</code></a>. + Beginning with NDB 7.5.4, <code class="option">--ndbcluster</code> is + ignored (and the <code class="literal">NDB</code> storage engine is + <span class="emphasis"><em>not</em></span> enabled) if + <code class="option">--initialize</code> is also used. (Bug #81689, + Bug #23518923) + </p> + </li> + <li class="listitem"> + <p><a name="option_mysqld_ndb-allow-copying-alter-table"></a> + <a class="indexterm" name="idm139716308160304"></a> + + <a class="indexterm" name="idm139716308158800"></a> + + <code class="option">--ndb-allow-copying-alter-table=[ON|OFF]</code> + </p> + <div class="table"> + <a name="ndb-allow-copying-alter-table-detailtable"></a> + <p class="title"><b>Table 21.208 + Type and value information for ndb-allow-copying-alter-table</b></p> + <div class="table-contents"> + <table> + <colgroup> + <col width="35%"> + <col width="65%"> + </colgroup> + <thead> + <tr> + <th scope="col">Property</th> + <th scope="col">Value</th> + </tr> + </thead> + <tbody> + <tr> + <td scope="row">Name</td> + <td><code + class="literal"><a class="link" href="mysql-cluster-options-variables.html#option_mysqld_ndb-allow-copying-alter-table">ndb-allow-copying-alter-table</a></code> + </td> + </tr> + <tr> + <td scope="row">Command Line</td> + <td>Yes</td> + </tr> + <tr> + <td scope="row">System Variable</td> + <td>Yes</td> + </tr> + <tr> + <td scope="row">Status Variable</td> + <td>No</td> + </tr> + <tr> + <td scope="row">Option File</td> + <td>Yes</td> + </tr> + <tr> + <td scope="row">Scope</td> + <td>Both</td> + </tr> + <tr> + <td scope="row">Dynamic</td> + <td>Yes</td> + </tr> + <tr> + <td scope="row">Type</td> + <td></td> + </tr> + <tr> + <td scope="row">Default, Range</td> + <td>ON (Version: NDB 7.5-7.6)</td> + </tr> + <tr> + <td scope="row">Notes</td> + <td> + <p> + DESCRIPTION: Set to OFF to keep ALTER TABLE from + using copying operations on NDB tables + </p> + </td> + </tr> + </tbody> + </table> + </div> + <div class="table-contents"> + <table cellpadding="0" cellspacing="0" + style="position: fixed; top: 0px; display: none; left: 431px; width: 911px;"> + <thead> + <tr> + <th scope="col" style="width: 319px;">Property</th> + <th scope="col" style="width: 591px;">Value</th> + </tr> + </thead> + </table> + </div> + + </div> + <br class="table-break"> + <p> + Let <a class="link" href="alter-table.html" title="13.1.8 ALTER TABLE Syntax"><code + class="literal">ALTER TABLE</code></a> and other + DDL statements use copying operations on + <code class="literal">NDB</code> tables. Set to + <code class="literal">OFF</code> to keep this from happening; doing + so may improve performance of critical applications. + </p> + </li> + <li class="listitem"> + <p><a name="option_mysqld_ndb-batch-size"></a> + <a class="indexterm" name="idm139716308121008"></a> + + <a class="indexterm" name="idm139716308119520"></a> + + <code class="option">--ndb-batch-size=<em class="replaceable"><code>#</code></em></code> + </p> + +</html> diff --git a/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/data/mysql_test_case_2.html b/srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/data/mysql_test_case_2.html new file mode 100644 index 0000000..2c3c1c5 -- |
