Re: Re: Insult my code!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/10/11 Eric Bauman <baumane@xxxxxxxxxxxxxx>:

> 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) );
    }
}

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux