diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-01-09 10:55:03 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-01-09 13:09:38 +0100 |
| commit | 04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa (patch) | |
| tree | 5c691241355c943a3c68ddb06b8cf8c60aa11319 /srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/SearchTest.php | |
| parent | 7e0d85db834d6351ed85d01e5126ac31dc510b86 (diff) | |
| download | ft_server-04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa.tar.gz ft_server-04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa.tar.bz2 ft_server-04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa.zip | |
phpmyadmin working
Diffstat (limited to 'srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/SearchTest.php')
| -rw-r--r-- | srcs/phpmyadmin/vendor/williamdes/mariadb-mysql-kbs/test/SearchTest.php | 178 |
1 files changed, 178 insertions, 0 deletions
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); + } + +} |
