fluent / fluent-logger-php

A structured logger for Fluentd (PHP)
Other
215 stars 57 forks source link

add msgpack packer #27

Closed dieend closed 4 years ago

cosmo0920 commented 9 years ago

It would be great to add unit test like this:

tests/Fluent/Logger/MsgpackPackerTest.php:

<?php
namespace FluentTests\Logger;

use Fluent\Logger\Entity;
use Fluent\Logger\MsgpackPacker;

class MsgpackPackerTest extends \PHPUnit_Framework_TestCase
{
    const TAG           = "debug.test";
    const EXPECTED_TIME = 123456789;

    protected $time;
    protected $expected_data = array();

    public function setUp()
    {
        $this->expected_data = array("abc" => "def");
    }

    public function testPack()
    {
        $entity = new Entity(self::TAG, $this->expected_data, self::EXPECTED_TIME);

        if (function_exists('msgpack_pack') && function_exists('msgpack_unpack')) {
            $packer = new MsgpackPacker();
            $packed = $packer->pack($entity);
            $unpacked = msgpack_unpack($packed); // for comparison in assertion
            $expected = (array(self::TAG, self::EXPECTED_TIME, $this->expected_data));

            $this->assertArraySubset($expected, $unpacked);
        } else {
            $this->markTestSkipped('Skipped MsgpackPackerTest::testPack.');
        }
    }
}
acraftydev commented 3 years ago

What happened to the msgpack Packer, i was able to add manually but wondering why it is no longer included?