@@ -50,6 +50,32 @@ public function testReadableStreamRead()
5050 $ this ->assertSame ('' , fread ($ stream , 3 ));
5151 }
5252
53+ public function testReadableStreamSeek ()
54+ {
55+ $ stream = $ this ->bucket ->openDownloadStream ('length-10 ' );
56+
57+ $ this ->assertSame (0 , fseek ($ stream , 2 , \SEEK_SET ));
58+ $ this ->assertSame ('cde ' , fread ($ stream , 3 ));
59+ $ this ->assertSame (0 , fseek ($ stream , 10 , \SEEK_SET ));
60+ $ this ->assertSame ('' , fread ($ stream , 3 ));
61+ $ this ->assertSame (-1 , fseek ($ stream , -1 , \SEEK_SET ));
62+ $ this ->assertSame (-1 , fseek ($ stream , 11 , \SEEK_SET ));
63+
64+ $ this ->assertSame (0 , fseek ($ stream , -5 , \SEEK_CUR ));
65+ $ this ->assertSame ('fgh ' , fread ($ stream , 3 ));
66+ $ this ->assertSame (0 , fseek ($ stream , 1 , \SEEK_CUR ));
67+ $ this ->assertSame ('j ' , fread ($ stream , 3 ));
68+ $ this ->assertSame (-1 , fseek ($ stream , 1 , \SEEK_CUR ));
69+ $ this ->assertSame (-1 , fseek ($ stream , -11 , \SEEK_CUR ));
70+
71+ $ this ->assertSame (0 , fseek ($ stream , 0 , \SEEK_END ));
72+ $ this ->assertSame ('' , fread ($ stream , 3 ));
73+ $ this ->assertSame (0 , fseek ($ stream , -8 , \SEEK_END ));
74+ $ this ->assertSame ('cde ' , fread ($ stream , 3 ));
75+ $ this ->assertSame (-1 , fseek ($ stream , -11 , \SEEK_END ));
76+ $ this ->assertSame (-1 , fseek ($ stream , 1 , \SEEK_END ));
77+ }
78+
5379 public function testReadableStreamStat ()
5480 {
5581 $ stream = $ this ->bucket ->openDownloadStream ('length-10 ' );
@@ -102,6 +128,25 @@ public function testWritableStreamRead()
102128 $ this ->assertSame ('' , fread ($ stream , 8192 ));
103129 }
104130
131+ public function testWritableStreamSeek ()
132+ {
133+ $ stream = $ this ->bucket ->openUploadStream ('filename ' );
134+
135+ $ this ->assertSame (6 , fwrite ($ stream , 'foobar ' ));
136+
137+ $ this ->assertSame (-1 , fseek ($ stream , 0 , \SEEK_SET ));
138+ $ this ->assertSame (-1 , fseek ($ stream , 7 , \SEEK_SET ));
139+ $ this ->assertSame (0 , fseek ($ stream , 6 , \SEEK_SET ));
140+
141+ $ this ->assertSame (0 , fseek ($ stream , 0 , \SEEK_CUR ));
142+ $ this ->assertSame (-1 , fseek ($ stream , -1 , \SEEK_CUR ));
143+ $ this ->assertSame (-1 , fseek ($ stream , 1 , \SEEK_CUR ));
144+
145+ $ this ->assertSame (0 , fseek ($ stream , 0 , \SEEK_END ));
146+ $ this ->assertSame (-1 , fseek ($ stream , -1 , \SEEK_END ));
147+ $ this ->assertSame (-1 , fseek ($ stream , 1 , \SEEK_END ));
148+ }
149+
105150 public function testWritableStreamStat ()
106151 {
107152 $ currentTimestamp = time ();
0 commit comments