Issues needing unit tests

There are several XML parser issues that require unit test, for example:

There are also some existing test cases that cover one parser, but not another.

The suggestion is to unify their test coverage and make sure that we test both parsers.

Useful resources

Here are some resources regarding testing XML with PHPUnit I found.

PHPUnit in Drupal 8

Testing XML with PHPUnit

Tobias Schlitt, "Practical PHPUnit: Testing XML generation" (2010)

XML-related PHPUnit assertions

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Frank Ralf created an issue. See original summary.

frank ralf’s picture

Issue summary: View changes
frank ralf’s picture

StatusFileSize
new1.84 KB

This is a working test file with some sample tests showing how the XML-related PHPUnit assertions work. Save this file to modules\migrate_plus\tests\src\Unit\data_parser\XmlTest.php and run it from the root of your Drupal installation with vendor/bin/phpunit -c core modules/migrate_plus/tests/src/Unit/data_parser/XmlTest.php.

Next step:
Test real Drupal functions with these assertions.

frank ralf’s picture

StatusFileSize
new1.84 KB

Re-upload with different file extension to allow download.

frank ralf’s picture

frank ralf’s picture

Title: XML data parser: unit tests needed » XML parser: Unit tests needed
Related issues: +#2934156: XMLReader does not read values wrapped in CDATA
frank ralf’s picture

There are still problems with downloading the sample file from here so I put it on GitHub:
https://github.com/nakohdo/Drupal8.migrate_plus/blob/master/tests/XmlTes...

frank ralf’s picture

Component: Plugins » Tests
matroskeen’s picture

Title: XML parser: Unit tests needed » XML parsers: Unit tests
Version: 8.x-4.x-dev » 6.0.x-dev
Issue summary: View changes

matroskeen’s picture

Status: Active » Needs review

The idea is to use BaseXmlTest.php for both plugins and individual test classes for some specific things that are different in both parsers.

  • Matroskeen committed 6d017f7 on 6.0.x
    Issue #2947711 by Matroskeen, Frank Ralf: XML parsers: Unit tests
    
matroskeen’s picture

Version: 6.0.x-dev » 8.x-5.x-dev
Status: Needs review » Patch (to be ported)
StatusFileSize
new15.04 KB

Uploading a patch for 8.x-5.x

  • Matroskeen committed 051b50f on 8.x-5.x
    Issue #2947711 by Matroskeen, Frank Ralf: XML parsers: Unit tests
    
matroskeen’s picture

Status: Patch (to be ported) » Fixed

It's all green, so marking as fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.