浏览代码

Fix tests.

mscherer 6 年之前
父节点
当前提交
b137cdb316
共有 2 个文件被更改,包括 18 次插入41 次删除
  1. 1 24
      tests/TestCase/Utility/NumberTest.php
  2. 17 17
      tests/TestCase/View/Helper/NumberHelperTest.php

+ 1 - 24
tests/TestCase/Utility/NumberTest.php

@@ -10,7 +10,7 @@ class NumberTest extends TestCase {
 	/**
 	 * @var \Tools\Utility\Number
 	 */
-	public $Number;
+	protected $Number;
 
 	/**
 	 * @return void
@@ -22,8 +22,6 @@ class NumberTest extends TestCase {
 	}
 
 	/**
-	 * NumberTest::testAverage()
-	 *
 	 * @return void
 	 */
 	public function testAverage() {
@@ -136,27 +134,6 @@ class NumberTest extends TestCase {
 	/**
 	 * @return void
 	 */
-	public function testToPercentage() {
-		$is = Number::toPercentage(22.11, 2, ['decimals' => '.']);
-		$expected = '22,11%';
-		$this->assertSame($expected, $is);
-
-		$is = Number::toPercentage(22.11, 2, ['locale' => 'en']);
-		$expected = '22.11%';
-		$this->assertSame($expected, $is);
-
-		$is = Number::toPercentage(22.11, 0, ['decimals' => '.']);
-		$expected = '22%';
-		$this->assertSame($expected, $is);
-
-		$is = Number::toPercentage(0.2311, 0, ['multiply' => true, 'decimals' => '.']);
-		$expected = '23%';
-		$this->assertSame($expected, $is);
-	}
-
-	/**
-	 * @return void
-	 */
 	public function testRoundTo() {
 		//increment = 10
 		$values = [

+ 17 - 17
tests/TestCase/View/Helper/NumberHelperTest.php

@@ -66,47 +66,47 @@ class NumberHelperTest extends TestCase {
 	public function testFormat() {
 		$is = $this->Number->format('22');
 		$expected = '22';
-		$this->assertEquals($expected, $is);
+		$this->assertSame($expected, $is);
 
 		$is = $this->Number->format('22.01');
 		$expected = '22,01';
-		$this->assertEquals($expected, $is);
+		$this->assertSame($expected, $is);
 
 		$is = $this->Number->format('22', ['places' => 2]);
 		$expected = '22,00';
-		$this->assertEquals($expected, $is);
+		$this->assertSame($expected, $is);
 
 		$is = $this->Number->format('22.30', ['places' => 1]);
 		$expected = '22,3';
-		$this->assertEquals($expected, $is);
+		$this->assertSame($expected, $is);
 
 		$is = $this->Number->format('22.30', ['precision' => -1]);
-		$expected = '22,3'; // Why?
-		$this->assertEquals($expected, $is);
+		$expected = '22'; // Why 22,3 locally?
+		$this->assertSame($expected, $is);
 
 		$is = $this->Number->format('22.30', ['places' => 3]);
 		$expected = '22,300';
-		$this->assertEquals($expected, $is);
+		$this->assertSame($expected, $is);
 
 		$is = $this->Number->format('abc', ['places' => 2]);
 		$expected = '0,00';
-		$this->assertEquals($expected, $is);
+		$this->assertSame($expected, $is);
 
 		$is = $this->Number->format('22.3', ['places' => 2, 'before' => 'EUR ']);
 		$expected = 'EUR 22,30';
-		$this->assertEquals($expected, $is);
+		$this->assertSame($expected, $is);
 
 		$is = $this->Number->format('22.3', ['places' => 2, 'after' => ' EUR']);
 		$expected = '22,30 EUR';
-		$this->assertEquals($expected, $is);
+		$this->assertSame($expected, $is);
 
 		$is = $this->Number->format('22.3', ['places' => 2, 'after' => 'x', 'before' => 'v']);
 		$expected = 'v22,30x';
-		$this->assertEquals($expected, $is);
+		$this->assertSame($expected, $is);
 
 		$is = $this->Number->format('22.3', ['places' => 2, 'locale' => 'en-US']);
 		$expected = '22.30';
-		$this->assertEquals($expected, $is);
+		$this->assertSame($expected, $is);
 	}
 
 	/**
@@ -116,10 +116,10 @@ class NumberHelperTest extends TestCase {
 	 */
 	public function testCurrency() {
 		$is = Number::defaultCurrency();
-		$this->assertEquals('EUR', $is);
+		$this->assertSame('EUR', $is);
 
 		$is = $this->Number->currency(22.2);
-		$this->assertEquals('22,20 €', $is);
+		$this->assertSame('22,20 €', $is);
 	}
 
 	/**
@@ -129,13 +129,13 @@ class NumberHelperTest extends TestCase {
 	 */
 	public function testToReadableSize() {
 		$is = $this->Number->toReadableSize(1206);
-		$this->assertEquals('1,18 KB', $is);
+		$this->assertSame('1,18 KB', $is);
 
 		$is = $this->Number->toReadableSize(1024 * 1024 * 1024);
-		$this->assertEquals('1 GB', $is);
+		$this->assertSame('1 GB', $is);
 
 		$is = $this->Number->toReadableSize(1024 * 1024 * 1024 * 1024 * 2.5);
-		$this->assertEquals('2,5 TB', $is);
+		$this->assertSame('2,5 TB', $is);
 	}
 
 }