phpunit icon indicating copy to clipboard operation
phpunit copied to clipboard

PHPT test has unexpected "Standard input code:" added to its output

Open dbrumann opened this issue 3 years ago • 0 comments

Q A
PHPUnit version 9.5.20
PHP version 8.1.5
Installation Method Composer

Summary

I have a some phpt-tests. In Github Actions they produce the expected output and work fine, but locally the produce different output. The output contains the added line "Standard input code:5:\n" with the number changing between tests. The bug occured, when we switched from phive to using composer. Here is a composer info output from my reproducer:

composer info | sort

doctrine/instantiator              1.4.1   A small, lightweight utility to instantiate objects in PHP without invoking their constructors
myclabs/deep-copy                  1.11.0  Create deep copies (clones) of your objects
nikic/php-parser                   v4.13.2 A PHP parser written in PHP
phar-io/manifest                   2.0.3   Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                    3.2.1   Library for handling version information and constraints
phpdocumentor/reflection-common    2.2.0   Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock  5.3.0   With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded ...
phpdocumentor/type-resolver        1.6.1   A PSR-5 based resolver of Class names, Types and Structural Element Names
phpspec/prophecy                   v1.15.0 Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage          9.2.15  Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator          3.0.6   FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker                3.1.1   Invoke callables with a timeout
phpunit/php-text-template          2.0.4   Simple template engine.
phpunit/php-timer                  5.0.3   Utility class for timing
phpunit/phpunit                    9.5.20  The PHP Unit Testing framework.
sebastian/cli-parser               1.0.1   Library for parsing CLI options
sebastian/code-unit                1.0.8   Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup 2.0.3   Looks up which function or method a line of code belongs to
sebastian/comparator               4.0.6   Provides the functionality to compare PHP values for equality
sebastian/complexity               2.0.2   Library for calculating the complexity of PHP code units
sebastian/diff                     4.0.4   Diff implementation
sebastian/environment              5.1.4   Provides functionality to handle HHVM/PHP environments
sebastian/exporter                 4.0.4   Provides the functionality to export PHP variables for visualization
sebastian/global-state             5.0.5   Snapshotting of global state
sebastian/lines-of-code            1.0.3   Library for counting the lines of code in PHP source code
sebastian/object-enumerator        4.0.4   Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector         2.0.4   Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context        4.0.4   Provides functionality to recursively process PHP variables
sebastian/resource-operations      3.0.3   Provides a list of PHP built-in functions that operate on resources
sebastian/type                     3.0.0   Collection of value objects that represent the types of the PHP type system
sebastian/version                  3.0.2   Library that helps with managing the version number of Git-hosted PHP projects
symfony/polyfill-ctype             v1.25.0 Symfony polyfill for ctype functions
theseer/tokenizer                  1.2.1   A small library for converting tokenized PHP source code into XML and potentially other formats
webmozart/assert                   1.10.0  Assertions to validate method input/output with nice error messages.

Current behavior

Locally phpt-tests contain unexpected output "Standard input code:..."

How to reproduce

I have created a minimal reproducer: https://github.com/dbrumann/phpt-reproducer

Test file (tests/Example.phpt):

--TEST--
Reproduce phpt adding output locally
--FILE--
<?php

var_dump('test');

--EXPECT--
string(4) "test"

phpunit.xml:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
    bootstrap="vendor/autoload.php"
    colors="true"
>
    <testsuites>
        <testsuite name="phpt">
            <directory suffix=".phpt">./tests</directory>
        </testsuite>
    </testsuites>
    <coverage>
        <include>
            <directory>./src</directory>
        </include>
    </coverage>
</phpunit>

Expected behavior

Test passes, but instead I get an error because of the added output:

1) /Users/dbr/Projects/phpt-reproducer/tests/Example.phpt
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'string(4) "test"'
+'Standard input code:3:\n
+string(4) "test"'

dbrumann avatar May 20 '22 13:05 dbrumann