Page 1 of 2
Simpletest woes
Posted: Mon Dec 22, 2008 7:38 pm
by josh
Anyone noticing simpletest supresses typecasting errors? Anyone know whats involved in patching this / the easiest workarounds / alternative test frameworks?
Re: Simpletest woes
Posted: Mon Dec 22, 2008 8:01 pm
by allspiritseve
You can file a bug report here:
http://sourceforge.net/projects/simpletest/
Lastcraft is the person you want to talk to.
Re: Simpletest woes
Posted: Mon Dec 22, 2008 8:27 pm
by josh
Hmm well I'm not sure if its a bug per se. To clarify I think it only happens if a test fails, maybe its something you can override in the reporter class? I haven't looked into it in too much detail but its caught me off guard on a few occasions now
Re: Simpletest woes
Posted: Sun Dec 28, 2008 10:49 pm
by Ambush Commander
jshpro2, could you post a small test-case for your bug here? That would really help.

Re: Simpletest woes
Posted: Mon Jan 05, 2009 9:59 am
by lastcraft
Hi...
jshpro2 wrote:Anyone noticing simpletest supresses typecasting errors? Anyone know whats involved in patching this / the easiest workarounds / alternative test frameworks?
Could you post a sample test?
SimpleTest has it's own error handler, but one that won't pick up E_STRICT errors (due to PHP 4 compatibility). You can get around this by pulling the SVN code, which is PHP 5 only and E_STRICT compliant.
assertEqual() does not throw on type errors. If you want type checking too, use assertIdentical().
yours, Marcus
Re: Simpletest woes
Posted: Mon Jan 05, 2009 10:49 am
by Eran
Marcus, is the trunk the PHP 5 compliant branch? you should push this on the site, I've been waiting for a PHP5 strict version of SimpleTest for ages.
Re: Simpletest woes
Posted: Mon Jan 05, 2009 12:00 pm
by Ambush Commander
The trunk is PHP 5 E_STRICT compliant, yep. It has been for a while, actually.
Re: Simpletest woes
Posted: Tue Jan 06, 2009 1:14 am
by josh
Ive been meaning to put together a test case for this, like I said its intermittent, I've kind of learned to live with it but next time it happens ( happens every few days ) I'll try to remember to cool down from my bug stomping session and figure out how to replicate this. I think it may be syntax errors ( "trying to invoke methods on non objects" ), maybe there's no way to catch those kinds of errors? If I remember I am getting a PHP error and no bar red OR green, and no type hinting errors, its as if simpletest is correctly catching the type error but then PHP is crashing out before ST can output the other error to the screen
Re: Simpletest woes
Posted: Tue Jan 06, 2009 1:17 am
by Ambush Commander
It sounds like you're getting a segfault or exit is being called prematurely. Can you grep for exit/quit in your source code? Also check your logs.
Re: Simpletest woes
Posted: Tue Jan 06, 2009 4:21 am
by josh
Although trivial, this illustrates the problem, like I said I've learned to deal with it, but its counter-intuitive because you sit there going "Well of course $foo is an instance of MyFoo or I would have gotten an error". I can affirmatively say it's gotten me more than once now. ( Other than that the library is great! ). Maybe also its impossible to trap "Fatal Errors"?
"Fatal error: Call to a member function bar() on a non-object in C:\Users\Josh\Desktop\ne8\metator\application\tests\Code\testTest.php on line 18"
Code: Select all
<?php
class testTest extends UnitTestCase
{
function testMyTest()
{
MyTest::acceptFoo( NULL );
}
}
class MyFoo
{
public function bar() {}
}
class MyTest
{
public function acceptFoo( MyFoo $foo )
{
$foo->bar();
}
}
Re: Simpletest woes
Posted: Tue Jan 06, 2009 4:56 am
by Eran
It's definitely impossible to trap fatal errors, since by definition they are fatal to the script (kill it).
Re: Simpletest woes
Posted: Tue Jan 06, 2009 6:28 am
by josh
Yeah, but simpletest could catch the typecast error and throw its own fatal error first

Re: Simpletest woes
Posted: Wed Jan 07, 2009 7:06 pm
by allspiritseve
Hmm... I wonder if I'm getting the same thing. I've been finding if I have syntax errors in the class I'm testing, the script quits at "All Tests" and doesn't show anything beyond that. It is quite annoying. I downloaded the latest trunk code, but that still doesn't change anything. Any ideas?
Code: Select all
class PaginationHelperTest extends UnitTestCase {
function setUp() {
$this->helper = new PaginationHelper();
}
function testDoNothing() {
$this->assertTrue (true);
}
}
Re: Simpletest woes
Posted: Wed Jan 07, 2009 8:44 pm
by josh
Sounds different, never had that problem. Sounds like you have error reporting turned off
Re: Simpletest woes
Posted: Wed Jan 07, 2009 8:54 pm
by allspiritseve
jshpro2 wrote:Sounds different, never had that problem. Sounds like you have error reporting turned off
I don't... errors for the test case show up, but not the class under test.