PHP code example of barkermn01 / unittest-josn-schema

1. Go to this page and download the library: Download barkermn01/unittest-josn-schema library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

barkermn01 / unittest-josn-schema example snippets


$SchemaName = "test.schema.json";
$schemaToTest = file_get_contents(__DIR__ . "/test.schema.json");
				
$tester = new SchemaTester;
$tester->DefineSchema("http://json-schema.org/draft-07/schema");
$tester->TestSchema($schemaToTest);
$this->assertFalse($tester->hasErrors(), "Schema '{$SchemaName}' failed vailidation: '".$tester->getErrors());

$SchemaName = "test.schema.json";
$schemaToTest = file_get_contents(__DIR__ . "/test.schema.json");
				
$tester = new SchemaTester;
$tester->TestSchema($schemaToTest);
$this->assertFalse($tester->hasErrors(), "Schema '{$SchemaName}' failed vailidation: '".$tester->getErrors());