Esempio n. 1
0
 public function testAdd()
 {
     $maths = new maths();
     $this->assertEquals(3, $maths->add(1, 2));
     $this->assertEquals(2, $maths->add(0, 2));
     $this->assertEquals(-2, $maths->add(0, -2));
 }
Esempio n. 2
0
class maths extends whatever
{
    private $number;
    public function setInitialNumber($number)
    {
        $this->number = $number;
    }
    public function add($num)
    {
        $this->number += $num;
    }
    public function subtract($num)
    {
        $this->number -= $num;
    }
    public function multiply($num)
    {
        $this->number *= $num;
    }
    public function getFinalNumber()
    {
        return $this->number;
    }
}
$m = new maths();
$m->setInitialNumber(5);
$m->add(4);
$m->subtract(1);
$m->multiply(2);
$m->add(2);
echo $m->getFinalNumber();