Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Expected a value other than null. #1480

Closed
maks-rafalko opened this issue Feb 11, 2021 · 10 comments
Closed

Error: Expected a value other than null. #1480

maks-rafalko opened this issue Feb 11, 2021 · 10 comments
Assignees
Labels
Milestone

Comments

@maks-rafalko
Copy link
Member

maks-rafalko commented Feb 11, 2021

I get this error too. I'm a brand new user and have infection/infection 0.21.0@dfacb1e3d9def7fd34c6fb8df4d4bd098815dc82 PHPUnit version 8.5.14 PHP 7.4.15 Xdebug 3.0.2 codebase is CakePHP 4.2.2.

challgren@challgren-pro authenticon-web %  XDEBUG_MODE=coverage; vendor/bin/infection

    ____      ____          __  _
   /  _/___  / __/__  _____/ /_(_)___  ____
   / // __ \/ /_/ _ \/ ___/ __/ / __ \/ __ \
 _/ // / / / __/  __/ /__/ /_/ / /_/ / / / /
/___/_/ /_/_/  \___/\___/\__/_/\____/_/ /_/

Infection - PHP Mutation Testing Framework version 0.21.0@dfacb1e3d9def7fd34c6fb8df4d4bd098815dc82


Running initial test suite...

PHPUnit version: 8.5.14

  173 [============================] 19 secs

Generate mutants...

Processing source code files: 33/36
In Assert.php line 2042:
                                     
  Expected a value other than null.  
                                     

run [--test-framework TEST-FRAMEWORK] [--test-framework-options TEST-FRAMEWORK-OPTIONS] [-j|--threads THREADS] [--only-covered] [-s|--show-mutations] [--no-progress] [--force-progress] [-c|--configuration CONFIGURATION] [--coverage COVERAGE] [--mutators MUTATORS] [--filter FILTER] [--formatter FORMATTER] [--git-diff-filter GIT-DIFF-FILTER] [--git-diff-base GIT-DIFF-BASE] [--logger-github] [--noop] [--min-msi MIN-MSI] [--min-covered-msi MIN-COVERED-MSI] [--log-verbosity LOG-VERBOSITY] [--initial-tests-php-options INITIAL-TESTS-PHP-OPTIONS] [--skip-initial-tests] [--ignore-msi-with-no-mutations] [--debug] [--dry-run]


See details #1357 (comment)

Originally posted by @challgren in #1357 (comment)

@challgren
Copy link

XDEBUG_MODE=coverage; vendor/bin/infection --log-verbosity=all -vvv
[debug] Checking INFECTION_ALLOW_XDEBUG
[debug] The Xdebug extension is loaded (3.0.2)
[debug] Async signals enabled (SIGINT = SIG_IGN)
[debug] Process restarting (INFECTION_ALLOW_XDEBUG=internal|3.0.2|1|*|*)
[debug] Running '/usr/local/Cellar/php@7.4/7.4.15/bin/php' 'vendor/bin/infection' '--log-verbosity=all' '-vvv' '--ansi'
[debug] Checking INFECTION_ALLOW_XDEBUG
[debug] Restarted (83 ms). The Xdebug extension is not loaded
[debug] Async signals enabled (SIGINT = SIG_DFL)

    ____      ____          __  _
   /  _/___  / __/__  _____/ /_(_)___  ____
   / // __ \/ /_/ _ \/ ___/ __/ / __ \/ __ \
 _/ // / / / __/  __/ /__/ /_/ / /_/ / / / /
/___/_/ /_/_/  \___/\___/\__/_/\____/_/ /_/

Infection - PHP Mutation Testing Framework version 0.21.0@dfacb1e3d9def7fd34c6fb8df4d4bd098815dc82


Running initial test suite...

PHPUnit version: 8.5.14

  173 [============================] 15 secs

Generate mutants...

Processing source code files: 33/36
In Assert.php line 2042:
                                     
  [InvalidArgumentException]         
  Expected a value other than null.  
                                     

Exception trace:
  at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/webmozart/assert/src/Assert.php:2042
 Webmozart\Assert\Assert::reportInvalidArgument() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/webmozart/assert/src/Assert.php:600
 Webmozart\Assert\Assert::notNull() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/infection/infection/src/TestFramework/Coverage/ProxyTrace.php:122
 Infection\TestFramework\Coverage\ProxyTrace->getTestLocator() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/infection/infection/src/TestFramework/Coverage/ProxyTrace.php:111
 Infection\TestFramework\Coverage\ProxyTrace->getAllTestsForMutation() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/infection/infection/src/Mutator/NodeMutationGenerator.php:182
 Infection\Mutator\NodeMutationGenerator->getAllTestsForCurrentNode() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/infection/infection/src/Mutator/NodeMutationGenerator.php:135
 Infection\Mutator\NodeMutationGenerator->generateForMutator() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/infection/infection/src/Mutator/NodeMutationGenerator.php:112
 Infection\Mutator\NodeMutationGenerator->generate() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/infection/infection/src/PhpParser/Visitor/MutationCollectorVisitor.php:80
 Infection\PhpParser\Visitor\MutationCollectorVisitor->getMutations() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/infection/infection/src/Mutation/FileMutationGenerator.php:109
 Infection\Mutation\FileMutationGenerator->generate() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/infection/infection/src/Mutation/MutationGenerator.php:101
 Infection\Mutation\MutationGenerator->generate() at n/a:n/a
 iterator_to_array() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/infection/infection/src/IterableCounter.php:64
 Infection\IterableCounter::bufferAndCountIfNeeded() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/infection/infection/src/Process/Runner/MutationTestingRunner.php:100
 Infection\Process\Runner\MutationTestingRunner->run() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/infection/infection/src/Engine.php:171
 Infection\Engine->runMutationAnalysis() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/infection/infection/src/Engine.php:111
 Infection\Engine->execute() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/infection/infection/src/Command/RunCommand.php:342
 Infection\Command\RunCommand->executeCommand() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/infection/infection/src/Command/BaseCommand.php:75
 Infection\Command\BaseCommand->execute() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/symfony/console/Application.php:971
 Symfony\Component\Console\Application->doRunCommand() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/symfony/console/Application.php:290
 Symfony\Component\Console\Application->doRun() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/symfony/console/Application.php:166
 Symfony\Component\Console\Application->run() at /Users/challgren/Projects/truepedigree/authenticon-web/vendor/infection/infection/bin/infection:83

run [--test-framework TEST-FRAMEWORK] [--test-framework-options TEST-FRAMEWORK-OPTIONS] [-j|--threads THREADS] [--only-covered] [-s|--show-mutations] [--no-progress] [--force-progress] [-c|--configuration CONFIGURATION] [--coverage COVERAGE] [--mutators MUTATORS] [--filter FILTER] [--formatter FORMATTER] [--git-diff-filter GIT-DIFF-FILTER] [--git-diff-base GIT-DIFF-BASE] [--logger-github] [--noop] [--min-msi MIN-MSI] [--min-covered-msi MIN-COVERED-MSI] [--log-verbosity LOG-VERBOSITY] [--initial-tests-php-options INITIAL-TESTS-PHP-OPTIONS] [--skip-initial-tests] [--ignore-msi-with-no-mutations] [--debug] [--dry-run]

[debug] Restarted process exited 1

As for the file thats breaking, I have no clue. This is my first run with infection/infection so you'd have to help guide me to find the problem code. I can tell you its a CakePHP 4.2.2 application

@AlexandruGG
Copy link
Contributor

I'm seeing this as well on a fresh Symfony 5.2 + PHP 8 installation, running with PHPUnit 9.5, and PCOV.

The stack trace is identical. I tried debugging a bit because I only have a few files. It fails in Entities and Repositories, although if I remove any getters and setters from the entity it works. In the repository, it only works if I remove the constructor.

@maks-rafalko
Copy link
Member Author

can I ask you to post the content of those files here? Are you able to reproduce it on our Playground?

@maks-rafalko maks-rafalko added this to the 0.22.0 milestone Feb 27, 2021
@AlexandruGG
Copy link
Contributor

AlexandruGG commented Feb 28, 2021

can I ask you to post the content of those files here? Are you able to reproduce it on our Playground?

I tried reproducing it in the playground without success. Nonetheless here is an example of an entity that is causing it to break. I stripped it to the minimum that still breaks Infection:

<?php

declare(strict_types=1);

namespace App\Infrastructure\Core\Entity;

use Doctrine\ORM\Mapping as ORM;
use App\Infrastructure\Core\Repository\UserRepository;

/**
 * @ORM\Entity(repositoryClass=UserRepository::class)
 * @ORM\Table(name="users")
 */
class User
{
    /**
     * @ORM\Column(name="id", type="integer", nullable=false, options={"unsigned"=true})
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private int $id;
    
    public function getId(): int
    {
        return $this->id;
    }
}

There's nothing special about it so I'm thinking the problem must be elsewhere. However, weirdly if I remove the getter everything works. Another thing to note is that the only tests I have currently don't even test this class at all.

@AlexandruGG
Copy link
Contributor

AlexandruGG commented Feb 28, 2021

Here's something else I found:

Based on this looks like an issue introduced by that PR. Actually, just reverting this one line fixes it: https://github.com/infection/infection/pull/1435/files#diff-87d093f6c6430c50b8ae34009e2fdbb447d50128df5e2d71aa12c4fd98b60b92R106

@sanmai sanmai self-assigned this Mar 1, 2021
sanmai added a commit to sanmai/infection that referenced this issue Mar 1, 2021
@sanmai
Copy link
Member

sanmai commented Mar 1, 2021

It's despicable it took me three weeks to get around at this issue. Should be fixed by #1494.

If anyone wishes to give it a shot, please be our guest.

@maks-rafalko
Copy link
Member Author

@challgren
Copy link

Ok cool thanks @sanmai I'll try it again once I get my project refactored so it will be a couple days before I can report back.

@AlexandruGG
Copy link
Contributor

@sanmai thank you very much for the speedy fix! I can confirm everything works now with the latest release 🎉

@challgren
Copy link

I can confirm this has now been fixed!!!!

challgren@challgren-pro authenticon-web % vendor/bin/infection --threads=10

 

    ____      ____          __  _
   /  _/___  / __/__  _____/ /_(_)___  ____
   / // __ \/ /_/ _ \/ ___/ __/ / __ \/ __ \
 _/ // / / / __/  __/ /__/ /_/ / /_/ / / / /
/___/_/ /_/_/  \___/\___/\__/_/\____/_/ /_/

 

Infection - PHP Mutation Testing Framework version 0.21.4@2ca5fd6ef8d291bf6577936bd8e25b5a2cf0cc09

 

Running initial test suite...

 

PHPUnit version: 8.5.14

 

  198 [============================] 18 secs

 

Generate mutants...

 

Processing source code files: 39/39
.: killed, M: escaped, U: uncovered, E: fatal error, T: timed out, S: skipped

 

UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU   (  50 / 1494)
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU   ( 100 / 1494)
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU..M   ( 150 / 1494)
..................................................   ( 200 / 1494)
..................................................   ( 250 / 1494)
..................................................   ( 300 / 1494)
..................................................   ( 350 / 1494)
..................................................   ( 400 / 1494)
..................................................   ( 450 / 1494)
.......TTTTTTTTTT.................................   ( 500 / 1494)
..................................................   ( 550 / 1494)
..................................................   ( 600 / 1494)
..................................................   ( 650 / 1494)
..................................................   ( 700 / 1494)
..................................................   ( 750 / 1494)
..................................................   ( 800 / 1494)
..................................................   ( 850 / 1494)
..................................................   ( 900 / 1494)
..................................................   ( 950 / 1494)
..................................................   (1000 / 1494)
.........................M..............M.........   (1050 / 1494)
.......TTTTTTTTTT.................................   (1100 / 1494)
..................................................   (1150 / 1494)
..................................................   (1200 / 1494)
..................................................   (1250 / 1494)
..................................................   (1300 / 1494)
............................................M.....   (1350 / 1494)
..................................................   (1400 / 1494)
..................................................   (1450 / 1494)
..M...M...M.................................         (1494 / 1494)

 

1494 mutations were generated:
    1320 mutants were killed
     147 mutants were not covered by tests
       7 covered mutants were not detected
       0 errors were encountered
      20 time outs were encountered
       0 mutants required more time than configured

 

Metrics:
         Mutation Score Indicator (MSI): 89%
         Mutation Code Coverage: 90%
         Covered Code MSI: 99%

 

Please note that some mutants will inevitably be harmless (i.e. false positives).

 

Time: 2m 22s. Memory: 0.07GB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants