Passage en Namespace et tous les tests fonctionnels OK

This commit is contained in:
2021-05-10 11:48:15 +02:00
parent 536dd0d56b
commit eb30d8ef97
56 changed files with 1091 additions and 964 deletions

View File

@@ -7,60 +7,62 @@
namespace Domframework\Tests;
use Domframework\Convert;
/** Test the Conversion of format */
class convertTest extends \PHPUnit_Framework_TestCase
class ConvertTest extends \PHPUnit_Framework_TestCase
{
public function test_convertDate1 ()
{
$res = \convert::convertDate ("2017-04-13", "Y-m-d", "d/m/Y");
$res = Convert::convertDate ("2017-04-13", "Y-m-d", "d/m/Y");
$this->assertSame ($res, "13/04/2017");
}
public function test_convertDate2 ()
{
$this->setExpectedException ("Exception");
$res = \convert::convertDate ("2017-13-33", "Y-m-d", "d/m/Y");
$res = Convert::convertDate ("2017-13-33", "Y-m-d", "d/m/Y");
}
public function test_convertDate3 ()
{
$res = \convert::convertDate ("2017-13-33", "Y-m-d", "d/m/Y", false);
$res = Convert::convertDate ("2017-13-33", "Y-m-d", "d/m/Y", false);
$this->assertSame ($res, "2017-13-33");
}
public function test_ucwords_1 ()
{
$res = \convert::ucwords (" test yuyu ");
$res = Convert::ucwords (" test yuyu ");
$this->assertSame ($res, " Test Yuyu ");
}
public function test_ucwords_2 ()
{
$res = \convert::ucwords ("");
$res = Convert::ucwords ("");
$this->assertSame ($res, "");
}
public function test_ucwords_3 ()
{
$res = \convert::ucwords ("test");
$res = Convert::ucwords ("test");
$this->assertSame ($res, "Test");
}
public function test_ucwords_4 ()
{
$res = \convert::ucwords ("TEST");
$res = Convert::ucwords ("TEST");
$this->assertSame ($res, "Test");
}
public function test_ucwords_5 ()
{
$res = \convert::ucwords ("édouard étienne");
$res = Convert::ucwords ("édouard étienne");
$this->assertSame ($res, "Édouard Étienne");
}
public function test_ucwords_6 ()
{
$res = \convert::ucwords ("édou-ard d'étienne", " -'");
$res = Convert::ucwords ("édou-ard d'étienne", " -'");
$this->assertSame ($res, "Édou-Ard D'Étienne");
}
@@ -72,7 +74,7 @@ class convertTest extends \PHPUnit_Framework_TestCase
$res = "";
for ($i = -8 ; $i <= 8 ; $i++)
{
$res .= \convert::humanSize (1.441234 * pow (1000, $i), 2, 1000)."\n";
$res .= Convert::humanSize (1.441234 * pow (1000, $i), 2, 1000)."\n";
}
$this->assertSame ($res, "1.44yB\n1.44zB\n1.44aB\n1.44fB\n1.44pB\n1.44nB\n".
"1.44uB\n1.44mB\n1.44B\n1.44kB\n1.44MB\n1.44GB\n1.44TB\n1.44PB\n1.44EB\n".
@@ -81,40 +83,40 @@ class convertTest extends \PHPUnit_Framework_TestCase
public function test_humanSize_2 ()
{
$res = \convert::humanSize (1441234);
$res = Convert::humanSize (1441234);
$this->assertSame ($res, "1.44MB");
}
public function test_humanSize_3 ()
{
$res = \convert::humanSize (10441234);
$res = Convert::humanSize (10441234);
$this->assertSame ($res, "10.44MB");
}
public function test_humanSize_4 ()
{
$res = \convert::humanSize (0.123, 0);
$res = Convert::humanSize (0.123, 0);
$this->assertSame ($res, "123mB");
}
public function test_humanSize_5 ()
{
$res = \convert::humanSize (0.12345, 2);
$res = Convert::humanSize (0.12345, 2);
$this->assertSame ($res, "123.45mB");
}
public function test_humanSize_6 ()
{
$res = \convert::humanSize (-0.12345, 2);
$res = Convert::humanSize (-0.12345, 2);
$this->assertSame ($res, "-123.45mB");
}
public function test_humanSize_7 ()
{
$res = \convert::humanSize (-12345, 2);
$res = Convert::humanSize (-12345, 2);
$this->assertSame ($res, "-12.35kB");
}
public function test_humanSize_8 ()
{
$res = \convert::humanSize (0, 2);
$res = Convert::humanSize (0, 2);
$this->assertSame ($res, "0.00B");
}
@@ -123,27 +125,27 @@ class convertTest extends \PHPUnit_Framework_TestCase
{
$this->expectException ("Exception",
"convert::humanSize value not numerical : string", 500);
$res = \convert::humanSize ("1441234");
$res = Convert::humanSize ("1441234");
}
public function test_humanSize_error2 ()
{
$this->expectException ("Exception",
"convert::humanSize decimal not integer : double", 500);
$res = \convert::humanSize (1441234, 0.1);
$res = Convert::humanSize (1441234, 0.1);
}
public function test_humanSize_error3 ()
{
$this->expectException ("Exception",
"convert::humanSize decimal value negative", 500);
$res = \convert::humanSize (1441234, -1);
$res = Convert::humanSize (1441234, -1);
}
public function test_humanSize_error4 ()
{
$this->expectException ("Exception",
"convert::humanSize power value !== 1000 and 1024 : 2000", 500);
$res = \convert::humanSize (1441234, 2, 2000);
$res = Convert::humanSize (1441234, 2, 2000);
}
}