PSR12
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/** DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
@@ -12,213 +13,242 @@ use Domframework\Inifile;
|
||||
/** Test the Inifile.php file */
|
||||
class InifileTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testsetString001 ()
|
||||
{
|
||||
$this->setExpectedException ("Exception");
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (1, TRUE);
|
||||
}
|
||||
public function testsetString001()
|
||||
{
|
||||
$this->setExpectedException("Exception");
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(1, true);
|
||||
}
|
||||
|
||||
public function testsetString002 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array (), TRUE);
|
||||
$this->assertSame("", $res);
|
||||
}
|
||||
public function testsetString002()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(array (), true);
|
||||
$this->assertSame("", $res);
|
||||
}
|
||||
|
||||
//// TEST OF THE SECTION PART ////
|
||||
public function testsetString103 ()
|
||||
{
|
||||
$this->setExpectedException ("Exception");
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"), TRUE);
|
||||
}
|
||||
public function testsetString103()
|
||||
{
|
||||
$this->setExpectedException("Exception");
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(array ("section1"), true);
|
||||
}
|
||||
|
||||
public function testsetString104 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array ()), TRUE);
|
||||
$this->assertSame("[section1]\n\n", $res);
|
||||
}
|
||||
public function testsetString104()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(array ("section1" => array ()), true);
|
||||
$this->assertSame("[section1]\n\n", $res);
|
||||
}
|
||||
|
||||
public function testsetString105 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array (0)), TRUE);
|
||||
$this->assertSame("[section1]\n0 = \"0\"\n\n", $res);
|
||||
}
|
||||
public function testsetString105()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(array ("section1" => array (0)), true);
|
||||
$this->assertSame("[section1]\n0 = \"0\"\n\n", $res);
|
||||
}
|
||||
|
||||
public function testsetString106 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array (0=>1)), TRUE);
|
||||
$this->assertSame("[section1]\n0 = \"1\"\n\n", $res);
|
||||
}
|
||||
public function testsetString106()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(array ("section1" => array (0 => 1)), true);
|
||||
$this->assertSame("[section1]\n0 = \"1\"\n\n", $res);
|
||||
}
|
||||
|
||||
public function testsetString107 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array (0=>null)), TRUE);
|
||||
$this->assertSame("[section1]\n0 = \"null\"\n\n", $res);
|
||||
}
|
||||
public function testsetString107()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(array ("section1" => array (0 => null)), true);
|
||||
$this->assertSame("[section1]\n0 = \"null\"\n\n", $res);
|
||||
}
|
||||
|
||||
public function testsetString108 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array (0=>null, 1=>1)),
|
||||
TRUE);
|
||||
$this->assertSame("[section1]\n0 = \"null\"\n1 = \"1\"\n\n", $res);
|
||||
}
|
||||
public function testsetString108()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(
|
||||
array ("section1" => array (0 => null, 1 => 1)),
|
||||
true
|
||||
);
|
||||
$this->assertSame("[section1]\n0 = \"null\"\n1 = \"1\"\n\n", $res);
|
||||
}
|
||||
|
||||
public function testsetString109 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
||||
1=>1, 2=>"str")),
|
||||
TRUE);
|
||||
$this->assertSame("[section1]\n0 = \"null\"\n1 = \"1\"\n2 = \"str\"\n\n",
|
||||
$res);
|
||||
}
|
||||
public function testsetString109()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(
|
||||
array ("section1" => array (0 => null,
|
||||
1 => 1, 2 => "str")),
|
||||
true
|
||||
);
|
||||
$this->assertSame(
|
||||
"[section1]\n0 = \"null\"\n1 = \"1\"\n2 = \"str\"\n\n",
|
||||
$res
|
||||
);
|
||||
}
|
||||
|
||||
public function testsetString110 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
||||
1=>1, 2=>"str",
|
||||
3=>array (1,2,3))),
|
||||
TRUE);
|
||||
$this->assertSame("[section1]\n0 = \"null\"\n1 = \"1\"\n2 = \"str\"\n".
|
||||
public function testsetString110()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(
|
||||
array ("section1" => array (0 => null,
|
||||
1 => 1, 2 => "str",
|
||||
3 => array (1,2,3))),
|
||||
true
|
||||
);
|
||||
$this->assertSame(
|
||||
"[section1]\n0 = \"null\"\n1 = \"1\"\n2 = \"str\"\n" .
|
||||
"3[0] = \"1\"\n3[1] = \"2\"\n3[2] = \"3\"\n\n",
|
||||
$res);
|
||||
}
|
||||
$res
|
||||
);
|
||||
}
|
||||
|
||||
public function testsetString111 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
||||
1=>1, 2=>"str",
|
||||
3=>array ())),
|
||||
TRUE);
|
||||
$this->assertSame("[section1]\n0 = \"null\"\n1 = \"1\"\n2 = \"str\"\n\n",
|
||||
$res);
|
||||
}
|
||||
public function testsetString111()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(
|
||||
array ("section1" => array (0 => null,
|
||||
1 => 1, 2 => "str",
|
||||
3 => array ())),
|
||||
true
|
||||
);
|
||||
$this->assertSame(
|
||||
"[section1]\n0 = \"null\"\n1 = \"1\"\n2 = \"str\"\n\n",
|
||||
$res
|
||||
);
|
||||
}
|
||||
|
||||
public function testsetString112 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
||||
1=>1, 2=>"str",
|
||||
"chain"=>array ("key"=>1,2))),
|
||||
TRUE);
|
||||
$this->assertSame("[section1]\n0 = \"null\"\n1 = \"1\"\n2 = \"str\"\n".
|
||||
public function testsetString112()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(
|
||||
array ("section1" => array (0 => null,
|
||||
1 => 1, 2 => "str",
|
||||
"chain" => array ("key" => 1,2))),
|
||||
true
|
||||
);
|
||||
$this->assertSame(
|
||||
"[section1]\n0 = \"null\"\n1 = \"1\"\n2 = \"str\"\n" .
|
||||
"chain[key] = \"1\"\nchain[0] = \"2\"\n\n",
|
||||
$res);
|
||||
}
|
||||
$res
|
||||
);
|
||||
}
|
||||
|
||||
//// TEST OF THE NOT SECTION PART ////
|
||||
public function testsetString203 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"), FALSE);
|
||||
$this->assertSame("0 = \"section1\"\n\n", $res);
|
||||
}
|
||||
public function testsetString203()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(array ("section1"), false);
|
||||
$this->assertSame("0 = \"section1\"\n\n", $res);
|
||||
}
|
||||
|
||||
public function testsetString204 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array ()), FALSE);
|
||||
$this->assertSame("\n", $res);
|
||||
}
|
||||
public function testsetString204()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(array ("section1" => array ()), false);
|
||||
$this->assertSame("\n", $res);
|
||||
}
|
||||
|
||||
public function testsetString205 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array (0)), FALSE);
|
||||
$this->assertSame("section1[0] = \"0\"\n\n", $res);
|
||||
}
|
||||
public function testsetString205()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(array ("section1" => array (0)), false);
|
||||
$this->assertSame("section1[0] = \"0\"\n\n", $res);
|
||||
}
|
||||
|
||||
public function testsetString206 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array (0=>1)), FALSE);
|
||||
$this->assertSame("section1[0] = \"1\"\n\n", $res);
|
||||
}
|
||||
public function testsetString206()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(array ("section1" => array (0 => 1)), false);
|
||||
$this->assertSame("section1[0] = \"1\"\n\n", $res);
|
||||
}
|
||||
|
||||
public function testsetString207 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array (0=>null)), FALSE);
|
||||
$this->assertSame("section1[0] = \"null\"\n\n", $res);
|
||||
}
|
||||
public function testsetString207()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(array ("section1" => array (0 => null)), false);
|
||||
$this->assertSame("section1[0] = \"null\"\n\n", $res);
|
||||
}
|
||||
|
||||
public function testsetString208 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array (0=>null, 1=>1)),
|
||||
FALSE);
|
||||
$this->assertSame("section1[0] = \"null\"\nsection1[1] = \"1\"\n\n",
|
||||
$res);
|
||||
}
|
||||
public function testsetString208()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(
|
||||
array ("section1" => array (0 => null, 1 => 1)),
|
||||
false
|
||||
);
|
||||
$this->assertSame(
|
||||
"section1[0] = \"null\"\nsection1[1] = \"1\"\n\n",
|
||||
$res
|
||||
);
|
||||
}
|
||||
|
||||
public function testsetString209 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
||||
1=>1, 2=>"str")),
|
||||
FALSE);
|
||||
$this->assertSame("section1[0] = \"null\"\nsection1[1] = \"1\"\n".
|
||||
public function testsetString209()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(
|
||||
array ("section1" => array (0 => null,
|
||||
1 => 1, 2 => "str")),
|
||||
false
|
||||
);
|
||||
$this->assertSame(
|
||||
"section1[0] = \"null\"\nsection1[1] = \"1\"\n" .
|
||||
"section1[2] = \"str\"\n\n",
|
||||
$res);
|
||||
}
|
||||
$res
|
||||
);
|
||||
}
|
||||
|
||||
public function testsetString210 ()
|
||||
{
|
||||
$this->setExpectedException ("Exception");
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
||||
1=>1, 2=>"str",
|
||||
3=>array (1,2,3))),
|
||||
FALSE);
|
||||
}
|
||||
public function testsetString210()
|
||||
{
|
||||
$this->setExpectedException("Exception");
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(
|
||||
array ("section1" => array (0 => null,
|
||||
1 => 1, 2 => "str",
|
||||
3 => array (1,2,3))),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
public function testsetString211 ()
|
||||
{
|
||||
$this->setExpectedException ("Exception");
|
||||
$inifile = new Inifile ();
|
||||
$res = $inifile->setString (array ("section1"=>array (0=>null,
|
||||
1=>1, 2=>"str",
|
||||
3=>array ())),
|
||||
FALSE);
|
||||
}
|
||||
public function testsetString211()
|
||||
{
|
||||
$this->setExpectedException("Exception");
|
||||
$inifile = new Inifile();
|
||||
$res = $inifile->setString(
|
||||
array ("section1" => array (0 => null,
|
||||
1 => 1, 2 => "str",
|
||||
3 => array ())),
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
//// LOOP TEST : CREATE AN INI STRING AND PARSE IT ////
|
||||
public function testLoop406 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$loop = $inifile->setString (array ("section1"=>array (0=>1)), FALSE);
|
||||
var_dump ($loop);
|
||||
$res = $inifile->getString ($loop, FALSE);
|
||||
var_dump ($res);
|
||||
$this->assertSame(array ("section1"=>array (0=>1)), $res);
|
||||
}
|
||||
public function testLoop406()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$loop = $inifile->setString(array ("section1" => array (0 => 1)), false);
|
||||
var_dump($loop);
|
||||
$res = $inifile->getString($loop, false);
|
||||
var_dump($res);
|
||||
$this->assertSame(array ("section1" => array (0 => 1)), $res);
|
||||
}
|
||||
|
||||
public function testLoop407 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$loop = $inifile->setString (array ("section1"=>array (0=>null)), FALSE);
|
||||
$res = $inifile->getString ($loop, FALSE);
|
||||
$this->assertSame(array ("section1"=>array (0=>null)), $res);
|
||||
}
|
||||
|
||||
public function testLoop408 ()
|
||||
{
|
||||
$inifile = new Inifile ();
|
||||
$loop = $inifile->setString (array ("section1"=>array (0=>"toto")), FALSE);
|
||||
var_dump ($loop);
|
||||
$res = $inifile->getString ($loop, FALSE);
|
||||
var_dump ($res);
|
||||
$this->assertSame(array ("section1"=>array (0=>"toto")), $res);
|
||||
}
|
||||
public function testLoop407()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$loop = $inifile->setString(array ("section1" => array (0 => null)), false);
|
||||
$res = $inifile->getString($loop, false);
|
||||
$this->assertSame(array ("section1" => array (0 => null)), $res);
|
||||
}
|
||||
|
||||
public function testLoop408()
|
||||
{
|
||||
$inifile = new Inifile();
|
||||
$loop = $inifile->setString(array ("section1" => array (0 => "toto")), false);
|
||||
var_dump($loop);
|
||||
$res = $inifile->getString($loop, false);
|
||||
var_dump($res);
|
||||
$this->assertSame(array ("section1" => array (0 => "toto")), $res);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user