@@ -36,6 +36,54 @@ public function testStreamDataWillEmitDataBehindNewlineWhenDataContainsDataBehin
3636 $ input ->write ("hello! \nignored " );
3737 }
3838
39+ public function testStreamDataWillEmitDataWhenDataContainsNewlineAtMaximumBufferSize ()
40+ {
41+ $ input = new ThroughStream ();
42+ $ stream = new LineSeparatedReader ($ input );
43+
44+ $ stream ->on ('data ' , $ this ->expectCallableOnceWith (str_repeat ('a ' , 65536 )));
45+ $ stream ->on ('error ' , $ this ->expectCallableNever ());
46+
47+ $ input ->write (str_repeat ('a ' , 65536 ));
48+ $ input ->write ("\n" );
49+ }
50+
51+ public function testStreamDataWillEmitErrorAndCloseWhenDataExceedsMaximumBufferSize ()
52+ {
53+ $ input = new ThroughStream ();
54+ $ stream = new LineSeparatedReader ($ input );
55+
56+ $ stream ->on ('data ' , $ this ->expectCallableNever ());
57+ $ stream ->on ('error ' , $ this ->expectCallableOnceWith ($ this ->isInstanceOf ('OverflowException ' )));
58+ $ stream ->on ('close ' , $ this ->expectCallableOnce ());
59+
60+ $ input ->write (str_repeat ('a ' , 40000 ));
61+ $ input ->write (str_repeat ('a ' , 40000 ));
62+ }
63+
64+ public function testStreamDataWillEmitErrorAndCloseWhenDataContainsNewlineBehindMaximumBufferSize ()
65+ {
66+ $ input = new ThroughStream ();
67+ $ stream = new LineSeparatedReader ($ input );
68+
69+ $ stream ->on ('data ' , $ this ->expectCallableNever ());
70+ $ stream ->on ('error ' , $ this ->expectCallableOnceWith ($ this ->isInstanceOf ('OverflowException ' )));
71+ $ stream ->on ('close ' , $ this ->expectCallableOnce ());
72+
73+ $ input ->write (str_repeat ('a ' , 65537 ) . "\n" );
74+ }
75+
76+ public function testStreamDataWillEmitDataAndErrorWhenDataBehindNewlineExceedsMaximumBufferSize ()
77+ {
78+ $ input = new ThroughStream ();
79+ $ stream = new LineSeparatedReader ($ input );
80+
81+ $ stream ->on ('data ' , $ this ->expectCallableOnceWith ("hello! " ));
82+ $ stream ->on ('error ' , $ this ->expectCallableOnceWith ($ this ->isInstanceOf ('OverflowException ' )));
83+
84+ $ input ->write ("hello! \n" . str_repeat ('a ' , 65537 ));
85+ }
86+
3987
4088 public function testStreamEndWillEndWithoutDataWhenNoPreviousDataInBuffer ()
4189 {
0 commit comments