Giter Site home page Giter Site logo

phpunit-schema's Introduction

PHPUnit Schema

The PHPUnit Schema file defines the rules by which a configuration file for PHPUnit may be structured. Schema aware XML Editors can provide content assist to authors. Using the Schema file is optional.

Validating your configuration file

The Schema file does not define a target namespace, so you should not need to modify your phpunit.xml if you just want to validate it. Just use a tool like xmllint to read in your configuration and validate it against the Schema, e.g.

 xmllint --schema phpunit.xsd phpunit.xml 

If you want to validate from a PHP file, you can use the DOM extension, e.g.

$dom = new DOMDocument;
$dom->load('/path/to/your/phpunit.xml');
if ($dom->schemaValidate('/path/to/phpunit.xsd')) {
    echo 'The document is valid';
}

Applying the Schema for Authoring

If you are using a Schema aware XML editor, you might want to apply the Schema file to your configuration file to get Content Assist and automatic validation when authoring the document.

To apply the Schema to a configuration file, you have to declare the Schema Namespace and the location of the Schema file in the phpunit.xml file. Since PHPUnit does not use a dedicated namespace for the configuration file, the following two lines are all that is required:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="location of xsd file"
    …

Getting a Single Schema file

The Schema file is currently split into multiple smaller files. This eases maintaining the Schema file during development. However, when working with PHPUnit, it might be undesired to have the entire folder structure in your project. For this reason, you can create a single phpunit.xsd with the PHP script given in the tools folder:

$ php generate-schema.php
Created new validated Schema file at:
 F:\Work\code\PHPUnit-Schema\tools\phpunit.xsd.1301999633 

Additional Resources

The documentation of configuration files can be found in the official PHPUnit Manual

The class processing the configuration file is

phpunit-schema's People

Contributors

gooh avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.