Tests are now compliant with php-cs-fixer (CamelCase for method, phpdoc valid)

This commit is contained in:
2023-04-13 22:22:46 +02:00
parent b017700d0a
commit 273db5f183
51 changed files with 3926 additions and 3637 deletions

View File

@@ -1,16 +1,19 @@
<?php
/** DomFramework - Tests
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
*/
/**
* DomFramework - Tests
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
*/
namespace Domframework\Tests;
use Domframework\Config;
/** Test the Config.php file */
/**
* Test the Config.php file
*/
class ConfigTest extends \PHPUnit_Framework_TestCase
{
public function testExternFile()
@@ -24,38 +27,38 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
{
$c = new Config();
$res = $c->params();
$this->assertSame(array (), $res);
$this->assertSame([], $res);
}
public function testGet1()
{
$c = new Config();
$c->confFile = "/tmp/testconf.php";
$c->default = array (
"database" => array (
$c->default = [
"database" => [
"dsn" => null,
"username" => null,
"password" => null,
"driver_options" => null,
"tableprefix" => ""));
"tableprefix" => ""]];
$res = $c->get("database");
$this->assertSame(array (
$this->assertSame([
"dsn" => null,
"username" => null,
"password" => null,
"driver_options" => null,
"tableprefix" => ""), $res);
"tableprefix" => ""], $res);
}
public function testSet1()
{
$c = new Config();
$c->confFile = "/tmp/testconf.php";
$c->default = array (
"database" => array (
$c->default = [
"database" => [
"dsn" => null,
"tableprefix" => ""));
$res = $c->set("database", array ("dsn" => 1,"tableprefix" => 3));
"tableprefix" => ""]];
$res = $c->set("database", ["dsn" => 1,"tableprefix" => 3]);
$this->assertSame(true, $res);
}
@@ -63,99 +66,111 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
{
$c = new Config();
$c->confFile = "/tmp/testconf.php";
$c->default = array (
"database" => array (
$c->default = [
"database" => [
"dsn" => null,
"tableprefix" => ""));
"tableprefix" => ""]];
$res = $c->get("database");
$this->assertSame(array (
$this->assertSame([
"dsn" => 1,
"tableprefix" => 3), $res);
"tableprefix" => 3], $res);
}
/** Can't create file */
/**
* Can't create file
*/
public function testGet3()
{
$c = new Config();
$c->confFile = "/tmp/1/2.3/dd/testconf.php";
$c->default = array (
"database" => array (
$c->default = [
"database" => [
"dsn" => null,
"tableprefix" => ""));
"tableprefix" => ""]];
$this->setExpectedException("Exception");
$res = $c->get("database");
}
/** Can't read the file */
/**
* Can't read the file
*/
public function testGet4()
{
$c = new Config();
$c->confFile = "/tmp/testconf.php";
chmod("/tmp/testconf.php", 0222);
$c->default = array (
"database" => array (
$c->default = [
"database" => [
"dsn" => null,
"tableprefix" => ""));
"tableprefix" => ""]];
$this->setExpectedException("Exception");
$res = $c->get("database");
}
/** File non exists and can not be created */
/**
* File non exists and can not be created
*/
public function testSet2()
{
$c = new Config();
$c->confFile = "/tmp/1/2.3/dd/testconf.php";
$c->default = array (
"database" => array (
$c->default = [
"database" => [
"dsn" => null,
"tableprefix" => ""));
"tableprefix" => ""]];
$this->setExpectedException("Exception");
$res = $c->set("database", array ("dsn" => 1,"tableprefix" => 3));
$res = $c->set("database", ["dsn" => 1,"tableprefix" => 3]);
}
/** Can't read the file */
/**
* Can't read the file
*/
public function testSet3()
{
$c = new Config();
$c->confFile = "/tmp/testconf.php";
chmod("/tmp/testconf.php", 0222);
$c->default = array (
"database" => array (
$c->default = [
"database" => [
"dsn" => null,
"tableprefix" => ""));
"tableprefix" => ""]];
$this->setExpectedException("Exception");
$res = $c->set("database", array ("dsn" => 1,"tableprefix" => 3));
$res = $c->set("database", ["dsn" => 1,"tableprefix" => 3]);
}
/** Can't write the file */
/**
* Can't write the file
*/
public function testSet4()
{
$c = new Config();
$c->confFile = "/tmp/testconf.php";
chmod("/tmp/testconf.php", 0444);
$c->default = array (
"database" => array (
$c->default = [
"database" => [
"dsn" => null,
"tableprefix" => ""));
"tableprefix" => ""]];
$this->setExpectedException("Exception");
$res = $c->set("database", array ("dsn" => 1,"tableprefix" => 3));
$res = $c->set("database", ["dsn" => 1,"tableprefix" => 3]);
}
/** Save TRUE/FALSE/NULL/String values */
/**
* Save TRUE/FALSE/NULL/String values
*/
public function testSet5()
{
$c = new Config();
$c->confFile = "/tmp/testconf.php";
chmod("/tmp/testconf.php", 0666);
$c->default = array (
"database" => array (
$c->default = [
"database" => [
"dsn" => null,
"user" => null,
"password" => null,
"tableprefix" => ""));
$res = $c->set("database", array ("dsn" => true, "user" => null,
"tableprefix" => ""]];
$res = $c->set("database", ["dsn" => true, "user" => null,
"password" => "text",
"tableprefix" => false));
"tableprefix" => false]);
$this->assertSame(true, $res);
}
@@ -164,24 +179,24 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
$c = new Config();
$c->confFile = "/tmp/testconf.php";
chmod("/tmp/testconf.php", 0666);
$c->default = array (
"database" => array (
$c->default = [
"database" => [
"dsn" => null,
"user" => null,
"password" => null,
"tableprefix" => ""),
"servers" => array (
"not configured" => array (
"tableprefix" => ""],
"servers" => [
"not configured" => [
"type" => "bind",
"username" => "",
),
)
);
],
]
];
$res = $c->get("servers");
$this->assertSame($res, array ("not configured" => array (
$this->assertSame($res, ["not configured" => [
"type" => "bind",
"username" => "",
)));
]]);
}
public function testSet7()
@@ -189,49 +204,49 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
$c = new Config();
$c->confFile = "/tmp/testconf.php";
chmod("/tmp/testconf.php", 0666);
$c->default = array (
"database" => array (
$c->default = [
"database" => [
"dsn" => null,
"user" => null,
"password" => null,
"tableprefix" => ""),
"servers" => array (
"not configured" => array (
"tableprefix" => ""],
"servers" => [
"not configured" => [
"type" => "bind",
"username" => "",
),
)
);
$res = $c->set("servers", array (
"127.0.0.1" => array (
],
]
];
$res = $c->set("servers", [
"127.0.0.1" => [
"type" => "BIND",
"username" => "toto",
)));
]]);
}
public function testGet7()
{
$c = new Config();
$c->confFile = "/tmp/testconf.php";
chmod("/tmp/testconf.php", 0666);
$c->default = array (
"database" => array (
$c->default = [
"database" => [
"dsn" => null,
"user" => null,
"password" => null,
"tableprefix" => ""),
"servers" => array (
"not configured" => array (
"tableprefix" => ""],
"servers" => [
"not configured" => [
"type" => "bind",
"username" => "",
),
)
);
],
]
];
$res = $c->get("servers");
$this->assertSame($res, array (
"127.0.0.1" => array (
$this->assertSame($res, [
"127.0.0.1" => [
"type" => "BIND",
"username" => "toto",
)));
]]);
}
public function testGet8()
@@ -239,26 +254,26 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
$c = new Config();
$c->confFile = "/tmp/testconf.php";
chmod("/tmp/testconf.php", 0666);
$c->default = array (
"database" => array (
$c->default = [
"database" => [
"dsn" => null,
"user" => null,
"password" => null,
"tableprefix" => ""),
"servers" => array (
"not configured" => array (
"tableprefix" => ""],
"servers" => [
"not configured" => [
"type" => "bind",
"username" => "",
"password" => "",
),
)
);
],
]
];
$res = $c->get("servers");
$this->assertSame($res, array (
"127.0.0.1" => array (
$this->assertSame($res, [
"127.0.0.1" => [
"type" => "BIND",
"username" => "toto",
"password" => "",
)));
]]);
}
}