expected_data = array("abc" => "def"); } public function testPack() { $entity = new Entity(self::TAG, $this->expected_data, self::EXPECTED_TIME); $packer = new JsonPacker(); $result = $packer->pack($entity); /* * expected format. * ["", , {object}] */ $this->assertStringMatchesFormat('["%s",%d,{"%s":"%s"}]', $result, "unexpected format returns"); return json_decode($result, true); } /** * @depends testPack */ public function testPackReturnTag($result) { $this->assertEquals($result['0'], self::TAG); } /** * @depends testPack */ public function testPackReturnTime($result) { $this->assertEquals($result['1'], self::EXPECTED_TIME); } /** * @depends testPack */ public function testPackReturnData($result) { $this->assertEquals($result['2'], $this->expected_data); } }