コード例 #1
0
 public function test_constructor_withProperParams_populateBodyAndPropertiesProperly()
 {
     $correlationId = uniqid();
     $contentType = MessageInterface::CONTENT_TYPE_PLAIN_TEXT;
     $properties = [MessageInterface::PROPERTY_CORRELATION_ID => $correlationId, MessageInterface::PROPERTY_CONTENT_TYPE => $contentType];
     $message = new RpcResponseMessage('', $properties);
     // timestamp
     $this->assertFalse(empty($message->getTimestamp()), 'Empty timestamp!');
     $this->assertTrue(is_int($message->getTimestamp()), 'Timestamp is not int!');
     // type
     $this->assertFalse(empty($message->getType()), 'Empty type!');
     $this->assertEquals(MessageInterface::TYPE_RPC_RESPONSE, $message->getType(), sprintf('Type is not "%s"!', MessageInterface::TYPE_RPC_RESPONSE));
     // correlation id
     $this->assertFalse(empty($message->getCorrelationId()), 'Empty correlation id!');
     $this->assertEquals($correlationId, $message->getCorrelationId());
     // content type
     $this->assertFalse(empty($message->getContentType()), 'Empty content type!');
     $this->assertEquals(MessageInterface::CONTENT_TYPE_PLAIN_TEXT, $message->getContentType(), sprintf('Content type is not "%s"', $contentType));
     // body
     $this->assertTrue(empty($message->getBody()), 'Body is not empty!');
 }