Infection: Uncaught Error: Call to a member function appendChild() on null

Created on 13 Jul 2017  路  5Comments  路  Source: infection/infection

I tried infection on a little project of mine wich has 100% coverage and where I am currently using humbug for mutation testing.

Steps to reproduce:

cd /tmp 
git clone https://github.com/bcremer/LineReader.git
cd LineReader 
composer install
wget https://github.com/infection/infection/releases/download/0.2.1/infection.phar
wget https://github.com/infection/infection/releases/download/0.2.1/infection.phar.pubkey
php infection.phar

Output:

   15 [============================]  1 sec
Generate mutants...

PHP Fatal error:  Uncaught Error: Call to a member function appendChild() on null in phar:///tmp/LineReader/infection.phar/src/TestFramework/PhpUnit/Config/MutationXmlConfiguration.php:107
Stack trace:
#0 phar:///tmp/LineReader/infection.phar/src/TestFramework/PhpUnit/Config/MutationXmlConfiguration.php(68): Infection\TestFramework\PhpUnit\Config\MutationXmlConfiguration->addTestSuiteWIthFilteredTestFiles(Object(DOMDocument), Object(DOMXPath))
#1 phar:///tmp/LineReader/infection.phar/src/TestFramework/PhpUnit/Config/MutationXmlConfiguration.php(52): Infection\TestFramework\PhpUnit\Config\MutationXmlConfiguration->setFilteredTestsToRun(Object(DOMDocument), Object(DOMXPath))
#2 phar:///tmp/LineReader/infection.phar/src/TestFramework/PhpUnit/Config/Builder/MutationConfigBuilder.php(63): Infection\TestFramework\PhpUnit\Config\MutationXmlConfiguration->getXml()
#3 phar:///tmp/LineReader/infection.phar/src/TestFramework/AbstractTestFrameworkAdapter.php(74): Infection\TestFramework\PhpUnit\Config\Builder\MutationConfigBuilder->build( in phar:///tmp/LineReader/infection.phar/src/TestFramework/PhpUnit/Config/MutationXmlConfiguration.php on line 107

PHP Version

$ php -v
PHP 7.1.7-1+ubuntu17.04.1+deb.sury.org+1 (cli) (built: Jul  7 2017 09:43:21) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.7-1+ubuntu17.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies
    with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans

Bug

All 5 comments

Thank you for this very detailed and well written bug report!

I didn't know that phpunit.xml can have <testsuite /> node directly inside root node, not inside <testssuites />

I've created a PR #7 to fix this problem, if you have 1 minute to review - I would appreciate it.

By the way, ran Infection on your LineReader lib:

0 mutations were generated:
      17 mutants were killed
       0 mutants were not covered by tests
       1 covered mutants were not detected
       2 time outs were encountered

Metrics:
         Mutation Score Indicator (MSI): 95%
         Mutation Code Coverage: 100%
         Covered Code MSI: 95%

Good stuff!

Thanks for the quick reply, I'll verify your fix tomorrow and report back.

Can confirm PR #7 fixes the Problem for me :)

20 mutations were generated:
      17 mutants were killed
       0 mutants were not covered by tests
       1 covered mutants were not detected
       2 time outs were encountered

Metrics:
         Mutation Score Indicator (MSI): 95%
         Mutation Code Coverage: 100%
         Covered Code MSI: 95%

Will be released today later under a new tag

Released under 0.3.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vitormelon picture vitormelon  路  5Comments

maks-rafalko picture maks-rafalko  路  3Comments

sanmai picture sanmai  路  5Comments

sanmai picture sanmai  路  8Comments

majkel89 picture majkel89  路  7Comments