MCPcopy Create free account
hub / github.com/apache/thrift / testRead

Method testRead

lib/php/test/Unit/Lib/Transport/THttpClientTest.php:78–110  ·  view source on GitHub ↗

* @dataProvider readDataProvider */

(
        $readLen,
        $freadResult,
        $streamGetMetaDataResult,
        $expectedResult,
        $expectedException,
        $expectedExceptionMessage,
        $expectedExceptionCode
    )

Source from the content-addressed store, hash-verified

76 * @dataProvider readDataProvider
77 */
78 public function testRead(
79 $readLen,
80 $freadResult,
81 $streamGetMetaDataResult,
82 $expectedResult,
83 $expectedException,
84 $expectedExceptionMessage,
85 $expectedExceptionCode
86 ) {
87 $handle = fopen('php://temp', 'r+');
88 $this->getFunctionMock('Thrift\\Transport', 'fread')
89 ->expects($this->once())
90 ->with($handle, $readLen)
91 ->willReturn($freadResult);
92
93 $this->getFunctionMock('Thrift\\Transport', 'stream_get_meta_data')
94 ->expects(!empty($streamGetMetaDataResult) ? $this->once() : $this->never())
95 ->with($handle)
96 ->willReturn($streamGetMetaDataResult);
97
98 if ($expectedException) {
99 $this->expectException($expectedException);
100 $this->expectExceptionMessage($expectedExceptionMessage);
101 $this->expectExceptionCode($expectedExceptionCode);
102 }
103
104 $host = 'localhost';
105 $transport = new THttpClient($host);
106
107 $this->setPropertyValue($transport, 'handle_', $handle);
108
109 $this->assertEquals($expectedResult, $transport->read($readLen));
110 }
111
112 public function readDataProvider()
113 {

Callers

nothing calls this directly

Calls 2

setPropertyValueMethod · 0.80
readMethod · 0.65

Tested by

no test coverage detected