Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F111360455
PhutilChannelTestCase.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, May 1, 02:02
Size
875 B
Mime Type
text/x-php
Expires
Sat, May 3, 02:02 (1 d, 3 h)
Engine
blob
Format
Raw Data
Handle
25904848
Attached To
rPHU libphutil
PhutilChannelTestCase.php
View Options
<?php
final
class
PhutilChannelTestCase
extends
PhutilTestCase
{
public
function
testChannelBasics
()
{
list
(
$x
,
$y
)
=
PhutilSocketChannel
::
newChannelPair
();
$str_len_8
=
'abcdefgh'
;
$str_len_4
=
'abcd'
;
// Do a write with no buffer limit.
$x
->
write
(
$str_len_8
);
while
(
true
)
{
$x
->
update
();
$y
->
update
();
$read
=
$y
->
read
();
if
(
strlen
(
$read
))
{
break
;
}
}
// We expect to read the entire message.
$this
->
assertEqual
(
$str_len_8
,
$read
);
// Again, with a read buffer limit.
$y
->
setReadBufferSize
(
4
);
$x
->
write
(
$str_len_8
);
while
(
true
)
{
$x
->
update
();
$y
->
update
();
$read
=
$y
->
read
();
if
(
strlen
(
$read
))
{
break
;
}
}
// We expect to see only the first 4 bytes of the message.
$this
->
assertEqual
(
$str_len_4
,
$read
);
}
}
Event Timeline
Log In to Comment