Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

276
Visualizações
What could cause PHPUnit to not print very large error messages?

This seems to happen only on my system. Nobody else could reproduce it. If the error's message is too large (about 65k bytes in my case) nothing gets printed on screen. I'm using PHP 7.1.3 on Windows 7, with the default php.ini (memory limit set to 8gb) and the default PHPUnit 6.0.13 configuration. The error does not appear in both prompt and powershell.

<?php

use PHPUnit\Framework\Constraint\Constraint;
use PHPUnit\Framework\TestCase;

class MyConstraint extends Constraint
{
    protected $expected;

    function __construct($expected){
        parent::__construct();
        $this->expected = $expected;
    }

    protected function matches($actual){
        return false;
    }

    function failureDescription($other): string{
        return "desc";
    }

    function toString(){
        return "description";
    }

    function additionalFailureDescription($other): string{
        return str_repeat("x", 100000);
        // If set to a smaller dump, error will appear
        // some people I asked to try could dump one million
        // bytes without problems, while I can't print more
        // than about 50k
    }
}

class SomeTest extends TestCase
{
    function testBigDump(){
        TestCase::assertThat("irrelevant", new MyConstraint("irrelevant"));
    }
}

?>

And this is what I get on screen:

PHPUnit 6.0.13 by Sebastian Bergmann and contributors.

Runtime: PHPDBG 7.1.3 Configuration: ..............

F 1 / 1 (100%)

Time: 361 ms, Memory: 6.00MB

There was 1 failure:

1) SomeTest::testBigDump

                             <------- Notice no error description here

FAILURES! Tests: 1, Assertions: 1, Failures: 1.

Do you have any idea what could cause this? Thank you in advance.

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Something in your configuration is running phpunit test via phpdbg

I've recreated this issue, attempting to replicate the environment as much as possible using a Windows 7 VM.

The clue was the Runtime: PHPDBG line in your dump. Apparently something about the phpdbg runtime prevents large buffers from working correctly. See my output below, both the initial output when run via phpdbg.exe (missing test description) and then when run via php.exe (truncated, obviously):

C:\project>phpdbg -r phpunit-6.1.0.phar -v test.php
[Welcome to phpdbg, the interactive PHP debugger, v0.5.0]
To get help using phpdbg type "help" and press enter
[Please report bugs to <http://bugs.php.net/report.php>]
PHPUnit 6.1.0 by Sebastian Bergmann and contributors.

Runtime:       PHPDBG 7.1.4

F                                                                   1 / 1 (100%)


Time: 99 ms, Memory: 22.00MB

There was 1 failure:

1) SomeTest::testBigDump

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
[Script ended normally]

C:\project>php phpunit-6.1.0.phar test.php
PHPUnit 6.1.0 by Sebastian Bergmann and contributors.

F                                                                   1 / 1 (100%)


Time: 109 ms, Memory: 8.00MB

There was 1 failure:

1) SomeTest::testBigDump
Failed asserting that desc.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
----- Snip -----
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda