Giter VIP home page Giter VIP logo

Comments (4)

sebastianbergmann avatar sebastianbergmann commented on July 17, 2024 1

Please note that bugs in PHPUnit 9 are no longer fixed. And while I agree that we should fix this for supported versions, please also note that annotations are deprecated and that you should use attributes instead sooner rather than later.

from phpunit.

staabm avatar staabm commented on July 17, 2024

will look into it

from phpunit.

staabm avatar staabm commented on July 17, 2024

@fredericgboutin-yapla I tried reproducing the issue but on my machine the code sample does not emit warnings. see #5802 (also doesnt reproduce on CI).

are you sure he warnings are emitted by a plain phpunit setup and not because of some other thing? do you have a backtrace of the warning?

from phpunit.

fredericgboutin-yapla avatar fredericgboutin-yapla commented on July 17, 2024

Hum, that's surprising.

I'm running PHP from the official Docker image using php.ini-development configuration.

> php vendor/bin/phpunit tests/ExampleTest.php

PHP Warning:  Uninitialized string offset 0 in /var/www/html/vendor/phpunit/phpunit/src/Metadata/Api/DataProvider.php on line 259

Warning: Uninitialized string offset 0 in /var/www/html/vendor/phpunit/phpunit/src/Metadata/Api/DataProvider.php on line 259
PHPUnit 10.5.17 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.14
Configuration: /var/www/html/phpunit.xml

...                                                                 3 / 3 (100%)

Time: 00:00.017, Memory: 6.00 MB

Example
 ✔ This test should NOT make phpunit spit a PHP Warning anymore... with data set 0
 ✔ This test should NOT make phpunit spit a PHP Warning anymore... with data set 1
 ✔ This test should NOT make phpunit spit a PHP Warning anymore... with data set 2

OK (3 tests, 3 assertions)
<?php

class ExampleTest extends PHPUnit\Framework\TestCase
{
    /**
     * @testWith [1]
     *           [2]
     *           [3]
     * 
     * @testdox This test should NOT make phpunit spit a PHP Warning anymore...
     */
    public function testExample($arg): void
    {
        $this->assertIsInt($arg);
    }
}

But sure, here is the backtrace JSON encoded for readability

[
    {
        "file": "\/var\/www\/html\/vendor\/bin\/phpunit",
        "line": 122,
        "args": [
            "\/var\/www\/html\/vendor\/phpunit\/phpunit\/phpunit"
        ],
        "function": "include"
    },
    {
        "file": "\/var\/www\/html\/vendor\/phpunit\/phpunit\/phpunit",
        "line": 104,
        "function": "run",
        "class": "PHPUnit\\TextUI\\Application",
        "object": {},
        "type": "->",
        "args": [
            [
                "vendor\/bin\/phpunit",
                "tests\/ExampleTest.php"
            ]
        ]
    },
    {
        "file": "\/var\/www\/html\/vendor\/phpunit\/phpunit\/src\/TextUI\/Application.php",
        "line": 108,
        "function": "buildTestSuite",
        "class": "PHPUnit\\TextUI\\Application",
        "object": {},
        "type": "->",
        "args": [
            {}
        ]
    },
    {
        "file": "\/var\/www\/html\/vendor\/phpunit\/phpunit\/src\/TextUI\/Application.php",
        "line": 349,
        "function": "build",
        "class": "PHPUnit\\TextUI\\Configuration\\TestSuiteBuilder",
        "object": {},
        "type": "->",
        "args": [
            {}
        ]
    },
    {
        "file": "\/var\/www\/html\/vendor\/phpunit\/phpunit\/src\/TextUI\/Configuration\/TestSuiteBuilder.php",
        "line": 55,
        "function": "testSuiteFromPath",
        "class": "PHPUnit\\TextUI\\Configuration\\TestSuiteBuilder",
        "object": {},
        "type": "->",
        "args": [
            "\/var\/www\/html\/tests\/ExampleTest.php",
            [
                "Test.php",
                ".phpt"
            ]
        ]
    },
    {
        "file": "\/var\/www\/html\/vendor\/phpunit\/phpunit\/src\/TextUI\/Configuration\/TestSuiteBuilder.php",
        "line": 119,
        "function": "fromClassReflector",
        "class": "PHPUnit\\Framework\\TestSuite",
        "type": "::",
        "args": [
            {
                "name": "ExampleTest"
            }
        ]
    },
    {
        "file": "\/var\/www\/html\/vendor\/phpunit\/phpunit\/src\/Framework\/TestSuite.php",
        "line": 134,
        "function": "addTestMethod",
        "class": "PHPUnit\\Framework\\TestSuite",
        "object": {},
        "type": "->",
        "args": [
            {
                "name": "ExampleTest"
            },
            {
                "name": "testExample",
                "class": "ExampleTest"
            }
        ]
    },
    {
        "file": "\/var\/www\/html\/vendor\/phpunit\/phpunit\/src\/Framework\/TestSuite.php",
        "line": 486,
        "function": "build",
        "class": "PHPUnit\\Framework\\TestBuilder",
        "object": {},
        "type": "->",
        "args": [
            {
                "name": "ExampleTest"
            },
            "testExample"
        ]
    },
    {
        "file": "\/var\/www\/html\/vendor\/phpunit\/phpunit\/src\/Framework\/TestBuilder.php",
        "line": 38,
        "function": "providedData",
        "class": "PHPUnit\\Metadata\\Api\\DataProvider",
        "object": {},
        "type": "->",
        "args": [
            "ExampleTest",
            "testExample"
        ]
    },
    {
        "file": "\/var\/www\/html\/vendor\/phpunit\/phpunit\/src\/Metadata\/Api\/DataProvider.php",
        "line": 61,
        "function": "dataProvidedByTestWithAnnotation",
        "class": "PHPUnit\\Metadata\\Api\\DataProvider",
        "object": {},
        "type": "->",
        "args": [
            "ExampleTest",
            "testExample"
        ]
    },
    {
        "file": "\/var\/www\/html\/vendor\/phpunit\/phpunit\/src\/Metadata\/Api\/DataProvider.php",
        "line": 259,
        "function": "throwError",
        "args": [
            2,
            "Uninitialized string offset 0",
            "\/var\/www\/html\/vendor\/phpunit\/phpunit\/src\/Metadata\/Api\/DataProvider.php",
            259
        ]
    }
]

from phpunit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.