Home

Awesome

RdfInterface compliance tests

A set of PHPUnit tests for checking compliance of your classes with the rdfInterface.

Usage

I assume you are using the composer to manage your code dependencies.
If not, it's definitely a good idea to start using it.

Sample implementation

Let's assume I developed a myOwnRdf\MyOwnNamedNode class implementing the rdfInterface\NamedNode interface.

The class providing compliance tests for the rdfInterface\NamedNode is \rdfInterface\tests\TermsTest. See here.

The \rdfInterface\tests\TermsTest class declares two abstract methods (trough the TestBaseTrait) which I have to implement:

Knowing all of that I can prepare my own test class inheriting from \rdfInterface\tests\TermsTest. Just:

<?php
namespace myOwnRdf;

class MyOwnNamedNodeTest extends \rdfInterface\tests\DataFactoryTest {

    public static function getDataFactory(): \rdfInterface\DataFactory {
        return new MyDataFactoryClass();
    }

    public static function getForeignDataFactory(): \rdfInterface\DataFactory {
        return new \simpleRdf\DataFactory();
    }

    // override unwanted \rdfInterface\tests\DataFactoryTest methods
    public function testBlankNode(): void {
        $this->assertTrue(true);
    }
    public function testLiteralFactory(): void {
        $this->assertTrue(true);
    }
    (...etc., there is a lot of methods to skip in this scenario...)

    // provide my own test

    public function testMyFeature(): void {
       (...perform some tests...)
    }
}

You can find more exhaustive examples of reusing tests provided by this package in simpleRdf library tests and quickRdf library tests.