1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class ShippingPackageTest extends SapphireTest{ |
4
|
|
|
|
5
|
|
|
function testPackages(){ |
|
|
|
|
6
|
|
|
|
7
|
|
|
$p = new ShippingPackage(25, array('depth' => 4, 'height' => 23,'width' => 12)); |
8
|
|
|
$this->assertEquals($p->height(),23); |
|
|
|
|
9
|
|
|
$this->assertEquals($p->width(),12); |
|
|
|
|
10
|
|
|
$this->assertEquals($p->depth(),4); |
|
|
|
|
11
|
|
|
$this->assertEquals($p->weight(),25); |
|
|
|
|
12
|
|
|
|
13
|
|
|
$p = new ShippingPackage(25.3, array('h' => 23.7, 'd' => 4, 'w' => 12.344,)); |
14
|
|
|
$this->assertEquals($p->height(),23.7); |
|
|
|
|
15
|
|
|
$this->assertEquals($p->width(),12.344); |
|
|
|
|
16
|
|
|
$this->assertEquals($p->depth(),4); |
|
|
|
|
17
|
|
|
$this->assertEquals($p->weight(),25.3); |
|
|
|
|
18
|
|
|
|
19
|
|
|
$p = new ShippingPackage(1, array(3,4,5)); |
20
|
|
|
$this->assertEquals($p->height(),3); |
|
|
|
|
21
|
|
|
$this->assertEquals($p->width(),4); |
|
|
|
|
22
|
|
|
$this->assertEquals($p->depth(),5); |
|
|
|
|
23
|
|
|
$this->assertEquals($p->volume(),60); |
|
|
|
|
24
|
|
|
|
25
|
|
|
$p = new ShippingPackage(13, array(1,1,2.5), array('shape' => 'cylinder')); |
26
|
|
|
$this->assertEquals($p->height(),1); |
|
|
|
|
27
|
|
|
$this->assertEquals($p->depth(),2.5); |
|
|
|
|
28
|
|
|
$this->assertEquals($p->weight(),13); |
|
|
|
|
29
|
|
|
$this->assertEquals($p->volume(),2.5); |
|
|
|
|
30
|
|
|
|
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
} |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.