Skip to content

Commit

Permalink
Fix #11. Using another way for generating a header (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
disc authored Feb 10, 2019
1 parent 813b6d4 commit cc64312
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"name": "disc/php-zabbix-sender",
"version": "1.3.0",
"version": "1.3.1",
"minimum-stability": "stable",
"description": "Php implementation of zabbix_sender utility. Works with Zabbix 2.0.8 and 2.1.7+ versions.",
"keywords": ["zabbix"],
"description": "PHP implementation of zabbix_sender utility. Works with Zabbix 2.0.8, 2.1.7+ and 4.0 versions.",
"keywords": [
"zabbix"
],
"type": "library",
"require": {
"php": ">=5.3"
Expand All @@ -16,11 +18,13 @@
"license": "MIT",
"authors": [
{
"name": "disc",
"name": "Alexandr Hacicheant",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": {"Disc\\": "src/"}
"psr-4": {
"Disc\\": "src/"
}
}
}
}
4 changes: 2 additions & 2 deletions src/Zabbix/Sender.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ protected function buildRequestBody()
'request' => 'sender data',
'data' => $this->getData(),
]);
return "ZBXD\1" . pack('P', strlen($data)) . $data;

return "ZBXD\1" . pack('V', strlen($data)) . "\0\0\0\0" . $data;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/SenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testAddData()
'request' => 'sender data',
'data' => [],
]);
$sender->shouldReceive('sendData')->once()->with("ZBXD\1" . pack('P', strlen($data)) . $data);
$sender->shouldReceive('sendData')->once()->with("ZBXD\1" . pack('V', strlen($data)) . "\0\0\0\0" . $data);

$sender->send();

Expand Down Expand Up @@ -78,7 +78,7 @@ public function testAddData()
],
],
]);
$sender->shouldReceive('sendData')->once()->with("ZBXD\1" . pack('P', strlen($data)) . $data);
$sender->shouldReceive('sendData')->once()->with("ZBXD\1" . pack('V', strlen($data)) . "\0\0\0\0" . $data);
$sender->send();
}

Expand Down Expand Up @@ -106,13 +106,13 @@ public function testClearData()
]
],
]);
$sender->shouldReceive('sendData')->once()->with("ZBXD\1" . pack('P', strlen($data)) . $data);
$sender->shouldReceive('sendData')->once()->with("ZBXD\1" . pack('V', strlen($data)) . "\0\0\0\0" . $data);
$sender->send();
$data = json_encode([
'request' => 'sender data',
'data' => [],
]);
$sender->shouldReceive('sendData')->once()->with("ZBXD\1" . pack('P', strlen($data)) . $data);
$sender->shouldReceive('sendData')->once()->with("ZBXD\1" . pack('V', strlen($data)) . "\0\0\0\0" . $data);
$sender->send();
}

Expand Down

0 comments on commit cc64312

Please sign in to comment.