@@ -353,35 +353,52 @@ public function testSetCurrentBeforeStarting()
353
353
354
354
public function testRedrawFrequency ()
355
355
{
356
- $ bar = $ this ->getMock ('Symfony\Component\Console\Helper\ProgressBar ' , array ('display ' ), array ($ this ->getOutputStream (), 6 ));
357
- $ bar ->expects ($ this ->exactly (4 ))->method ('display ' );
358
-
356
+ $ bar = new ProgressBar ($ output = $ this ->getOutputStream (), 6 );
359
357
$ bar ->setRedrawFrequency (2 );
360
358
$ bar ->start ();
361
359
$ bar ->setProgress (1 );
362
360
$ bar ->advance (2 );
363
361
$ bar ->advance (2 );
364
362
$ bar ->advance (1 );
363
+
364
+ rewind ($ output ->getStream ());
365
+ $ this ->assertEquals (
366
+ ' 0/6 [>---------------------------] 0% ' .
367
+ $ this ->generateOutput (' 3/6 [==============>-------------] 50% ' ).
368
+ $ this ->generateOutput (' 5/6 [=======================>----] 83% ' ).
369
+ $ this ->generateOutput (' 6/6 [============================] 100% ' ),
370
+ stream_get_contents ($ output ->getStream ())
371
+ );
365
372
}
366
373
367
374
public function testRedrawFrequencyIsAtLeastOneIfZeroGiven ()
368
375
{
369
- $ bar = $ this ->getMock ('Symfony\Component\Console\Helper\ProgressBar ' , array ('display ' ), array ($ this ->getOutputStream ()));
370
-
371
- $ bar ->expects ($ this ->exactly (2 ))->method ('display ' );
376
+ $ bar = new ProgressBar ($ output = $ this ->getOutputStream ());
372
377
$ bar ->setRedrawFrequency (0 );
373
378
$ bar ->start ();
374
379
$ bar ->advance ();
380
+
381
+ rewind ($ output ->getStream ());
382
+ $ this ->assertEquals (
383
+ ' 0 [>---------------------------] ' .
384
+ $ this ->generateOutput (' 1 [->--------------------------] ' ),
385
+ stream_get_contents ($ output ->getStream ())
386
+ );
375
387
}
376
388
377
389
public function testRedrawFrequencyIsAtLeastOneIfSmallerOneGiven ()
378
390
{
379
- $ bar = $ this ->getMock ('Symfony\Component\Console\Helper\ProgressBar ' , array ('display ' ), array ($ this ->getOutputStream ()));
380
-
381
- $ bar ->expects ($ this ->exactly (2 ))->method ('display ' );
391
+ $ bar = new ProgressBar ($ output = $ this ->getOutputStream ());
382
392
$ bar ->setRedrawFrequency (0.9 );
383
393
$ bar ->start ();
384
394
$ bar ->advance ();
395
+
396
+ rewind ($ output ->getStream ());
397
+ $ this ->assertEquals (
398
+ ' 0 [>---------------------------] ' .
399
+ $ this ->generateOutput (' 1 [->--------------------------] ' ),
400
+ stream_get_contents ($ output ->getStream ())
401
+ );
385
402
}
386
403
387
404
public function testMultiByteSupport ()
0 commit comments