assertInstanceof( SchemaDefinition::class, $instance ); $this->assertInstanceof( '\SMW\Schema\Schema', $instance ); $this->assertInstanceof( '\JsonSerializable', $instance ); } public function testGetName() { $instance = new SchemaDefinition( 'foo', [] ); $this->assertEquals( 'foo', $instance->getName() ); } public function testGetSchemaLink() { $instance = new SchemaDefinition( 'foo', [], [ SchemaDefinition::SCHEMA_VALIDATION_FILE => 'BAR' ] ); $this->assertEquals( 'BAR', $instance->info( SchemaDefinition::SCHEMA_VALIDATION_FILE ) ); } public function testInfo_Default() { $instance = new SchemaDefinition( 'foo', [], [ SchemaDefinition::SCHEMA_VALIDATION_FILE => 'BAR' ] ); $this->assertEquals( 'default_value', $instance->info( 'Foo', 'default_value' ) ); } public function testToArray() { $def = [ 'type' => 'foo_bar', 'description' => 'bar foo bar', 'Schema' => [ 'if' => [ 'doSomething', 'and' => [ 'doSomethingElse' ] ], 'then' => [ ] ] ]; $instance = new SchemaDefinition( 'foo', $def ); $this->assertEquals( $def, $instance->toArray() ); } public function testGet() { $def = [ 'type' => 'foo_bar', 'description' => 'bar foo bar', 'Schema' => [ 'if' => [ 'doSomething', 'and' => [ 'doSomethingElse' ] ], 'then' => [ ] ] ]; $instance = new SchemaDefinition( 'foo', $def ); $this->assertEquals( 'foo_bar', $instance->get( SchemaDefinition::SCHEMA_TYPE ) ); $this->assertEquals( [ 'doSomething', 'and' => [ 'doSomethingElse' ] ], $instance->get( 'Schema.if' ) ); $this->assertEquals( [ 'doSomethingElse' ], $instance->get( 'Schema.if.and' ) ); } public function testJsonSerialize() { $def = [ 'type' => 'foo_bar', 'description' => 'bar foo bar', 'Schema' => [ 'if' => [ 'doSomething', 'and' => [ 'doSomethingElse' ] ], 'then' => [ ] ] ]; $instance = new SchemaDefinition( 'foo', $def ); $this->assertEquals( json_encode( $def ), $instance->jsonSerialize() ); } }