Skip to content

Commit 7dbc9fd

Browse files
committed
Add body, properties and headers to client's message constructor.
fixes php-enqueue#88
1 parent 2dfef3b commit 7dbc9fd

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

pkg/enqueue/Client/Message.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ class Message
7878
*/
7979
private $properties = [];
8080

81-
public function __construct()
81+
public function __construct($body = '', array $properties = [], array $headers = [])
8282
{
83-
$this->headers = [];
84-
$this->properties = [];
83+
$this->body = $body;
84+
$this->headers = $headers;
85+
$this->properties = $properties;
86+
8587
$this->scope = static::SCOPE_MESSAGE_BUS;
8688
}
8789

pkg/enqueue/Tests/Client/MessageTest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,22 @@
77

88
class MessageTest extends TestCase
99
{
10-
public function testCouldBeConstructedWithoutAnyArguments()
10+
public function testCouldBeConstructedWithoutArguments()
1111
{
12-
new Message();
12+
$message = new Message();
13+
14+
$this->assertSame('', $message->getBody());
15+
$this->assertSame([], $message->getProperties());
16+
$this->assertSame([], $message->getHeaders());
17+
}
18+
19+
public function testCouldBeConstructedWithOptionalArguments()
20+
{
21+
$message = new Message('theBody', ['barProp' => 'barPropVal'], ['fooHeader' => 'fooHeaderVal']);
22+
23+
$this->assertSame('theBody', $message->getBody());
24+
$this->assertSame(['barProp' => 'barPropVal'], $message->getProperties());
25+
$this->assertSame(['fooHeader' => 'fooHeaderVal'], $message->getHeaders());
1326
}
1427

1528
public function testShouldAllowGetPreviouslySetBody()

0 commit comments

Comments
 (0)