mrtnzlml-archive / testbench

:green_apple: Simple integration testing tool for Nette applications
http://zlml.cz/jednoduche-testovani-pro-uplne-kazdeho
41 stars 13 forks source link

PresenterTester::checkAction doesn't fail when Latte throws Exception #3

Closed hantc closed 9 years ago

hantc commented 9 years ago

For example, when I try to put non-existent component into latte file - e.g. {control nonExistentComponent}, test case should fail. But it passes despite of Latte's thrown InvalidArgumentException.

mrtnzlml commented 9 years ago

Can you please provide more details about this issue? I am getting this error:

E_USER_ERROR: Exception in Nette\Bridges\ApplicationLatte\Template::__toString(): Component with name 'nonExistentComponent' does not exist. in /var/www/html/testbench/vendor/nette/component-model/src/ComponentModel/Container.php:162

It's not ideal but test result is red and that's the important part. It's possible that you have disabled error reporting or something like that? Or maybe are you able to write failing test so I can fix it?

hantc commented 9 years ago

I tried it from the phpstorm terminal, and run run-tests.bat. It says (btw is possible xdebug must be loaded?): PHP startup error: Failed loading C:\xampp\php\ext\php_xdebug.dll (note that PHP CLI generates better error messages)

I tried it second time in "Command line" which threw an error, but not about non existing component, but about doctrine. -- FAILED: presenters\Front\CustomerPresenterTest.phpt [method=testRenderSignUp] Exited with error code 255 (expected 0) E_USER_ERROR: Exception in Nette\Bridges\ApplicationLatte\Template::__toString(): An exception occured in driver: could not find driver in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\eshop\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\AbstractMySQLDriver.php:115

Sorry, I'm a bit confused now.


EDIT: Bad paste of second error message.

mrtnzlml commented 9 years ago

Yeah, it's wrong path to the xdebug extension (see https://github.com/mrtnzlml/testbench/blob/master/tests/php.ini). Unfortunatelly I don't have Windows environment anymore so I cannot fix it correctly. But to be honest, I am not sure why I wrote this config file with xdebug. You should set up your own ini file and run something like this: ./vendor/bin/tester tests/ -c tests/php-custom.ini. Or if you are able to, you can fix this configuration via pull request. Otherwise I will probably delete these Win based files, because I'm no longer able to maintain this files.

hantc commented 9 years ago

But bad path to xdebug didn't cause it. I tried my own php.ini and testes with latte exception still passes.

But strange thing is, if I run it in browser (ctrl+shift+f10 opens browser with url http://localhost:63342/eshop/tests/presenters/Front/CustomerPresenterTest.phpt), it finally shows the error: E_USER_ERROR: Exception in Nette\Bridges\ApplicationLatte\Template::__toString(): Component with name 'nonExistentComponent' does not exist.

But still can't figure out why this error doesn't show up when running test from cmd.

hantc commented 9 years ago

Got it, finally found out it was cache problem (surprisingly it didn't help when I tried it for the first time, but I could do a mistake when erasing tests/temp). So, solution could be flushing temp in run-tests.bat as a first command before running tests.

hantc commented 9 years ago

@ECHO OFF rmdir temp /s /q SET BIN_TARGET=%~dp0/../vendor/nette/tester/Tester/tester.php php "%BIN_TARGET%" -c php.ini ./../tests