uhi67/codeception-module-xmlasserts

Xml module for Codeception

1.0 2021-11-02 14:44 UTC

This package is auto-updated.

Last update: 2024-03-29 04:33:08 UTC


README

Codeception Module for testing XML structures.

Version 1.0

Installation

composer require "uhi67/codeception-module-xmlasserts:^1.0"

Usage

  1. Include in your suite's yml:
modules:
    enabled:
        - XmlAsserts
  1. Build codeception generated classes:

    codecept build

  2. Use assertions in tests/cests

    /** @noinspection PhpUndefinedVariableInspection */
    $I->assertXmlMatches($xpath, $xml);      // Checks XML matches XPath query
    $I->assertXmlIncludes($fragment, $xml);  // Checks if XML includes provided XML fragment.

... and helper methods

    /** @noinspection PhpUndefinedVariableInspection */
    $xml = $I->toXml($value);                 // Converts string, array or other node to DOMDocument
    $result = $I->xmlEval($query, $xml);      // Evaluates an Xpath query, returns typed result or nodeset
    $result = $I->xmlQuery($query, $xml);      // Evaluates an Xpath query, returns nodeset only     

License

uhi67/codeception-module-xmlasserts is released under the MIT License. See the bundled LICENSE for details.