blob: e08057b4fbc8ff4e96ca9b6f39f69cc97d022154 [file] [log] [blame]
Jens Geyer19983382014-02-22 17:34:29 +01001<?php
2
3/*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 *
21 * @package thrift.test
22 */
23
Roger Thomas6fb59232014-11-04 10:09:23 +000024namespace Test\Thrift\Protocol;
Jens Geyer19983382014-02-22 17:34:29 +010025
26use Thrift\ClassLoader\ThriftClassLoader;
27use Thrift\Serializer\TBinarySerializer;
28
Robert Lubfba3702017-11-03 12:27:31 +080029require_once __DIR__.'/../../../../vendor/autoload.php';
Jens Geyer19983382014-02-22 17:34:29 +010030
31$loader = new ThriftClassLoader();
Robert Lubfba3702017-11-03 12:27:31 +080032$loader->registerDefinition('ThriftTest', __DIR__ . '/../packages');
Jens Geyer19983382014-02-22 17:34:29 +010033$loader->register();
34
35/***
36 * This test suite depends on running the compiler against the
37 * standard ThriftTest.thrift file:
38 *
39 * lib/php/test$ ../../../compiler/cpp/thrift --gen php -r \
40 * --out ./packages ../../../test/ThriftTest.thrift
41 */
42
43class TestBinarySerializer extends \PHPUnit_Framework_TestCase
44{
45
46 public function setUp()
47 {
48 }
49
50 /**
51 * We try to serialize and deserialize a random object to make sure no exceptions are thrown.
52 * @see THRIFT-1579
53 */
54 public function testBinarySerializer()
55 {
56 $struct = new \ThriftTest\Xtruct(array('string_thing' => 'abc'));
57 $serialized = TBinarySerializer::serialize($struct, 'ThriftTest\\Xtruct');
58 $deserialized = TBinarySerializer::deserialize($serialized, 'ThriftTest\\Xtruct');
59 $this->assertEquals($struct, $deserialized);
60 }
61
62}