pkvach commented on code in PR #2942:
URL: https://github.com/apache/thrift/pull/2942#discussion_r1510414124


##########
lib/php/test/Unit/Lib/Transport/TFramedTransportTest.php:
##########
@@ -0,0 +1,244 @@
+<?php
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * @package thrift.transport
+ */
+
+namespace Test\Thrift\Unit\Lib\Transport;
+
+namespace Unit\Lib\Transport;
+
+use PHPUnit\Framework\TestCase;
+use Thrift\Transport\TFramedTransport;
+use Thrift\Transport\TTransport;
+
+class TFramedTransportTest extends TestCase
+{
+    public function testIsOpen()
+    {
+        $transport = $this->createMock(TTransport::class);
+        $framedTransport = new TFramedTransport($transport);
+
+        $transport
+            ->expects($this->once())
+            ->method('isOpen')
+            ->willReturn(true);
+
+        $this->assertTrue($framedTransport->isOpen());
+    }
+
+    public function testOpen()
+    {
+        $transport = $this->createMock(TTransport::class);
+        $framedTransport = new TFramedTransport($transport);
+
+        $transport
+            ->expects($this->once())
+            ->method('open')
+            ->willReturn(null);
+
+        $this->assertNull($framedTransport->open());
+    }
+
+    public function testClose()
+    {
+        $transport = $this->createMock(TTransport::class);
+        $framedTransport = new TFramedTransport($transport);
+
+        $transport
+            ->expects($this->once())
+            ->method('close')
+            ->willReturn(null);
+
+        $this->assertNull($framedTransport->close());
+    }
+
+    public function testPutBack()
+    {
+        $transport = $this->createMock(TTransport::class);
+        $framedTransport = new TFramedTransport($transport);
+        $framedTransport->putBack('test');
+
+        $ref = new \ReflectionClass($framedTransport);
+        $property = $ref->getProperty('rBuf_');
+        $property->setAccessible(true);
+        $this->assertEquals('test', $property->getValue($framedTransport));
+
+        $framedTransport->putBack('abcde');
+        $this->assertEquals('abcdetest', 
$property->getValue($framedTransport));
+    }
+
+    /**
+     * @dataProvider readDataProvider
+     */
+    public function testRead(
+        $readAllowed,
+        $readBuffer,
+        $lowLevelTransportReadResult,
+        $lowLevelTransportReadAllParams,
+        $lowLevelTransportReadAllResult,
+        $readLength,
+        $expectedReadResult
+    ) {
+        $transport = $this->createMock(TTransport::class);
+        $framedTransport = new TFramedTransport($transport, $readAllowed);
+        $framedTransport->putBack($readBuffer);
+
+        $transport
+            ->expects($readAllowed ? $this->never() : $this->once())
+            ->method('read')
+            ->with($readLength)
+            ->willReturn($lowLevelTransportReadResult);
+
+        $transport
+            ->expects($this->exactly(count($lowLevelTransportReadAllParams)))
+            ->method('readAll')
+            ->withConsecutive(...$lowLevelTransportReadAllParams)

Review Comment:
   `withConsecutive()` is 
[deprecated](https://github.com/sebastianbergmann/phpunit/issues/5063) and has 
been [removed](https://github.com/sebastianbergmann/phpunit/issues/4564) in 
PHPUnit 10.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to