| 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\TMultiplexedProtocol; |
| 27 |
use Thrift\Protocol\TProtocol; |
| 28 |
use Thrift\Type\TMessageType; |
| 29 |
|
| 30 |
class TMultiplexedProtocolTest extends TestCase |
| 31 |
{ |
| 32 |
|
| 33 |
/** |
| 34 |
* @dataProvider writeMessageBeginDataProvider |
| 35 |
*/ |
| 36 |
public function testWriteMessageBegin( |
| 37 |
$serviceName, |
| 38 |
$name, |
| 39 |
$type, |
| 40 |
$seqid, |
| 41 |
$expectedName |
| 42 |
) { |
| 43 |
$protocol = $this->createMock(TProtocol::class); |
| 44 |
$multiplexedProtocol = new TMultiplexedProtocol($protocol, $serviceName); |
| 45 |
|
| 46 |
$protocol->expects($this->once()) |
| 47 |
->method('writeMessageBegin') |
| 48 |
->with($expectedName, $type, $seqid); |
| 49 |
|
| 50 |
$multiplexedProtocol->writeMessageBegin($name, $type, $seqid); |
| 51 |
} |
| 52 |
|
| 53 |
public function writeMessageBeginDataProvider() |
| 54 |
{ |
| 55 |
yield 'messageTypeCall' => [ |
| 56 |
'serviceName' => 'serviceName', |
| 57 |
'name' => 'testName', |
| 58 |
'type' => TMessageType::CALL, |
| 59 |
'seqid' => 1, |
| 60 |
'expectedName' => 'serviceName:testName' |
| 61 |
]; |
| 62 |
yield 'messageTypeOneWay' => [ |
| 63 |
'serviceName' => 'serviceName', |
| 64 |
'name' => 'testName', |
| 65 |
'type' => TMessageType::ONEWAY, |
| 66 |
'seqid' => 1, |
| 67 |
'expectedName' => 'serviceName:testName' |
| 68 |
]; |
| 69 |
yield 'messageTypeReply' => [ |
| 70 |
'serviceName' => 'serviceName', |
| 71 |
'name' => 'testName', |
| 72 |
'type' => TMessageType::REPLY, |
| 73 |
'seqid' => 1, |
| 74 |
'expectedName' => 'testName' |
| 75 |
]; |
| 76 |
yield 'messageTypeException' => [ |
| 77 |
'serviceName' => 'serviceName', |
| 78 |
'name' => 'testName', |
| 79 |
'type' => TMessageType::EXCEPTION, |
| 80 |
'seqid' => 1, |
| 81 |
'expectedName' => 'testName' |
| 82 |
]; |
| 83 |
} |
| 84 |
} |