refine more exception classes in port management
[racktables] / tests / PortTriggerTest.php
1 <?php
2
3 // We should prohibit reusing an l2address on different objects
4 class PortTriggerTest extends PHPUnit_Framework_TestCase
5 {
6 public function setUp ()
7 {
8 $this->object1_id = commitAddObject ('unit test object 1', NULL, 1, NULL);
9 $this->object2_id = commitAddObject ('unit test object 2', NULL, 1, NULL);
10 $this->port1_1_id = commitAddPort ($this->object1_id, 'port 1', '1-24', 'label 1', 'aabbccddee01');
11 $this->port1_2_id = commitAddPort ($this->object1_id, 'port 2', '1-24', 'label 2', 'aabbccddee02');
12 $this->port2_1_id = commitAddPort ($this->object2_id, 'port 1', '1-24', 'label 1', 'aabbccddee03');
13 }
14
15 public function tearDown ()
16 {
17 commitDeleteObject ($this->object1_id);
18 commitDeleteObject ($this->object2_id);
19 }
20
21 /**
22 * @group small
23 */
24 public function testUniqueMacAddSame()
25 {
26 $port1_3_id = commitAddPort ($this->object1_id, 'port 3', '1-24', 'label 3', 'aabbccddee01');
27 }
28
29 /**
30 * @group small
31 */
32 public function testUniqueMacUpdateSame()
33 {
34 commitUpdatePort ($this->object1_id, $this->port1_2_id, 'port 2', '1-24', 'label 1', 'aabbccddee01', '');
35 }
36
37 /**
38 * @group small
39 * @expectedException InvalidArgException
40 */
41 public function testUniqueMacAdd()
42 {
43 $port2_2_id = commitAddPort ($this->object2_id, 'port 2', '1-24', 'label 1', 'aabbccddee01');
44 }
45
46 /**
47 * @group small
48 * @expectedException InvalidArgException
49 */
50 public function testUniqueMacUpdate()
51 {
52 commitUpdatePort ($this->object2_id, $this->port2_1_id, 'port 1', '1-24', 'label 1', 'aabbccddee01', '');
53 }
54 }