Skip to content

Commit 15fb662

Browse files
committed
Action no longer sets an ActionID internally
1 parent 20397e7 commit 15fb662

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

src/Protocol/Action.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ public function __construct($action, array $parts = array())
1010
{
1111
$this->action = $action;
1212
$this->parts = $parts;
13-
14-
$this->parts['ActionID'] = (string)mt_rand();
1513
}
1614

1715
public function getMessageSerialized()

tests/Protocol/ActionTest.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,48 @@
11
<?php
22

33
use Clue\React\Ami\Protocol\Action;
4+
45
class ActionTest extends TestCase
56
{
7+
public function testIdDefaultsToNull()
8+
{
9+
$action = new Action('name');
10+
11+
$this->assertNull($action->getActionId());
12+
}
13+
14+
public function testIdCanBeSet()
15+
{
16+
$action = new Action('name', array('ActionID' => '123'));
17+
18+
$this->assertEquals('123', $action->getActionId());
19+
}
20+
621
public function testSerializeSimple()
722
{
823
$action = new Action('name');
9-
$id = $action->getActionId();
1024

11-
$this->assertEquals("Action: name\r\nActionID: $id\r\n\r\n", $action->getMessageSerialized());
25+
$this->assertEquals("Action: name\r\n\r\n", $action->getMessageSerialized());
1226
}
1327

1428
public function testSerializeKeySingle()
1529
{
1630
$action = new Action('name', array('Key' => 'Value'));
17-
$id = $action->getActionId();
1831

19-
$this->assertEquals("Action: name\r\nKey: Value\r\nActionID: $id\r\n\r\n", $action->getMessageSerialized());
32+
$this->assertEquals("Action: name\r\nKey: Value\r\n\r\n", $action->getMessageSerialized());
2033
}
2134

2235
public function testSerializeKeyMultipleValues()
2336
{
2437
$action = new Action('name', array('Key' => array('Value1', 'Value2')));
25-
$id = $action->getActionId();
2638

27-
$this->assertEquals("Action: name\r\nKey: Value1\r\nKey: Value2\r\nActionID: $id\r\n\r\n", $action->getMessageSerialized());
39+
$this->assertEquals("Action: name\r\nKey: Value1\r\nKey: Value2\r\n\r\n", $action->getMessageSerialized());
2840
}
2941

3042
public function testSerializeKeyMultipleKeyValues()
3143
{
3244
$action = new Action('name', array('Variables' => array('first' => 'on', 'second' => 'off')));
33-
$id = $action->getActionId();
3445

35-
$this->assertEquals("Action: name\r\nVariables: first=on\r\nVariables: second=off\r\nActionID: $id\r\n\r\n", $action->getMessageSerialized());
46+
$this->assertEquals("Action: name\r\nVariables: first=on\r\nVariables: second=off\r\n\r\n", $action->getMessageSerialized());
3647
}
3748
}

0 commit comments

Comments
 (0)