/** * @covers ICANS\Component\IcansLoggingComponent\Transport\MessageFactory::createMessageWithPulseId */ public function testCreateMessageWithPulseIdWithExistingHttpHost() { $oldhost = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null; $_SERVER['HTTP_HOST'] = 'my-dummy-hostname'; $actual = $this->object->createMessageWithPulseId('message type', 'message handle', 1, array('Body item 1', 'Body item 2'), 'app', 'origin service type', 'origin service component', 'origin service instance', 'pulse ID', 1234, 'log level name'); // Additionally, when createMessage() is called, a random pulse ID is // created. As we cannot predict it and neither can perform any test // without relying on internals, we simply verify it's a non-empty // string and do nothing more. $rawData = $actual->getRawData(); $this->assertInternalType('string', $rawData['origin_host']); $this->assertSame(gethostname(), $rawData['origin_host']); $_SERVER['HTTP_HOST'] = $oldhost; // Reset to initial state }