* @dataProvider readFailDataProvider */
(
$streamSelectResult,
$freadResult,
$feofResult,
$expectedException,
$expectedMessage,
$expectedCode
)
| 587 | * @dataProvider readFailDataProvider |
| 588 | */ |
| 589 | public function testReadFail( |
| 590 | $streamSelectResult, |
| 591 | $freadResult, |
| 592 | $feofResult, |
| 593 | $expectedException, |
| 594 | $expectedMessage, |
| 595 | $expectedCode |
| 596 | ) { |
| 597 | $host = 'localhost'; |
| 598 | $port = 9090; |
| 599 | $persist = false; |
| 600 | $debugHandler = null; |
| 601 | $handle = fopen('php://memory', 'r+'); |
| 602 | |
| 603 | $this->getFunctionMock('Thrift\Transport', 'stream_select') |
| 604 | ->expects($this->once()) |
| 605 | ->with( |
| 606 | [$handle], |
| 607 | $this->anything(), #$null, |
| 608 | $this->anything(), #$null, |
| 609 | $this->anything(), #$this->recvTimeoutSec_, |
| 610 | $this->anything() #$this->recvTimeoutUsec_ |
| 611 | ) |
| 612 | ->willReturn($streamSelectResult); |
| 613 | |
| 614 | $this->getFunctionMock('Thrift\Transport', 'fread') |
| 615 | ->expects($this->exactly($streamSelectResult ? 1 : 0)) |
| 616 | ->with( |
| 617 | $handle, |
| 618 | 5 |
| 619 | ) |
| 620 | ->willReturn($freadResult); |
| 621 | $this->getFunctionMock('Thrift\Transport', 'feof') |
| 622 | ->expects($this->exactly($feofResult ? 1 : 0)) |
| 623 | ->with($handle) |
| 624 | ->willReturn($feofResult); |
| 625 | |
| 626 | $this->expectException($expectedException); |
| 627 | $this->expectExceptionMessage($expectedMessage); |
| 628 | $this->expectExceptionCode($expectedCode); |
| 629 | |
| 630 | $transport = new TSocket( |
| 631 | $host, |
| 632 | $port, |
| 633 | $persist, |
| 634 | $debugHandler |
| 635 | ); |
| 636 | $transport->setHandle($handle); |
| 637 | |
| 638 | $transport->read(5); |
| 639 | } |
| 640 | |
| 641 | public function readFailDataProvider() |
| 642 | { |