PHPackages                             shulard/atoum-xml-extension - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. shulard/atoum-xml-extension

ActiveLibrary[Testing &amp; Quality](/categories/testing)

shulard/atoum-xml-extension
===========================

The atoum xml extension allows you to make assertions on XML files

v1.1.0(6mo ago)216.8k↓84.3%3Apache-2.0PHPCI passing

Since Sep 6Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/shulard/atoum-xml-extension)[ Packagist](https://packagist.org/packages/shulard/atoum-xml-extension)[ Docs](http://www.atoum.org)[ RSS](/packages/shulard-atoum-xml-extension/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (2)Versions (7)Used By (0)

shulard/atoum-xml-extension [![Build Status](https://camo.githubusercontent.com/4f9f7ecf212971e77555bffb383ace8c77fc42d3754ffefdb6a9faae873936c4/68747470733a2f2f7472617669732d63692e6f72672f7368756c6172642f61746f756d2d786d6c2d657874656e73696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/shulard/atoum-xml-extension) [![Latest Stable Version](https://camo.githubusercontent.com/6002ea57ed612db30250331479dce251f52bfc4626d1c34473e45236006f6dfa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7368756c6172642f61746f756d2d786d6c2d657874656e73696f6e2e737667)](https://packagist.org/packages/shulard/atoum-xml-extension)
=============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#shulardatoum-xml-extension--)

This atoum extension allows you to test XML document using [atoum](https://github.com/atoum/atoum). It's possible to execute xpath against the document or to validate it using DTD, XSD or RelaxNG schema. You can use it to validate HTML documents too.

Example
-------

[](#example)

```

    1namespaced content2

XML;

        $this
            ->then
                ->xml($xml)
                    ->isValidAgainstSchema
                        ->dtd('file://path/to.dtd', 'root')
                ->node
                    ->hasNamespace('atom', 'http://purl.org/atom/ns#')
                    ->isUsedNamespace('dc', 'http://purl.org/dc/elements/1.1/')
                    ->withNamespace('m', 'http://purl.org/atom/ns#')
                        ->xpath('//m:feed')
                            ->hasSize(1)
        ;
    }
}
```

When running this test, the XML document will be loaded and:

- Validate the document using a DTD;
- Check if `atom` namespace is present in document declaration;
- Check that `dc` namespace is used inside the document;
- Execute a xpath one namespaced node and check returning node collection.

Install it
----------

[](#install-it)

Install extension using [composer](https://getcomposer.org):

```
composer require --dev shulard/atoum-xml-extension
```

Enable and configure the extension using atoum configuration file:

```

XML;

        $node = $this->xml($xml)
            ->children
            ->item(0);
        $node
            ->attributes()
                ->hasSize(1)
                ->string['attribute']->isEqualTo('value')
        ;
        $node
            ->attributes('m')
                ->hasSize(1)
                ->string['attribute']->isEqualTo('namespaced value')
        ;
    }

    /**
     * Test node content using phpString asserter
     */
    public function testXpathAndNodeContent()
    {
        $xml =
