Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > it.comp.www.php > #22292 > unrolled thread
| Started by | alex <1j9448a02@lnx159sneakemail.com.invalid> |
|---|---|
| First post | 2018-10-13 13:35 +0200 |
| Last post | 2018-10-13 13:42 +0200 |
| Articles | 2 — 1 participant |
Back to article view | Back to it.comp.www.php
phpunit: debuggare un'Exception alex <1j9448a02@lnx159sneakemail.com.invalid> - 2018-10-13 13:35 +0200
Re: phpunit: debuggare un'Exception alex <1j9448a02@lnx159sneakemail.com.invalid> - 2018-10-13 13:42 +0200
| From | alex <1j9448a02@lnx159sneakemail.com.invalid> |
|---|---|
| Date | 2018-10-13 13:35 +0200 |
| Subject | phpunit: debuggare un'Exception |
| Message-ID | <ppslaj$1jtq$1@gioia.aioe.org> |
$ cat XTest.php
<?php
class XTest extends PHPUnit\Framework\TestCase {
function testY(): void {
throw new Ex;
}
}
class Ex extends \Exception {
function __toString() {
return
parent::__toString() . PHP_EOL .
'Altri dati di debug...'
;
}
}
$ vendor/bin/phpunit XTest.php
blablabla...
1) XTest::testY
Ex:
/tmp/tmp.ZyqmeJemwx/XTest.php:5
altri blablabla inutili...
Non è che la cosa mi dice molto.
Io vorrei, oltre ai blablabla, un output di questo tipo:
Ex in /tmp/tmp.ZyqmeJemwx/mio-script.php:3
Stack trace:
#0 {main}
Altri dati di debug...
che in genere si ottiene così:
<?php // mio-script.php
try {
throw new Ex;
}catch(Ex $ex){
// IL MIO GESTORE
echo $ex;
exit(1);
}
Non è che con phpunit si possano configurare dei catch personalizzati?
[toc] | [next] | [standalone]
| From | alex <1j9448a02@lnx159sneakemail.com.invalid> |
|---|---|
| Date | 2018-10-13 13:42 +0200 |
| Message-ID | <ppslng$1kfn$1@gioia.aioe.org> |
| In reply to | #22292 |
Il 13/10/2018 13:35, alex ha scritto: > ... In pratica dirgli di visualizzare le eccezioni sotto forma di stringa, sfruttando appunto il magic-method __toString()
[toc] | [prev] | [standalone]
Back to top | Article view | it.comp.www.php
csiph-web