Debian Codegraph @

lib/php/test/Unit/Lib/Factory/TBinaryProtocolFactoryTest.php

raw
1 <?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
22 namespace Test\Thrift\Unit\Lib\Factory;
23
24 use PHPUnit\Framework\TestCase;
25 use Test\Thrift\Unit\Lib\ReflectionHelper;
26 use Thrift\Factory\TBinaryProtocolFactory;
27 use Thrift\Protocol\TBinaryProtocol;
28 use Thrift\Transport\TTransport;
29
30 class TBinaryProtocolFactoryTest extends TestCase
31 {
32 use ReflectionHelper;
33
34 /**
35 * @dataProvider getProtocolDataProvider
36 * @param bool $strictRead
37 * @param bool $strictWrite
38 * @return void
39 */
40 public function testGetProtocol(
41 $strictRead,
42 $strictWrite
43 ) {
44 $transport = $this->createMock(TTransport::class);
45 $factory = new TBinaryProtocolFactory($strictRead, $strictWrite);
46 $protocol = $factory->getProtocol($transport);
47
48 $this->assertInstanceOf(TBinaryProtocol::class, $protocol);
49
50 $this->assertEquals($strictRead, $this->getPropertyValue($protocol, 'strictRead_'));
51 $this->assertEquals($strictWrite, $this->getPropertyValue($protocol, 'strictWrite_'));
52 $this->assertSame($transport, $this->getPropertyValue($protocol, 'trans_'));
53 }
54
55 public function getProtocolDataProvider()
56 {
57 yield 'allTrue' => [
58 'strictRead' => true,
59 'strictWrite' => true,
60 ];
61 yield 'allFalse' => [
62 'strictRead' => false,
63 'strictWrite' => false,
64 ];
65 yield 'strictReadTrue' => [
66 'strictRead' => true,
67 'strictWrite' => false,
68 ];
69 yield 'strictWriteTrue' => [
70 'strictRead' => false,
71 'strictWrite' => true,
72 ];
73 }
74 }