Browse Source

Add a test to the shell ProgressHelper float pad fix

Yves P. 10 years ago
parent
commit
234f643d17
1 changed files with 49 additions and 0 deletions
  1. 49 0
      tests/TestCase/Shell/Helper/ProgressHelperTest.php

+ 49 - 0
tests/TestCase/Shell/Helper/ProgressHelperTest.php

@@ -191,4 +191,53 @@ class ProgressHelperTest extends TestCase
 
         $this->assertEquals($expected, $this->stub->messages());
     }
+
+    /**
+     * Test increment and draw with value that makes the pad
+     * be a float
+     *
+     * @return void
+     */
+    public function testIncrementFloatPad()
+    {
+        $this->helper->init([
+            'total' => 50
+        ]);
+        $expected = [
+            '',
+            '=========>                                                                   14%',
+            '',
+            '====================>                                                        28%',
+            '',
+            '==============================>                                              42%',
+            '',
+            '=========================================>                                   56%',
+            '',
+            '===================================================>                         70%',
+            '',
+            '========================================================>                    76%',
+            '',
+            '==============================================================>              84%',
+            '',
+            '==========================================================================> 100%',
+        ];
+        $this->helper->increment(7);
+        $this->helper->draw();
+        $this->helper->increment(7);
+        $this->helper->draw();
+        $this->helper->increment(7);
+        $this->helper->draw();
+        $this->helper->increment(7);
+        $this->helper->draw();
+        $this->helper->increment(7);
+        $this->helper->draw();
+        $this->helper->increment(3);
+        $this->helper->draw();
+        $this->helper->increment(4);
+        $this->helper->draw();
+        $this->helper->increment(8);
+        $this->helper->draw();
+
+        $this->assertEquals($expected, $this->stub->messages());
+    }
 }