Search code examples
phpterminalphpunitvar-dump

var_dump() output shortned - phpunit or my terminal?


I am writing tests in phpunit and every now and then I have to do a

var_dump($this->getRequest()->getBody())

which is all fine and dandy, however in the terminal when I do:

phpunit application/modules/account/ContactControllerTest.php

I get the output of:

string(2319) "<!DOCTYPE html><!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]--><!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"><![endif]--><!--[if IE 8]><html class="no-js lt-ie9"><![endif]--><!--[if gt IE 8]><!--><html class="no-js"><!--<![endif]--><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" ><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" ><meta name="apple-mobile-web-app-capable" content="yes" "...
...

That is not 2319 characters.... it is more like 516.... where is the rest of my content? Yes my terminal has unlimited scrolling turned on.


Solution

  • What you are looking for is:

    xdebug.var_display_max_data

    Type: integer, Default value: 512

    Controls the maximum string length that is shown when variables are displayed with either xdebug_var_dump(), xdebug.show_local_vars or through Function Trace

    If you change that setting to -1 you will get your full dump back.