* @dataProvider writeFailDataProvider */
(
$streamSelectResult,
$fwriteCallCount,
$expectedException,
$expectedMessage,
$expectedCode
)
| 465 | * @dataProvider writeFailDataProvider |
| 466 | */ |
| 467 | public function testWriteFail( |
| 468 | $streamSelectResult, |
| 469 | $fwriteCallCount, |
| 470 | $expectedException, |
| 471 | $expectedMessage, |
| 472 | $expectedCode |
| 473 | ) { |
| 474 | $host = 'localhost'; |
| 475 | $port = 9090; |
| 476 | $persist = false; |
| 477 | $debugHandler = null; |
| 478 | $handle = fopen('php://memory', 'r+'); |
| 479 | |
| 480 | $this->getFunctionMock('Thrift\Transport', 'stream_select') |
| 481 | ->expects($this->once()) |
| 482 | ->with( |
| 483 | $this->anything(), #$null, |
| 484 | [$handle], |
| 485 | $this->anything(), #$null, |
| 486 | $this->anything(), #$this->sendTimeoutSec_, |
| 487 | $this->anything() #$this->sendTimeoutUsec_ |
| 488 | ) |
| 489 | ->willReturn($streamSelectResult); |
| 490 | |
| 491 | $this->getFunctionMock('Thrift\Transport', 'fwrite') |
| 492 | ->expects($this->exactly($fwriteCallCount)) |
| 493 | ->with( |
| 494 | $handle, |
| 495 | 'test1234456789132456798' |
| 496 | ) |
| 497 | ->willReturn(false); |
| 498 | |
| 499 | $this->expectException($expectedException); |
| 500 | $this->expectExceptionMessage($expectedMessage); |
| 501 | $this->expectExceptionCode($expectedCode); |
| 502 | |
| 503 | $transport = new TSocket( |
| 504 | $host, |
| 505 | $port, |
| 506 | $persist, |
| 507 | $debugHandler |
| 508 | ); |
| 509 | $transport->setHandle($handle); |
| 510 | |
| 511 | $transport->write('test1234456789132456798'); |
| 512 | } |
| 513 | |
| 514 | public function testWrite() |
| 515 | { |