Problems with yii2-debug when testing


(Paulo) #1

Hi,

I have some problems when test my Yii2 open source project for community:

The problems is when the test finished an error message appear after all related to yii2-debug:

[backend\tests]: tests from /usr/share/nginx/html/backend


Backend\tests.functional Tests (1) -------------------------
✔ LoginCest: Login user (8.83s)
------------------------------------------------------------

Backend\tests.unit Tests (0) -------------------------------
------------------------------------------------------------


Time: 17.34 seconds, Memory: 36.00MB

OK (25 tests, 61 assertions)
PHP Fatal error:  Uncaught Error: Call to a member function getRequest() on null in /usr/share/nginx/html/vendor/yiisoft/yii2-debug/src/panels/RequestPanel.php:59
Stack trace:
#0 /usr/share/nginx/html/vendor/yiisoft/yii2-debug/src/LogTarget.php(61): yii\debug\panels\RequestPanel->save()
#1 /usr/share/nginx/html/vendor/yiisoft/yii2-debug/src/LogTarget.php(136): yii\debug\LogTarget->export()
#2 /usr/share/nginx/html/vendor/yiisoft/yii2/log/Dispatcher.php(189): yii\debug\LogTarget->collect(Array, true)
#3 /usr/share/nginx/html/vendor/yiisoft/yii2/log/Logger.php(177): yii\log\Dispatcher->dispatch(Array, true)
#4 [internal function]: yii\log\Logger->flush(true)
#5 {main}
  thrown in /usr/share/nginx/html/vendor/yiisoft/yii2-debug/src/panels/RequestPanel.php on line 59
make: *** [test] Error 255

Can anyone help me with this?

On travis the same error happen and have a full log:
https://travis-ci.com/prsolucoes/yii2-app-advanced/jobs/225024359#L5422

Thanks.


(Alexander Makarov) #2

Does that happen with the latest version of Yii / Debug toolbar?


(Paulo) #3

Hi,

Sure. See my composer.json:

"minimum-stability": "stable",
"require": {
	"php": ">=5.4.0",
	"yiisoft/yii2": "2.0.25",
	"yiisoft/yii2-bootstrap": "2.0.10",
	"yiisoft/yii2-swiftmailer": "2.1.2",
	"yiisoft/yii2-jui": "2.0.7",
	"bower-asset/admin-lte": "2.4.17",
	"bower-asset/font-awesome": "4.7.0",
	"bower-asset/html5shiv": "3.7.3",
	"bower-asset/jquery": ">=1.9.0 <4.0.0",
	"bower-asset/jquery-slimscroll": "1.3.8",
	"bower-asset/js-cookie": "2.2.1",
	"bower-asset/lightbox2": "2.11.1",
	"kartik-v/yii2-grid": "3.3.2",
	"kartik-v/yii2-export": "1.4.0",
	"yii2-starter-kit/yii2-file-kit": "2.0.1",
	"intervention/image": "2.5.0",
	"vova07/yii2-imperavi-widget": "2.0.11",
	"kartik-v/yii2-widget-datepicker": "1.4.7",
	"kartik-v/yii2-datecontrol": "1.9.7",
	"ausi/slug-generator": "1.1.0",
	"lcobucci/jwt": "3.3.1"
},
"require-dev": {
	"yiisoft/yii2-debug": "2.1.7",
	"yiisoft/yii2-gii": "2.1.1",
	"yiisoft/yii2-faker": "2.0.4",
	"codeception/base": "3.0.0",
	"codeception/verify": "1.1.0",
	"phpunit/phpunit": "6.5.14",
	"symfony/browser-kit": "4.3.3"
},

Thanks.


(Paulo) #4

Hi

Solved it. Removed bootstrap debug item from main config and put inside if like others.

if (!YII_ENV_TEST) {
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
    ];
}

Thanks.