Server : Apache/2.4.43 (Win64) OpenSSL/1.1.1g PHP/7.4.6
System : Windows NT USER-PC 6.1 build 7601 (Windows 7 Professional Edition Service Pack 1) AMD64
User : User ( 0)
PHP Version : 7.4.6
Disable Function : NONE
Directory :  C:/xampp/phpMyAdmin/vendor/williamdes/mariadb-mysql-kbs/test/
Upload File :
Current Directory [ Writeable ] Root Directory [ Writeable ]


Current File : C:/xampp/phpMyAdmin/vendor/williamdes/mariadb-mysql-kbs/test/SlimDataTest.php
<?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)
        );
    }

}