Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.2.0

Bug #14802 Unit test failures eat up memory
Submitted: 2008-10-15 22:14 UTC
From: doconnor Assigned: beni
Status: Closed Package: Net_LDAP2 (version CVS)
PHP Version: 5.2.6 OS:
Roadmaps: 2.0.0    
Subscription  


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 10 + 30 = ?

 
 [2008-10-15 22:14 UTC] doconnor (Daniel O'Connor)
Description: ------------ Whenever there's a case where a pear error is returned; PHPUnit will try to print_r() it if it is in an assertation. This makes the unit test fall over after eating up loads of memory on printing the backtrace. In particular Net_LDAP2_Test::testCheckLDAPExtension() Test script: --------------- # Make sure you don't have the ldap extension anywhere on your system phpunit Net_LDAP2_Test Expected result: ---------------- Graceful failure Actual result: -------------- Out of memory

Comments

 [2008-10-15 22:17 UTC] doconnor (Daniel O'Connor)
This just changes the use of some of the PHPUnit apis for more low level checking. It is far less helpful in terms of the error messages produced; but... Other approaches may include simply writing custom assertations. public function assertExpectedError($foo, $expected_error_message, $debug) { if (!$foo instanceOf PEAR_Error) { $this->fail("Expected an error object"); } $this->assertSame($expected_error_message, $foo->getMessage(), $debug); }
 [2008-10-16 06:34 UTC] beni (Benedikt Hallinger)
Thank you for submitting this patch! A short question (without looked in the patch code), there is the following code in function connect(): // Check extension if (true !== Net_LDAP2::checkLDAPExtension()) { $this->markTestSkipped('PHP LDAP extension not found or not loadable. Skipped Test.'); } It was planned, that because each function requiring LDAP also needs a connect to a server, the connect() function will abort the test with "skipped". I am certainly sure i tested this bit of code as i wrote it, so i wonder why it fails now.
 [2008-10-16 07:49 UTC] doconnor (Daniel O'Connor)
The one test I changed explicitly dealt with "when I fail, assert I get true or a Net_LDAP2_Error" ; but it got a PEAR_Error instead. That makes PHPUnit get unhappy and try to render itself out, which then eats up memory.
 [2008-10-16 08:18 UTC] beni (Benedikt Hallinger)
Hello! I think i fixed the issue, but in a deeper level. The issue was not in the test itself but in the checkLDAPExtension() method. Since the method is called statically, PEAR does not know which error class it should use. Because of this, checkLDAPExtension() returns a PEAR error when it should return a Net_LDAP_Error.
 [2008-10-16 08:19 UTC] beni (Benedikt Hallinger)
Please check out the latest CVS and test if the issue is fixed for you now.
 [2008-10-18 03:36 UTC] doconnor (Daniel O'Connor)
Looks OK now