Tests are now compliant with php-cs-fixer (CamelCase for method, phpdoc valid)
This commit is contained in:
@@ -1,183 +1,186 @@
|
||||
<?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\Getopts;
|
||||
|
||||
/** Test the GetOpts */
|
||||
/**
|
||||
* Test the GetOpts
|
||||
*/
|
||||
class GetoptsTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_empty1()
|
||||
public function testEmpty1()
|
||||
{
|
||||
// Empty
|
||||
// Empty
|
||||
$getopts = new Getopts();
|
||||
$res = $getopts->help();
|
||||
$this->assertSame($res, "No option defined\n");
|
||||
}
|
||||
|
||||
public function test_simu1()
|
||||
public function testSimu1()
|
||||
{
|
||||
$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()
|
||||
public function testAdd1()
|
||||
{
|
||||
$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");
|
||||
$res = $getopts->add("Help", "?h", ["help","help2"], "Help of the software");
|
||||
$this->assertSame(is_object($res), true);
|
||||
}
|
||||
|
||||
public function test_add2()
|
||||
public function testAdd2()
|
||||
{
|
||||
$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("Help", "?h", ["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()
|
||||
public function testScan1()
|
||||
{
|
||||
$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("Help", "?h", ["help","help2"], "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->scan();
|
||||
}
|
||||
|
||||
public function test_getShort1()
|
||||
public function testGetShort1()
|
||||
{
|
||||
// One unique value (-h -> true/false)
|
||||
// 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("Help", "?h", ["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()
|
||||
public function testGetShort2()
|
||||
{
|
||||
// Multiple values, two set (-d -d)
|
||||
// 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("Help", "?h", ["help","help2"], "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get("Debug");
|
||||
$this->assertSame($res, array (true,true));
|
||||
$this->assertSame($res, [true,true]);
|
||||
}
|
||||
|
||||
public function test_getShort3()
|
||||
public function testGetShort3()
|
||||
{
|
||||
// Multiple values, one set (-d)
|
||||
// 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("Help", "?h", ["help","help2"], "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get("Debug");
|
||||
$this->assertSame($res, array (true));
|
||||
$this->assertSame($res, [true]);
|
||||
}
|
||||
|
||||
public function test_getShort4()
|
||||
public function testGetShort4()
|
||||
{
|
||||
// Multiple values, None set (-d)
|
||||
// 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("Help", "?h", ["help","help2"], "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get("Debug");
|
||||
$this->assertSame($res, array ());
|
||||
$this->assertSame($res, []);
|
||||
}
|
||||
|
||||
public function test_getLong1()
|
||||
public function testGetLong1()
|
||||
{
|
||||
// One unique value (--help -> true/false)
|
||||
// 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("Help", "?h", ["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()
|
||||
public function testGetLong2()
|
||||
{
|
||||
// Multiple values, two set (-debug --debug)
|
||||
// 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("Help", "?h", ["help","help2"], "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get("Debug");
|
||||
$this->assertSame($res, array (true,true));
|
||||
$this->assertSame($res, [true,true]);
|
||||
}
|
||||
|
||||
public function test_getLong3()
|
||||
public function testGetLong3()
|
||||
{
|
||||
// Multiple values, one set (-d)
|
||||
// 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("Help", "?h", ["help","help2"], "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get("Debug");
|
||||
$this->assertSame($res, array (true));
|
||||
$this->assertSame($res, [true]);
|
||||
}
|
||||
|
||||
public function test_getLong4()
|
||||
public function testGetLong4()
|
||||
{
|
||||
// Multiple values, None set (-d)
|
||||
// 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("Help", "?h", ["help","help2"], "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->get("Debug");
|
||||
$this->assertSame($res, array ());
|
||||
$this->assertSame($res, []);
|
||||
}
|
||||
|
||||
public function test_restOfLine1()
|
||||
public function testRestOfLine1()
|
||||
{
|
||||
$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("Help", "?h", ["help","help2"], "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->restOfLine();
|
||||
$this->assertSame($res, array ("-bla", "final"));
|
||||
$this->assertSame($res, ["-bla", "final"]);
|
||||
}
|
||||
|
||||
public function test_restOfLine2()
|
||||
public function testRestOfLine2()
|
||||
{
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate bla final");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add("Help", "?h", ["help","help2"], "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->restOfLine();
|
||||
$this->assertSame($res, array ("bla", "final"));
|
||||
$this->assertSame($res, ["bla", "final"]);
|
||||
}
|
||||
|
||||
public function test_restOfLine3()
|
||||
public function testRestOfLine3()
|
||||
{
|
||||
$getopts = new Getopts();
|
||||
$getopts->simulate("sim\ ulate -- -bla final");
|
||||
$getopts->add("Help", "?h", array ("help","help2"), "Help of the software");
|
||||
$getopts->add("Help", "?h", ["help","help2"], "Help of the software");
|
||||
$getopts->add("Debug", "d", "debug", "Debug", "DebugLevel", 2);
|
||||
$res = $getopts->restOfLine();
|
||||
$this->assertSame($res, array ("-bla", "final"));
|
||||
$this->assertSame($res, ["-bla", "final"]);
|
||||
}
|
||||
|
||||
public function test_programName1()
|
||||
public function testProgramName1()
|
||||
{
|
||||
$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("Help", "?h", ["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