| 561 | } |
| 562 | |
| 563 | public function testRead() |
| 564 | { |
| 565 | $host = 'localhost'; |
| 566 | $port = 9090; |
| 567 | $persist = false; |
| 568 | $debugHandler = null; |
| 569 | $transport = new TSocket( |
| 570 | $host, |
| 571 | $port, |
| 572 | $persist, |
| 573 | $debugHandler |
| 574 | ); |
| 575 | $fileName = sys_get_temp_dir() . '/' . md5(mt_rand(0, time()) . time()); |
| 576 | file_put_contents($fileName, '12345678901234567890'); |
| 577 | $handle = fopen($fileName, 'r+'); |
| 578 | $transport->setHandle($handle); |
| 579 | $this->assertEquals('12345', $transport->read(5)); |
| 580 | |
| 581 | register_shutdown_function(function () use ($fileName) { |
| 582 | is_file($fileName) && unlink($fileName); |
| 583 | }); |
| 584 | } |
| 585 | |
| 586 | /** |
| 587 | * @dataProvider readFailDataProvider |