Browse Source

Use better default chars that work in all browsers.

mscherer 6 years ago
parent
commit
cc95261759
2 changed files with 14 additions and 12 deletions
  1. 4 2
      src/View/Helper/ProgressHelper.php
  2. 10 10
      tests/TestCase/View/Helper/ProgressHelperTest.php

+ 4 - 2
src/View/Helper/ProgressHelper.php

@@ -16,6 +16,8 @@ use Tools\Utility\Number;
 class ProgressHelper extends Helper {
 
 	const LENGTH_MIN = 3;
+	const CHAR_EMPTY = '░';
+	const CHAR_FULL = '█';
 
 	/**
 	 * @var array
@@ -26,8 +28,8 @@ class ProgressHelper extends Helper {
 	 * @var array
 	 */
 	protected $_defaults = [
-		'empty' => '⬜',
-		'full' => '⬛',
+		'empty' => self::CHAR_EMPTY,
+		'full' => self::CHAR_FULL,
 	];
 
 	/**

+ 10 - 10
tests/TestCase/View/Helper/ProgressHelperTest.php

@@ -33,22 +33,22 @@ class ProgressHelperTest extends TestCase {
 	 */
 	public function testDraw() {
 		$result = $this->progressHelper->draw(0.00, 3);
-		$this->assertSame('⬜⬜⬜', $result);
+		$this->assertSame('░░░', $result);
 
 		$result = $this->progressHelper->draw(1.00, 3);
-		$this->assertSame('⬛⬛⬛', $result);
+		$this->assertSame('███', $result);
 
 		$result = $this->progressHelper->draw(0.50, 3);
-		$this->assertSame('⬛⬛⬜', $result);
+		$this->assertSame('██░', $result);
 
 		$result = $this->progressHelper->draw(0.30, 5);
-		$this->assertSame('⬛⬛⬜⬜⬜', $result);
+		$this->assertSame('██░░░', $result);
 
 		$result = $this->progressHelper->draw(0.01, 3);
-		$this->assertSame('⬛⬜⬜', $result);
+		$this->assertSame('█░░', $result);
 
 		$result = $this->progressHelper->draw(0.99, 3);
-		$this->assertSame('⬛⬛⬜', $result);
+		$this->assertSame('██░', $result);
 	}
 
 	/**
@@ -56,16 +56,16 @@ class ProgressHelperTest extends TestCase {
 	 */
 	public function testProgressBar() {
 		$result = $this->progressHelper->progressBar(0.001, 3);
-		$this->assertSame('<span title="1%">⬛⬜⬜</span>', $result);
+		$this->assertSame('<span title="1%">█░░</span>', $result);
 
 		$result = $this->progressHelper->progressBar(0.999, 3);
-		$this->assertSame('<span title="99%">⬛⬛⬜</span>', $result);
+		$this->assertSame('<span title="99%">██░</span>', $result);
 
 		$result = $this->progressHelper->progressBar(0.000, 3);
-		$this->assertSame('<span title="0%">⬜⬜⬜</span>', $result);
+		$this->assertSame('<span title="0%">░░░</span>', $result);
 
 		$result = $this->progressHelper->progressBar(1.000, 3);
-		$this->assertSame('<span title="100%">⬛⬛⬛</span>', $result);
+		$this->assertSame('<span title="100%">███</span>', $result);
 	}
 
 	/**