[TYPO3-core] RFC #15020: Enhancement of t3lib_div::testInt

Christian Futterlieb christian.futterlieb at agenturamwasser.ch
Thu Jul 8 12:14:50 CEST 2010


> This discussion would be far more easy if we just cover all those
> testInt() edge case with some simple unit tests. Anyone wants to go
> ahead? Otherwise I'll probably do this evening ...

Hi core list

I'm not experienced in unit testing, but I'll give it a try.. Please see
the attached patch.

While playing around I found out, that testInt('01234') returns FALSE,
even tough this is an integer. Regardless, I added the value to the
'invalid' dataProvider, assuming that the current version works correct.

Following version of testInt would be much faster, and react (IMO)
correct on above problem.

function testInt ($var) {
    if (is_numeric($var)) {
        return (int) $var == $var;
    }
    return FALSE;
}

I hope I did not overshoot :)

Regards Christian
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 15020_unitTest.diff
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20100708/3395d5ec/attachment.asc>


More information about the TYPO3-team-core mailing list