PSR12
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/** DomFramework - Tests
|
||||
* @package domframework
|
||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||
@@ -12,173 +13,173 @@ use Domframework\Getopts;
|
||||
/** Test the GetOpts */
|
||||
class GetoptsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_empty1 ()
|
||||
{
|
||||
// Empty
|
||||
$getopts = new Getopts ();
|
||||
$res = $getopts->help ();
|
||||
$this->assertSame ($res, "No option defined\n");
|
||||
}
|
||||
public function test_empty1()
|
||||
{
|
||||
// Empty
|
||||
$getopts = new Getopts();
|
||||
$res = $getopts->help();
|
||||
$this->assertSame($res, "No option defined\n");
|
||||
}
|
||||
|
||||
public function test_simu1 ()
|
||||
{
|
||||
$getopts = new Getopts ();
|
||||
$res = $getopts->simulate ("sim\ ulate -h -d -d -f ii -o 1\ 2 -o \"2 2\" -o 3 -- -bla final");
|
||||
$this->assertSame (is_object ($res), true);
|
||||
}
|
||||
public function test_simu1()
|
||||
{
|
||||
$getopts = new Getopts();
|
||||
$res = $getopts->simulate("sim\ ulate -h -d -d -f ii -o 1\ 2 -o \"2 2\" -o 3 -- -bla final");
|
||||
$this->assertSame(is_object($res), true);
|
||||
}
|
||||
|
||||
public function test_add1 ()
|
||||
{
|
||||
$getopts = new Getopts ();
|
||||
$getopts->simulate ("sim\ ulate -h -d -d -f ii -o 1\ 2 -o \"2 2\" -o 3 -- -bla final");
|
||||
$res = $getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$this->assertSame (is_object ($res), true);
|
||||
}
|
||||
public function test_add1()
|
||||
{
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate -h -d -d -f ii -o 1\ 2 -o \"2 2\" -o 3 -- -bla final");
|
||||
$res = $getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$this->assertSame(is_object($res), true);
|
||||
}
|
||||
|
||||
public function test_add2 ()
|
||||
{
|
||||
$getopts = new Getopts ();
|
||||
$getopts->simulate ("sim\ ulate -h -d -d -f ii -o 1\ 2 -o \"2 2\" -o 3 -- -bla final");
|
||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$res = $getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$this->assertSame (is_object ($res), true);
|
||||
}
|
||||
public function test_add2()
|
||||
{
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate -h -d -d -f ii -o 1\ 2 -o \"2 2\" -o 3 -- -bla final");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$res = $getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$this->assertSame(is_object($res), true);
|
||||
}
|
||||
|
||||
public function test_scan1 ()
|
||||
{
|
||||
$this->expectException ("Exception", "Provided tokens are not known: -f,-o,-o,-o");
|
||||
$getopts = new Getopts ();
|
||||
$getopts->simulate ("sim\ ulate -h -d -d -f ii -o 1\ 2 -o \"2 2\" -o 3 -- -bla final");
|
||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->scan ();
|
||||
}
|
||||
public function test_scan1()
|
||||
{
|
||||
$this->expectException("Exception", "Provided tokens are not known: -f,-o,-o,-o");
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate -h -d -d -f ii -o 1\ 2 -o \"2 2\" -o 3 -- -bla final");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->scan();
|
||||
}
|
||||
|
||||
public function test_getShort1 ()
|
||||
{
|
||||
// One unique value (-h -> true/false)
|
||||
$getopts = new Getopts ();
|
||||
$getopts->simulate ("sim\ ulate -h -d -d ");
|
||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get ("Help");
|
||||
$this->assertSame ($res, true);
|
||||
}
|
||||
public function test_getShort1()
|
||||
{
|
||||
// One unique value (-h -> true/false)
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate -h -d -d ");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get("Help");
|
||||
$this->assertSame($res, true);
|
||||
}
|
||||
|
||||
public function test_getShort2 ()
|
||||
{
|
||||
// Multiple values, two set (-d -d)
|
||||
$getopts = new Getopts ();
|
||||
$getopts->simulate ("sim\ ulate -h -d -d ");
|
||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get ("Debug");
|
||||
$this->assertSame ($res, array (true,true));
|
||||
}
|
||||
public function test_getShort2()
|
||||
{
|
||||
// Multiple values, two set (-d -d)
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate -h -d -d ");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get("Debug");
|
||||
$this->assertSame($res, array (true,true));
|
||||
}
|
||||
|
||||
public function test_getShort3 ()
|
||||
{
|
||||
// Multiple values, one set (-d)
|
||||
$getopts = new Getopts ();
|
||||
$getopts->simulate ("sim\ ulate -h -d ");
|
||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get ("Debug");
|
||||
$this->assertSame ($res, array (true));
|
||||
}
|
||||
public function test_getShort3()
|
||||
{
|
||||
// Multiple values, one set (-d)
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate -h -d ");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get("Debug");
|
||||
$this->assertSame($res, array (true));
|
||||
}
|
||||
|
||||
public function test_getShort4 ()
|
||||
{
|
||||
// Multiple values, None set (-d)
|
||||
$getopts = new Getopts ();
|
||||
$getopts->simulate ("sim\ ulate -h ");
|
||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get ("Debug");
|
||||
$this->assertSame ($res, array ());
|
||||
}
|
||||
public function test_getShort4()
|
||||
{
|
||||
// Multiple values, None set (-d)
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate -h ");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get("Debug");
|
||||
$this->assertSame($res, array ());
|
||||
}
|
||||
|
||||
public function test_getLong1 ()
|
||||
{
|
||||
// One unique value (--help -> true/false)
|
||||
$getopts = new Getopts ();
|
||||
$getopts->simulate ("sim\ ulate --help -d -d ");
|
||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get ("Help");
|
||||
$this->assertSame ($res, true);
|
||||
}
|
||||
public function test_getLong1()
|
||||
{
|
||||
// One unique value (--help -> true/false)
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate --help -d -d ");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get("Help");
|
||||
$this->assertSame($res, true);
|
||||
}
|
||||
|
||||
public function test_getLong2 ()
|
||||
{
|
||||
// Multiple values, two set (-debug --debug)
|
||||
$getopts = new Getopts ();
|
||||
$getopts->simulate ("sim\ ulate -h --debug --debug ");
|
||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get ("Debug");
|
||||
$this->assertSame ($res, array (true,true));
|
||||
}
|
||||
public function test_getLong2()
|
||||
{
|
||||
// Multiple values, two set (-debug --debug)
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate -h --debug --debug ");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get("Debug");
|
||||
$this->assertSame($res, array (true,true));
|
||||
}
|
||||
|
||||
public function test_getLong3 ()
|
||||
{
|
||||
// Multiple values, one set (-d)
|
||||
$getopts = new Getopts ();
|
||||
$getopts->simulate ("sim\ ulate --help -d ");
|
||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get ("Debug");
|
||||
$this->assertSame ($res, array (true));
|
||||
}
|
||||
public function test_getLong3()
|
||||
{
|
||||
// Multiple values, one set (-d)
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate --help -d ");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get("Debug");
|
||||
$this->assertSame($res, array (true));
|
||||
}
|
||||
|
||||
public function test_getLong4 ()
|
||||
{
|
||||
// Multiple values, None set (-d)
|
||||
$getopts = new Getopts ();
|
||||
$getopts->simulate ("sim\ ulate -h");
|
||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get ("Debug");
|
||||
$this->assertSame ($res, array ());
|
||||
}
|
||||
public function test_getLong4()
|
||||
{
|
||||
// Multiple values, None set (-d)
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate -h");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get("Debug");
|
||||
$this->assertSame($res, array ());
|
||||
}
|
||||
|
||||
public function test_restOfLine1 ()
|
||||
{
|
||||
$getopts = new Getopts ();
|
||||
$getopts->simulate ("sim\ ulate -h -d -d -- -bla final");
|
||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->restOfLine ();
|
||||
$this->assertSame ($res, array ("-bla", "final"));
|
||||
}
|
||||
public function test_restOfLine1()
|
||||
{
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate -h -d -d -- -bla final");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->restOfLine();
|
||||
$this->assertSame($res, array ("-bla", "final"));
|
||||
}
|
||||
|
||||
public function test_restOfLine2 ()
|
||||
{
|
||||
$getopts = new Getopts ();
|
||||
$getopts->simulate ("sim\ ulate bla final");
|
||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->restOfLine ();
|
||||
$this->assertSame ($res, array ("bla", "final"));
|
||||
}
|
||||
public function test_restOfLine2()
|
||||
{
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate bla final");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->restOfLine();
|
||||
$this->assertSame($res, array ("bla", "final"));
|
||||
}
|
||||
|
||||
public function test_restOfLine3 ()
|
||||
{
|
||||
$getopts = new Getopts ();
|
||||
$getopts->simulate ("sim\ ulate -- -bla final");
|
||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->restOfLine ();
|
||||
$this->assertSame ($res, array ("-bla", "final"));
|
||||
}
|
||||
public function test_restOfLine3()
|
||||
{
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate -- -bla final");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->restOfLine();
|
||||
$this->assertSame($res, array ("-bla", "final"));
|
||||
}
|
||||
|
||||
public function test_programName1 ()
|
||||
{
|
||||
$getopts = new Getopts ();
|
||||
$getopts->simulate ("sim\ ulate -h -d -d -- -bla final");
|
||||
$getopts->add ("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add ("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->programName ();
|
||||
$this->assertSame ($res, "sim ulate");
|
||||
}
|
||||
public function test_programName1()
|
||||
{
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate -h -d -d -- -bla final");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->programName();
|
||||
$this->assertSame($res, "sim ulate");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user