Re: Re: Insult my code!

From: Date: Mon, 12 Oct 2009 10:21:41 +0000
Subject: Re: Re: Insult my code!
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-298854@lists.php.net to get a copy of this message
2009/10/11 Eric Bauman <baumane@livejournal.dk>: > As before, please feel free to insult my code. ;-) Any and all feedback is > of course most appreciated. I know you're more concerned with structure, but your checkInt() method is arguably buggy/has an un-noted assumption. It accepts ints formatted as ints and strings, but not floats: <?php require_once 'PHPUnit/Framework/TestCase.php'; require_once 'BankModel.php'; class BankModelTest extends PHPUnit_Framework_TestCase { function testSetBalanceAcceptsInts() { $fixture = new BankModel(); $int = 1351236; $this->assertNull( $fixture->setBalance($int) ); } function testSetBalanceAcceptsFloats() { $fixture = new BankModel(); $float = (float)1351236; $this->assertNull( $fixture->setBalance($float) ); } function testSetBalanceAcceptsStrings() { $fixture = new BankModel(); $string = (string)1351236; $this->assertNull( $fixture->setBalance($string) ); } }

« previous php.general (#298854) next »