From: SourceForge.net <no...@so...> - 2008-08-21 08:04:35
|
Bugs item #2034744, was opened at 2008-08-01 08:35 Message generated for change (Comment added) made by airhead You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=547455&aid=2034744&group_id=76550 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Unit test framework Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: assertEqual does not work Initial Comment: win xp sp4; mozilla firefox; simpletest version 1.0.1; php 5.2.5; my test: function test_get_charset() { $this->assertEqual("utf-8", get_charset(array())); } my utils: function get_charset($arr) { return 0; //if I change this to 1. test fails. } result: 1/1 test cases complete: 1 passes, 0 fails and 0 exceptions. email: sen...@ma... ---------------------------------------------------------------------- Comment By: Peter Bex (airhead) Date: 2008-08-21 08:04 Message: Logged In: YES user_id=5398 Originator: NO This is not a bug; you'll need to use assertIdentical, which uses typesafe comparison. With assertEqual, it uses the type unsafe comparison ==. assertIdentical uses the === comparison operator. With the type unsafe comparison, PHP sees you're comparing a string to a number and then it coerces the string to a number. intval("utf-8") results in 0, so the test succeeds because 0 is equal to 0. HTH ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=547455&aid=2034744&group_id=76550 |