Debian Codegraph @

lib/php/test/Unit/Lib/Protocol/TProtocolDecoratorTest.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
23 namespace Test\Thrift\Unit\Lib\Protocol;
24
25 use PHPUnit\Framework\TestCase;
26 use Thrift\Protocol\TProtocol;
27 use Thrift\Protocol\TProtocolDecorator;
28
29 class TProtocolDecoratorTest extends TestCase
30 {
31
32 /**
33 * @dataProvider methodDecorationDataProvider
34 */
35 public function testMethodDecoration(
36 $methodName,
37 $methodArguments
38 ) {
39 $concreteProtocol = $this->createMock(TProtocol::class);
40 $decorator = new class ($concreteProtocol) extends TProtocolDecorator {
41 public function __construct(TProtocol $protocol)
42 {
43 parent::__construct($protocol);
44 }
45 };
46
47 $concreteProtocol->expects($this->once())
48 ->method($methodName)
49 ->with(...$methodArguments);
50
51 $decorator->$methodName(...$methodArguments);
52 }
53
54 public function methodDecorationDataProvider()
55 {
56 yield 'writeMessageBegin' => ['writeMessageBegin', ['name', 'type', 'seqid']];
57 yield 'writeMessageEnd' => ['writeMessageEnd', []];
58 yield 'writeStructBegin' => ['writeStructBegin', ['name']];
59 yield 'writeStructEnd' => ['writeStructEnd', []];
60 yield 'writeFieldBegin' => ['writeFieldBegin', ['name', 'type', 'id']];
61 yield 'writeFieldEnd' => ['writeFieldEnd', []];
62 yield 'writeFieldStop' => ['writeFieldStop', []];
63 yield 'writeMapBegin' => ['writeMapBegin', ['keyType', 'valType', 'size']];
64 yield 'writeMapEnd' => ['writeMapEnd', []];
65 yield 'writeListBegin' => ['writeListBegin', ['elemType', 'size']];
66 yield 'writeListEnd' => ['writeListEnd', []];
67 yield 'writeSetBegin' => ['writeSetBegin', ['elemType', 'size']];
68 yield 'writeSetEnd' => ['writeSetEnd', []];
69 yield 'writeBool' => ['writeBool', ['value']];
70 yield 'writeByte' => ['writeByte', ['value']];
71 yield 'writeI16' => ['writeI16', ['value']];
72 yield 'writeI32' => ['writeI32', ['value']];
73 yield 'writeI64' => ['writeI64', ['value']];
74 yield 'writeDouble' => ['writeDouble', ['value']];
75 yield 'writeString' => ['writeString', ['value']];
76 yield 'readMessageBegin' => ['readMessageBegin', ['name', 'type', 'seqid']];
77 yield 'readMessageEnd' => ['readMessageEnd', []];
78 yield 'readStructBegin' => ['readStructBegin', ['name']];
79 yield 'readStructEnd' => ['readStructEnd', []];
80 yield 'readFieldBegin' => ['readFieldBegin', ['name', 'type', 'id']];
81 yield 'readFieldEnd' => ['readFieldEnd', []];
82 yield 'readMapBegin' => ['readMapBegin', ['keyType', 'valType', 'size']];
83 yield 'readMapEnd' => ['readMapEnd', []];
84 yield 'readListBegin' => ['readListBegin', ['elemType', 'size']];
85 yield 'readListEnd' => ['readListEnd', []];
86 yield 'readSetBegin' => ['readSetBegin', ['elemType', 'size']];
87 yield 'readSetEnd' => ['readSetEnd', []];
88 yield 'readBool' => ['readBool', ['value']];
89 yield 'readByte' => ['readByte', ['value']];
90 yield 'readI16' => ['readI16', ['value']];
91 yield 'readI32' => ['readI32', ['value']];
92 yield 'readI64' => ['readI64', ['value']];
93 yield 'readDouble' => ['readDouble', ['value']];
94 yield 'readString' => ['readString', ['value']];
95 }
96 }