Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Maks Rafalko
    @maks-rafalko

    To me it looks like invalid code

    Why is the code invalid? Does it produce syntax error or warning?

    Tomas Norre
    @tomasnorre_twitter
    Not invalid, just read it wrong. Thanks for your explaination.
    Matthias Leopold
    @Matleo

    Hello there :)
    I am part of a small developer team in the swiss health industry and absolutely love the idea of infection testing.

    We are currently using it in the backend project for our E-Commerce platform, but are facing a problem when trying to exclude certain Classes from the infection test:
    In the github.io documentation it says "Paths under excludes key are relative to the source.directories folders."

    In our Project we have a File named "src/AppBundle/PHPUnit/Mocks/Traits/SampleBrandWithArticlesTrait.php" where "src" is specified as our "source.directories".
    Now I cannot manage to exclue this file from being used for the infection tests.

    Neither "AppBundle\/PHPUnit\/Mocks\/Traits\/**" nor "**\/Traits\/**" (we want to exclude all Traits), does the job.
    What are we doing wrong?
    This message was deleted
    Matthias Leopold
    @Matleo
    Our infection.json.dist looks as follows
    {
    "source": {
    "directories": [
    "src\/"
    ],
    "excludes": [
    "**\/Tests\/*",
    "AppBundle\/PHPUnit\/Mocks\/Traits\/**"
    ]
    },
    "timeout": 10,
    "logs": {
    "text": "artifacts\/infection\/infection.log",
    "summary": "php:\/\/stdout",
    "perMutator": "artifacts\/infection\/per-mutator_blabla.md"
    },
    "tmpDir": "var\/temp",
    "phpUnit": {
    "configDir": "var\/infection"
    },
    "mutators": {
    "@default": true,
    "@function_signature": false
    },
    "testFramework":"phpunit",
    "testFrameworkOptions": "-vvv"
    }
    Maks Rafalko
    @maks-rafalko

    hello!

    have you tried "excludes": [“SampleBrandWithArticlesTrait.php”]?

    it’s weird, to be honest. If you could try creating a minimal reproducing example repository - feel free to open an issue. Probably this is just a bug that we are not aware of
    Matthias Leopold
    @Matleo
    Wow. That actually worked. Thank you
    We still would like to exclude all Traits though. Any Ideas?
    Maks Rafalko
    @maks-rafalko

    AppBundle\/PHPUnit\/Mocks\/Traits\/*.php does it work?

    I still think there might be an issue / bug here. So fell free to open a ticket

    Matthias Leopold
    @Matleo
    Does not work
    Matthias Leopold
    @Matleo
    I will open an Issue on this concern next week.
    Thank you for your help!
    Maks Rafalko
    @maks-rafalko
    thanks!
    Valentin
    @Vallelorand_twitter
    Hi,
    I have a problem with this awesome library :
    • Output
      Running initial test suite...
      PHPUnit version: 8.5.8
       4 [============================] 24 secs
      In NoLineExecuted.php line 47:                                                                                
      No line of code was executed during tests. This could be due to "@covers" annotations or your  
      PHPUnit filters not being set up correctly.
    • Config
      {
       "source": {
           "directories": [
               "src"
           ]
       },
       "logs": {
           "text": "php://stdout"
       },
       "tmpDir": "cache/infection",
       "mutators": {
           "@default": true 
       },
       "initialTestsPhpOptions": "-d zend_extension=xdebug.so"
      }
      There is not @covers annotations (it's a big project ) and no difference when I comment the filter flag in phpunit.xml.
      I haven't seen similary error on the web, it's weird, I'm lost.
    Alexey Kopytko
    @sanmai
    Hi, would you mind opening an issue so someone can have a closer look?
    Please include phpunit.xml too.
    Valentin
    @Vallelorand_twitter
    Okay thanks, I will do that
    <?xml version="1.0" encoding="UTF-8"?>
    <phpunit
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
        bootstrap="bootstrap-phpunit.php"
        verbose="false"
        backupGlobals="false"
        backupStaticAttributes="false"
        convertErrorsToExceptions="false"
        convertNoticesToExceptions="false"
        convertWarningsToExceptions="false"
        failOnWarning="true"
        timeoutForSmallTests="5"
        timeoutForMediumTests="10"
        timeoutForLargeTests="60"
        beStrictAboutTestsThatDoNotTestAnything="true"
    >
        <filter>
            <whitelist processUncoveredFilesFromWhitelist="false">
                <directory suffix=".php">./src</directory>
            </whitelist>
        </filter>
    </phpunit>
    MGatner
    @MGatner
    Is anyone here? I went on the Discord first but the Infection channel seems pretty much dead.
    Maks Rafalko
    @maks-rafalko

    @MGatner we are here, but please prefer Discord rather than any other place.

    https://discord.gg/ZUmyHTJ

    LLIED
    @LLIED
    I see that the installation commands are Linux. Can I install infection under Windows according to the installation procedures
    Maks Rafalko
    @maks-rafalko
    @LLIED while I don't use Windows, we have a build where Infection is tested on Windows, so it should work
    composer require infection/infection
    probably php bin/infection ... instead of just bin/infection must work
    MGatner
    @MGatner
    @maks-rafalko Thanks! We spoke there, I'm Tattersail on Discord 👍
    LLIED
    @LLIED
    Is there a PHP version requirement when using infection? such as applications written by PHP 5.3?
    Eric COURTIAL
    @ecourtial

    Is there a PHP version requirement when using infection? such as applications written by PHP 5.3?

    As you can see in the composer.json on Github : "php": "^7.4 || ^8.0","

    But older version might support older version of PHP
    After a quick look, the older version of infection contains this : ""php": "^7.0","
    LLIED
    @LLIED
    So I have a web project written in php5.3.29, which can't use infection?The minimum supported version of PHP is 7.
    Eric COURTIAL
    @ecourtial

    So I have a web project written in php5.3.29, which can't use infection?The minimum supported version of PHP is 7.

    Exactly, you cannot use Infection with this version of PHP. Side note, even if by experience I perfectly understand we are not always the master of the destiny of the program we are working on, but, from memory PHP 5.3 was released circa 2009. It is not prehistoric, but almost. Not only for security but also for maintanability, you should consider to perform an upgrade. There are some tools that could help you to analyse the different steps you would need to do, and even propose some refactorization.

    Alexey Kopytko
    @sanmai

    So I have a web project written in php5.3.29, which can't use infection?The minimum supported version of PHP is 7.

    If you have a project written for php 5.3, and if you can get it run under PHP 7.0+, then you can definitely use Infection on it. Only you'll have to run Infection under PHP 7+. You can keep running your project under PHP 5.3.

    Wolfgang Schaefer
    @wolfgangschaefer
    Hello! I have troubles using the command infection --git-diff-base=origin/master --git-diff-filter=A on MacOS. It does not seem to reduce the number of Mutants/files. Are there any Mac users out there that successfully use infection with the --git-diff-filter options?
    Maks Rafalko
    @maks-rafalko

    @wolfgangschaefer interesting. You can try to run the underlying command directly in the mac's terminal:

    git diff origin/master --diff-filter=AM --name-only | grep src/ | paste -sd ","

    what is the output?

    @/all please, consider moving to our main discussion channel - Discord https://discord.gg/ZUmyHTJ
    Wolfgang Schaefer
    @wolfgangschaefer
    @maks-rafalko When I try the command directly in terminal I get following error: usage: paste [-s] [-d delimiters] file …- Any idea why it would fail on mac?
    Maks Rafalko
    @maks-rafalko

    seems like you don't have paste command or paste command on mac has different options than linux's one

    could you please open an issue on GitHub so we can discuss it and resolve further? Thank you

    Wolfgang Schaefer
    @wolfgangschaefer
    @maks-rafalko will do, thank you for your help!
    Wolfgang Schaefer
    @wolfgangschaefer
    @maks-rafalko infection/infection#1492
    MGatner
    @MGatner
    @maks-rafalko IMO you should shut this down. As long as Gitter is an option there will be people that come here first because it is much easier to log in, even though Discord offers way better support options.
    Wolfgang Schaefer
    @wolfgangschaefer

    @MGatner I came here because it was listed in infection “Support Question” issue template:

    * Slack Chat: https://symfony-devs.slack.com/messages/C78M7A4BY/
    * Gitter: https://gitter.im/infection/Lobby
    * Twitter: If it's just a quick question you can ping our Twitter: https://twitter.com/infection_php
    * Also have a look at the documentation: https://infection.github.io

    Slack chat did not work for me, and the discord is not listed there.

    MGatner
    @MGatner
    @wolfgangschaefer I totally understand, it's how I ended up here too. :) I think the community would be richer if the pipeline directing people to community conversations were clearer and cleaner.
    Eric COURTIAL
    @ecourtial
    Hi everybody. I have a small question. I have been using infection (with success :P ) during the last year on many projects, but today I am facing an issue, certainly my fault, for which I did not find any solution so far. To make it simple, I have one small class, 100% covered by one unit test. Infection is using some mutator on a if condition but I don't understand how the mutant can escape. Below are the data :
    6 covered mutants were not detected
    The condition which is driving me crazy
        if (false === $this->connector instanceof Api) {
            $this->connector = $this->connectorFactory->get($this->connectorUrl, $this->connectorToken);
        }
    So you guess that Infection is changing many times the if condition. But in my test, I put a mock for the ConnectorFactory, and check that it is only called one time. However the mutant still escape. I assume that in fact I don't completely understand how Infection works. Anybody with an idea of what I am missing ?
    MGatner
    @MGatner
    @ecourtial You might have better luck on the Discord, link just above!
    Eric COURTIAL
    @ecourtial
    @MGatner Allright thanks :)