[php-pear-Console-Getargs] fix FTBFS, update tests suite from git

Remi Collet remi at fedoraproject.org
Mon Jan 16 09:06:29 UTC 2012


commit db53a391b8b458b3315c068b918a931cb86b5d4f
Author: remi <fedora at famillecollet.com>
Date:   Mon Jan 16 10:06:02 2012 +0100

    fix FTBFS, update tests suite from git

 .gitignore                    |    2 +-
 Console_Getargs-git.patch     | 1618 +++++++++++++++++++++++++++++++++++++++++
 php-pear-Console-Getargs.spec |   21 +-
 xml2changelog                 |   21 +-
 4 files changed, 1644 insertions(+), 18 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index d0f5a43..21dad5a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
-Console_Getargs-1.3.4.tgz
+*spec~
 package.xml
 /Console_Getargs-1.3.5.tgz
diff --git a/Console_Getargs-git.patch b/Console_Getargs-git.patch
new file mode 100644
index 0000000..3dcd097
--- /dev/null
+++ b/Console_Getargs-git.patch
@@ -0,0 +1,1618 @@
+diff -ruN Console_Getargs-1.3.5/tests.old/AllTests.php Console_Getargs-1.3.5/tests/AllTests.php
+--- Console_Getargs-1.3.5/tests.old/AllTests.php	1970-01-01 10:13:08.000000000 +0100
++++ Console_Getargs-1.3.5/tests/AllTests.php	1970-01-01 01:00:00.000000000 +0100
+@@ -1,56 +0,0 @@
+-<?php
+-/* vim: set expandtab tabstop=4 shiftwidth=4: */
+-// +----------------------------------------------------------------------+
+-// | PHP Version 4                                                        |
+-// +----------------------------------------------------------------------+
+-// | Copyright (c) 2004 The PHP Group                                     |
+-// +----------------------------------------------------------------------+
+-// | This source file is subject to version 3.0 of the PHP license,       |
+-// | that is bundled with this package in the file LICENSE, and is        |
+-// | available through the world-wide-web at the following url:           |
+-// | http://www.php.net/license/3_0.txt.                                  |
+-// | If you did not receive a copy of the PHP license and are unable to   |
+-// | obtain it through the world-wide-web, please send a note to          |
+-// | license at php.net so we can mail you a copy immediately.               |
+-// +----------------------------------------------------------------------+
+-// | Author: Bertrand Mansion <bmansion at mamasam.com>                      |
+-// +----------------------------------------------------------------------+
+-//
+-// $Id: AllTests.php 294988 2010-02-12 04:57:14Z clockwerx $
+-
+-/**
+- * Unit tests for Console_Getargs package.
+- */
+-if (!defined('PHPUnit_MAIN_METHOD')) {
+-    define('PHPUnit_MAIN_METHOD', 'Console_Getargs_AllTests::main');
+-}
+-
+-require_once 'PHPUnit/TextUI/TestRunner.php';
+-
+-
+-chdir(dirname(__FILE__) . '/../');
+-require_once 'Getargs_basic_testcase.php';
+-require_once 'Getargs_getValues_testcase.php';
+-
+-class Console_Getargs_AllTests
+-{
+-    public static function main()
+-    {
+-        PHPUnit_TextUI_TestRunner::run(self::suite());
+-    }
+-
+-    public static function suite()
+-    {
+-        $suite = new PHPUnit_Framework_TestSuite('Console_Getargs Tests');
+-        /** Add testsuites, if there is. */
+-        $suite->addTestSuite('Getargs_basic_testcase');
+-        $suite->addTestSuite('Getargs_getValues_testcase');
+-
+-        return $suite;
+-    }
+-}
+-
+-if (PHPUnit_MAIN_METHOD == 'Console_Getargs_AllTests::main') {
+-    Console_Getargs_AllTests::main();
+-}
+-?>
+diff -ruN Console_Getargs-1.3.5/tests.old/Getargs_basic_testcase.php Console_Getargs-1.3.5/tests/Getargs_basic_testcase.php
+--- Console_Getargs-1.3.5/tests.old/Getargs_basic_testcase.php	1970-01-01 10:13:08.000000000 +0100
++++ Console_Getargs-1.3.5/tests/Getargs_basic_testcase.php	1970-01-01 01:00:00.000000000 +0100
+@@ -1,478 +0,0 @@
+-<?php
+-/* vim: set expandtab tabstop=4 shiftwidth=4: */
+-// +----------------------------------------------------------------------+
+-// | PHP Version 4                                                        |
+-// +----------------------------------------------------------------------+
+-// | Copyright (c) 2004 The PHP Group                                     |
+-// +----------------------------------------------------------------------+
+-// | This source file is subject to version 3.0 of the PHP license,       |
+-// | that is bundled with this package in the file LICENSE, and is        |
+-// | available through the world-wide-web at the following url:           |
+-// | http://www.php.net/license/3_0.txt.                                  |
+-// | If you did not receive a copy of the PHP license and are unable to   |
+-// | obtain it through the world-wide-web, please send a note to          |
+-// | license at php.net so we can mail you a copy immediately.               |
+-// +----------------------------------------------------------------------+
+-// | Author: Bertrand Mansion <bmansion at mamasam.com>                      |
+-// +----------------------------------------------------------------------+
+-//
+-// $Id: Getargs_basic_testcase.php 304307 2010-10-11 11:28:02Z jespino $
+-if (!defined('PHPUnit_MAIN_METHOD')) {
+-    define('PHPUnit_MAIN_METHOD', 'Getargs_Basic_testCase::main');
+-}
+-
+-require_once 'Console/Getargs.php';
+-require_once 'PHPUnit/Framework.php';
+-
+-/**
+- * Unit tests for Console_Getargs package.
+- */
+-
+-class Getargs_Basic_testCase extends PHPUnit_Framework_TestCase
+-{
+-    /**
+-     * Runs the test methods of this class.
+-     *
+-     * @access public
+-     * @static
+-     */
+-    public static function main() {
+-        require_once 'PHPUnit/TextUI/TestRunner.php';
+-
+-        $suite  = new PHPUnit_Framework_TestSuite('Getargs_Basic_testCase');
+-        PHPUnit_TextUI_TestRunner::run($suite);
+-    }
+-
+-
+-
+-    function testFixed1()
+-    {
+-        $config = array(
+-                    'name' => array(
+-                        'short' => 'n',
+-                        'min'   => 1,
+-                        'max'   => 1,
+-                        'desc'  => 'An argument.')
+-                       );
+-
+-        $args = array('-n', 'arg1');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' ".$obj->getMessage());
+-        } else {
+-            $this->assertEquals($args[1], $obj->getValue('n'), "'$message' Incorrect value returned");
+-        }
+-
+-        $args = array('--name', 'arg1');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' ".$obj->getMessage());
+-        } else {
+-            $this->assertEquals($args[1], $obj->getValue('name'), "'$message' Incorrect value returned");
+-        }
+-    }
+-
+-    function testFixed2()
+-    {
+-        $config = array(
+-                    'name' => array(
+-                        'short' => 'n',
+-                        'min'   => 2,
+-                        'max'   => 2,
+-                        'desc'  => 'Two arguments.')
+-                       );
+-
+-        $args = array('-n', 'arg1', 'arg2');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' ".$obj->getMessage());
+-        } else {
+-            $this->assertEquals(array($args[1], $args[2]), $obj->getValue('n'), "'$message' Incorrect value returned");
+-        }
+-
+-        $args = array('--name', 'arg1', 'arg2');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' ".$obj->getMessage());
+-        } else {
+-            $this->assertEquals(array($args[1], $args[2]), $obj->getValue('name'), "'$message' Incorrect value returned");
+-        }
+-
+-    }
+-
+-    function testFixed1WithDefault()
+-    {
+-        $config = array(
+-                    'name' => array(
+-                       'min'     => 1,
+-                       'max'     => 1,
+-                       'desc'    => 'Fixed number with default value if not used.',
+-                       'default' => 'default1')
+-                       );
+-
+-        $args = array('--name', 'arg1');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' ".$obj->getMessage());
+-        } else {
+-            $this->assertEquals($args[1], $obj->getValue('name'), "'$message' Incorrect value returned");
+-        }
+-
+-        $args = array();
+-
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail($obj->getMessage());
+-        } else {
+-            $this->assertEquals('default1', $obj->getValue('name'), "Incorrect value returned");
+-        }
+-
+-    }
+-
+-    function testFixed2WithDefault()
+-    {
+-        $config = array(
+-                    'names' => array(
+-                       'min'     => 2,
+-                       'max'     => 2,
+-                       'desc'    => 'Fixed number with default values if not used.',
+-                       'default' => array('default1', 'default2'))
+-                       );
+-
+-        $args = array('--names', 'arg1', 'arg2');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' ".$obj->getMessage());
+-        } else {
+-            $this->assertEquals(array($args[1], $args[2]), $obj->getValue('names'), "'$message' Incorrect value returned");
+-        }
+-
+-        $args = array();
+-
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail($obj->getMessage());
+-        } else {
+-            $this->assertEquals(array('default1', 'default2'), $obj->getValue('names'), "Incorrect value returned");
+-        }
+-
+-    }
+-
+-    function testSwitch()
+-    {
+-        $config = array(
+-                    'switch' => array(
+-                        'short' => 's',
+-                        'max'   => 0,
+-                        'desc'  => 'A switch.')
+-                        );
+-
+-        $args = array('-s');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' ".$obj->getMessage());
+-        } else {
+-            $this->assertTrue($obj->isDefined('s'), "'$message' Switch not defined");
+-            $this->assertTrue($obj->isDefined('switch'), "'$message' Switch not defined");
+-        }
+-
+-        $args = array('--switch');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' ".$obj->getMessage());
+-        } else {
+-            $this->assertTrue($obj->isDefined('s'), "'$message' Switch not defined");
+-            $this->assertTrue($obj->isDefined('switch'), "'$message' Switch not defined");
+-        }
+-
+-    }
+-
+-    function testSwitchWithDefaultIfValueNotSet()
+-    {
+-        $config = array(
+-                    'default' => array(
+-                        'short'   => 'd',
+-                        'min'     => 0,
+-                        'max'     => 1,
+-                        'desc'    => 'A switch with a default value if no value set.',
+-                        'default' => 3)
+-                        );
+-
+-        $args = array('-d');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' ".$obj->getMessage());
+-        } else {
+-            $this->assertEquals(3, $obj->getValue('d'), "'$message' Incorrect value returned");
+-            $this->assertEquals(3, $obj->getValue('default'), "'$message' Incorrect value returned");
+-        }
+-
+-        $args = array('-d', 4);
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' ".$obj->getMessage());
+-        } else {
+-            $this->assertEquals(4, $obj->getValue('d'), "'$message' Incorrect value returned");
+-            $this->assertEquals(4, $obj->getValue('default'), "'$message' Incorrect value returned");
+-        }
+-    }
+-
+-    function testVariable1_3()
+-    {
+-        $config = array(
+-                    'name' => array(
+-                        'min' => 1,
+-                        'max' => 3,
+-                        'desc' => 'One to three values.')
+-                        );
+-        
+-        $args = array('--name', 'arg1');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' ".$obj->getMessage());
+-        } else {
+-            $this->assertEquals('arg1', $obj->getValue('name'), "'$message' Incorrect value returned");
+-        }
+-
+-        $args = array('--name', 'arg1', 'arg2', 'arg3');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' ".$obj->getMessage());
+-        } else {
+-            $this->assertEquals(array('arg1', 'arg2', 'arg3'), $obj->getValue('name'), "'$message' Incorrect values returned");
+-        }
+-
+-    }
+-
+-    function testVariable1_3WithDefault()
+-    {
+-        // TODO : using min => 0 should maybe work too
+-        $config = array(
+-                    'name' => array(
+-                        'min'     => 1,
+-                        'max'     => 3,
+-                        'desc'    => 'Zero to three values using default if no values set.',
+-                        'default' => 'default1')
+-                        );
+-        
+-        $args = array('--name', 'arg1');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' ".$obj->getMessage());
+-        } else {
+-            $this->assertEquals('arg1', $obj->getValue('name'), "'$message' Incorrect value returned");
+-        }
+-
+-        $args = array('--name', 'arg1', 'arg2', 'arg3');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' ".$obj->getMessage());
+-        } else {
+-            $this->assertEquals(array('arg1', 'arg2', 'arg3'), $obj->getValue('name'), "'$message' Incorrect values returned");
+-        }
+-
+-        $args = array();
+-
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail($obj->getMessage());
+-        } else {
+-            $this->assertEquals('default1', $obj->getValue('name'), "'$message' Incorrect values returned");
+-        }
+-
+-    }
+-
+-    function testNoLimit()
+-    {
+-        $config = array(
+-                    'name' => array(
+-                        'min'     => 1,
+-                        'max'     => -1,
+-                        'desc'    => 'Unlimited number of values.')
+-                        );
+-        
+-        $args = array('--name', 'arg1');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' ".$obj->getMessage());
+-        } else {
+-            $this->assertEquals('arg1', $obj->getValue('name'), "'$message' Incorrect value returned");
+-        }
+-
+-        $args = array('--name', 'arg1', 'arg2', 'arg3');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail($obj->getMessage());
+-        } else {
+-            $this->assertEquals(array('arg1', 'arg2', 'arg3'), $obj->getValue('name'), "'$message' Incorrect values returned");
+-        }
+-    }
+-
+-    function testNoLimitWithDefault()
+-    {
+-        $config = array(
+-                    'name' => array(
+-                        'min'     => 1,
+-                        'max'     => -1,
+-                        'desc'    => 'Unlimited number of values.',
+-                        'default' => 'default1')
+-                        );
+-
+-        $args = array();
+-
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail($obj->getMessage());
+-        } else {
+-            $this->assertEquals('default1', $obj->getValue('name'), "Incorrect values returned");
+-        }
+-    }
+-
+-    function testAlias()
+-    {
+-        $config = array(
+-                    'name|alias' => array(
+-                        'short'   => 'n|a',
+-                        'min'     => 0,
+-                        'max'     => 0,
+-                        'desc'    => 'Unlimited number of values with alias.')
+-                        );
+-
+-        $args = array('-n', '-a', '--name', '--alias');
+-        foreach ($args as $arg) {
+-            $message = $arg;
+-            $obj =& Console_Getargs::factory($config, array($arg));
+-    
+-            if (PEAR::isError($obj)) {
+-                $this->fail($obj->getMessage());
+-            } else {
+-                $this->assertTrue($obj->isDefined('name'), "Value 'name' is not defined");
+-                $this->assertTrue($obj->isDefined('alias'), "Value 'alias' is not defined");
+-                $this->assertTrue($obj->isDefined('n'), "Value 'n' is not defined");
+-                $this->assertTrue($obj->isDefined('a'), "Value 'a' is not defined");
+-            }
+-        }
+-    }
+-
+-
+-
+-    /**
+-    * isDefined should return true when the parameter is passed on cmdline
+-    */
+-    function testIsDefined()
+-    {
+-        $config = array(
+-            'name' => array(
+-                'short'   => 'n',
+-                'min'     => 1,
+-                'max'     => 1,
+-                'desc'    => 'An argument.',
+-                'default' => 'john'
+-            )
+-        );
+-
+-        $args = array('-n', 'arg1');
+-        $obj  =& Console_Getargs::factory($config, $args);
+-
+-        $this->assertFalse(PEAR::isError($obj));
+-        $this->assertTrue($obj->isDefined('n'));
+-        $this->assertTrue($obj->isDefined('name'));
+-    }
+-
+-
+-
+-    /**
+-    * isDefined should return true when the parameter is passed on cmdline,
+-    * even when checking for the alias name
+-    */
+-    function testIsDefinedAlias()
+-    {
+-        $config = array(
+-            'name|alias' => array(
+-                'short'   => 'n',
+-                'min'     => 1,
+-                'max'     => 1,
+-                'desc'    => 'An argument.',
+-                'default' => 'john'
+-            )
+-        );
+-
+-        $args = array('-n', 'arg1');
+-        $obj  =& Console_Getargs::factory($config, $args);
+-
+-        $this->assertFalse(PEAR::isError($obj));
+-        $this->assertTrue($obj->isDefined('n'));
+-        $this->assertTrue($obj->isDefined('name'));
+-        $this->assertTrue($obj->isDefined('alias'));
+-    }
+-
+-
+-
+-    /**
+-    * isDefined should return false when the parameter is not
+-    * given on cmdline - even if there is a default value
+-    */
+-    function testIsDefinedDefaultOnly()
+-    {
+-        $config = array(
+-            'name' => array(
+-                'short'   => 'n',
+-                'min'     => 1,
+-                'max'     => 1,
+-                'desc'    => 'An argument.',
+-                'default' => 'john'
+-            )
+-        );
+-
+-        $args = array();
+-        $obj  =& Console_Getargs::factory($config, $args);
+-
+-        $this->assertFalse(PEAR::isError($obj));
+-        $this->assertFalse($obj->isDefined('n'));
+-        $this->assertFalse($obj->isDefined('name'));
+-    }
+-
+-
+-}
+-
+-if (PHPUnit_MAIN_METHOD == 'Getargs_Basic_testCase::main') {
+-    Getargs_Basic_testCase::main();
+-}
+-
+-?>
+diff -ruN Console_Getargs-1.3.5/tests.old/Getargs_BasicTest.php Console_Getargs-1.3.5/tests/Getargs_BasicTest.php
+--- Console_Getargs-1.3.5/tests.old/Getargs_BasicTest.php	1970-01-01 01:00:00.000000000 +0100
++++ Console_Getargs-1.3.5/tests/Getargs_BasicTest.php	2012-01-16 09:48:50.000000000 +0100
+@@ -0,0 +1,458 @@
++<?php
++/* vim: set expandtab tabstop=4 shiftwidth=4: */
++// +----------------------------------------------------------------------+
++// | PHP Version 4                                                        |
++// +----------------------------------------------------------------------+
++// | Copyright (c) 2004 The PHP Group                                     |
++// +----------------------------------------------------------------------+
++// | This source file is subject to version 3.0 of the PHP license,       |
++// | that is bundled with this package in the file LICENSE, and is        |
++// | available through the world-wide-web at the following url:           |
++// | http://www.php.net/license/3_0.txt.                                  |
++// | If you did not receive a copy of the PHP license and are unable to   |
++// | obtain it through the world-wide-web, please send a note to          |
++// | license at php.net so we can mail you a copy immediately.               |
++// +----------------------------------------------------------------------+
++// | Author: Bertrand Mansion <bmansion at mamasam.com>                      |
++// +----------------------------------------------------------------------+
++//
++// $Id$
++if (!defined('PHPUnit_MAIN_METHOD')) {
++    define('PHPUnit_MAIN_METHOD', 'Getargs_Basic_testCase::main');
++}
++
++require_once 'Console/Getargs.php';
++require_once 'PHPUnit/Framework/TestCase.php';
++
++/**
++ * Unit tests for Console_Getargs package.
++ */
++
++class Getargs_BasicTest extends PHPUnit_Framework_TestCase
++{
++    function testFixed1()
++    {
++        $config = array(
++                    'name' => array(
++                        'short' => 'n',
++                        'min'   => 1,
++                        'max'   => 1,
++                        'desc'  => 'An argument.')
++                       );
++
++        $args = array('-n', 'arg1');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' ".$obj->getMessage());
++        } else {
++            $this->assertEquals($args[1], $obj->getValue('n'), "'$message' Incorrect value returned");
++        }
++
++        $args = array('--name', 'arg1');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' ".$obj->getMessage());
++        } else {
++            $this->assertEquals($args[1], $obj->getValue('name'), "'$message' Incorrect value returned");
++        }
++    }
++
++    function testFixed2()
++    {
++        $config = array(
++                    'name' => array(
++                        'short' => 'n',
++                        'min'   => 2,
++                        'max'   => 2,
++                        'desc'  => 'Two arguments.')
++                       );
++
++        $args = array('-n', 'arg1', 'arg2');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' ".$obj->getMessage());
++        } else {
++            $this->assertEquals(array($args[1], $args[2]), $obj->getValue('n'), "'$message' Incorrect value returned");
++        }
++
++        $args = array('--name', 'arg1', 'arg2');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' ".$obj->getMessage());
++        } else {
++            $this->assertEquals(array($args[1], $args[2]), $obj->getValue('name'), "'$message' Incorrect value returned");
++        }
++
++    }
++
++    function testFixed1WithDefault()
++    {
++        $config = array(
++                    'name' => array(
++                       'min'     => 1,
++                       'max'     => 1,
++                       'desc'    => 'Fixed number with default value if not used.',
++                       'default' => 'default1')
++                       );
++
++        $args = array('--name', 'arg1');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' ".$obj->getMessage());
++        } else {
++            $this->assertEquals($args[1], $obj->getValue('name'), "'$message' Incorrect value returned");
++        }
++
++        $args = array();
++
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail($obj->getMessage());
++        } else {
++            $this->assertEquals('default1', $obj->getValue('name'), "Incorrect value returned");
++        }
++
++    }
++
++    function testFixed2WithDefault()
++    {
++        $config = array(
++                    'names' => array(
++                       'min'     => 2,
++                       'max'     => 2,
++                       'desc'    => 'Fixed number with default values if not used.',
++                       'default' => array('default1', 'default2'))
++                       );
++
++        $args = array('--names', 'arg1', 'arg2');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' ".$obj->getMessage());
++        } else {
++            $this->assertEquals(array($args[1], $args[2]), $obj->getValue('names'), "'$message' Incorrect value returned");
++        }
++
++        $args = array();
++
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail($obj->getMessage());
++        } else {
++            $this->assertEquals(array('default1', 'default2'), $obj->getValue('names'), "Incorrect value returned");
++        }
++
++    }
++
++    function testSwitch()
++    {
++        $config = array(
++                    'switch' => array(
++                        'short' => 's',
++                        'max'   => 0,
++                        'desc'  => 'A switch.')
++                        );
++
++        $args = array('-s');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' ".$obj->getMessage());
++        } else {
++            $this->assertTrue($obj->isDefined('s'), "'$message' Switch not defined");
++            $this->assertTrue($obj->isDefined('switch'), "'$message' Switch not defined");
++        }
++
++        $args = array('--switch');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' ".$obj->getMessage());
++        } else {
++            $this->assertTrue($obj->isDefined('s'), "'$message' Switch not defined");
++            $this->assertTrue($obj->isDefined('switch'), "'$message' Switch not defined");
++        }
++
++    }
++
++    function testSwitchWithDefaultIfValueNotSet()
++    {
++        $config = array(
++                    'default' => array(
++                        'short'   => 'd',
++                        'min'     => 0,
++                        'max'     => 1,
++                        'desc'    => 'A switch with a default value if no value set.',
++                        'default' => 3)
++                        );
++
++        $args = array('-d');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' ".$obj->getMessage());
++        } else {
++            $this->assertEquals(3, $obj->getValue('d'), "'$message' Incorrect value returned");
++            $this->assertEquals(3, $obj->getValue('default'), "'$message' Incorrect value returned");
++        }
++
++        $args = array('-d', 4);
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' ".$obj->getMessage());
++        } else {
++            $this->assertEquals(4, $obj->getValue('d'), "'$message' Incorrect value returned");
++            $this->assertEquals(4, $obj->getValue('default'), "'$message' Incorrect value returned");
++        }
++    }
++
++    function testVariable1_3()
++    {
++        $config = array(
++                    'name' => array(
++                        'min' => 1,
++                        'max' => 3,
++                        'desc' => 'One to three values.')
++                        );
++        
++        $args = array('--name', 'arg1');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' ".$obj->getMessage());
++        } else {
++            $this->assertEquals('arg1', $obj->getValue('name'), "'$message' Incorrect value returned");
++        }
++
++        $args = array('--name', 'arg1', 'arg2', 'arg3');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' ".$obj->getMessage());
++        } else {
++            $this->assertEquals(array('arg1', 'arg2', 'arg3'), $obj->getValue('name'), "'$message' Incorrect values returned");
++        }
++
++    }
++
++    function testVariable1_3WithDefault()
++    {
++        // TODO : using min => 0 should maybe work too
++        $config = array(
++                    'name' => array(
++                        'min'     => 1,
++                        'max'     => 3,
++                        'desc'    => 'Zero to three values using default if no values set.',
++                        'default' => 'default1')
++                        );
++        
++        $args = array('--name', 'arg1');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' ".$obj->getMessage());
++        } else {
++            $this->assertEquals('arg1', $obj->getValue('name'), "'$message' Incorrect value returned");
++        }
++
++        $args = array('--name', 'arg1', 'arg2', 'arg3');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' ".$obj->getMessage());
++        } else {
++            $this->assertEquals(array('arg1', 'arg2', 'arg3'), $obj->getValue('name'), "'$message' Incorrect values returned");
++        }
++
++        $args = array();
++
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail($obj->getMessage());
++        } else {
++            $this->assertEquals('default1', $obj->getValue('name'), "'$message' Incorrect values returned");
++        }
++
++    }
++
++    function testNoLimit()
++    {
++        $config = array(
++                    'name' => array(
++                        'min'     => 1,
++                        'max'     => -1,
++                        'desc'    => 'Unlimited number of values.')
++                        );
++        
++        $args = array('--name', 'arg1');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' ".$obj->getMessage());
++        } else {
++            $this->assertEquals('arg1', $obj->getValue('name'), "'$message' Incorrect value returned");
++        }
++
++        $args = array('--name', 'arg1', 'arg2', 'arg3');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail($obj->getMessage());
++        } else {
++            $this->assertEquals(array('arg1', 'arg2', 'arg3'), $obj->getValue('name'), "'$message' Incorrect values returned");
++        }
++    }
++
++    function testNoLimitWithDefault()
++    {
++        $config = array(
++                    'name' => array(
++                        'min'     => 1,
++                        'max'     => -1,
++                        'desc'    => 'Unlimited number of values.',
++                        'default' => 'default1')
++                        );
++
++        $args = array();
++
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail($obj->getMessage());
++        } else {
++            $this->assertEquals('default1', $obj->getValue('name'), "Incorrect values returned");
++        }
++    }
++
++    function testAlias()
++    {
++        $config = array(
++                    'name|alias' => array(
++                        'short'   => 'n|a',
++                        'min'     => 0,
++                        'max'     => 0,
++                        'desc'    => 'Unlimited number of values with alias.')
++                        );
++
++        $args = array('-n', '-a', '--name', '--alias');
++        foreach ($args as $arg) {
++            $message = $arg;
++            $obj = Console_Getargs::factory($config, array($arg));
++    
++            if (PEAR::isError($obj)) {
++                $this->fail($obj->getMessage());
++            } else {
++                $this->assertTrue($obj->isDefined('name'), "Value 'name' is not defined");
++                $this->assertTrue($obj->isDefined('alias'), "Value 'alias' is not defined");
++                $this->assertTrue($obj->isDefined('n'), "Value 'n' is not defined");
++                $this->assertTrue($obj->isDefined('a'), "Value 'a' is not defined");
++            }
++        }
++    }
++
++
++
++    /**
++    * isDefined should return true when the parameter is passed on cmdline
++    */
++    function testIsDefined()
++    {
++        $config = array(
++            'name' => array(
++                'short'   => 'n',
++                'min'     => 1,
++                'max'     => 1,
++                'desc'    => 'An argument.',
++                'default' => 'john'
++            )
++        );
++
++        $args = array('-n', 'arg1');
++        $obj  = Console_Getargs::factory($config, $args);
++
++        $this->assertFalse(PEAR::isError($obj));
++        $this->assertTrue($obj->isDefined('n'));
++        $this->assertTrue($obj->isDefined('name'));
++    }
++
++
++
++    /**
++    * isDefined should return true when the parameter is passed on cmdline,
++    * even when checking for the alias name
++    */
++    function testIsDefinedAlias()
++    {
++        $config = array(
++            'name|alias' => array(
++                'short'   => 'n',
++                'min'     => 1,
++                'max'     => 1,
++                'desc'    => 'An argument.',
++                'default' => 'john'
++            )
++        );
++
++        $args = array('-n', 'arg1');
++        $obj  = Console_Getargs::factory($config, $args);
++
++        $this->assertFalse(PEAR::isError($obj));
++        $this->assertTrue($obj->isDefined('n'));
++        $this->assertTrue($obj->isDefined('name'));
++        $this->assertTrue($obj->isDefined('alias'));
++    }
++
++
++
++    /**
++    * isDefined should return false when the parameter is not
++    * given on cmdline - even if there is a default value
++    */
++    function testIsDefinedDefaultOnly()
++    {
++        $config = array(
++            'name' => array(
++                'short'   => 'n',
++                'min'     => 1,
++                'max'     => 1,
++                'desc'    => 'An argument.',
++                'default' => 'john'
++            )
++        );
++
++        $args = array();
++        $obj  = Console_Getargs::factory($config, $args);
++
++        $this->assertFalse(PEAR::isError($obj));
++        $this->assertFalse($obj->isDefined('n'));
++        $this->assertFalse($obj->isDefined('name'));
++    }
++
++
++}
++
+diff -ruN Console_Getargs-1.3.5/tests.old/Getargs_getValues_testcase.php Console_Getargs-1.3.5/tests/Getargs_getValues_testcase.php
+--- Console_Getargs-1.3.5/tests.old/Getargs_getValues_testcase.php	1970-01-01 10:13:08.000000000 +0100
++++ Console_Getargs-1.3.5/tests/Getargs_getValues_testcase.php	1970-01-01 01:00:00.000000000 +0100
+@@ -1,297 +0,0 @@
+-<?php
+-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+-
+-/**
+- * getValues Test case for Console_Getargs
+- *
+- * PHP versions 4 and 5
+- *
+- * LICENSE: This source file is subject to version 3.0 of the PHP license
+- * that is available through the world-wide-web at the following URI:
+- * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
+- * the PHP License and are unable to obtain it through the web, please
+- * send a note to license at php.net so we can mail you a copy immediately.
+- *
+- * @category   Console
+- * @package    Console_Getargs
+- * @subpackage Tests
+- * @author     Stephan Schmidt <schst at php.net>
+- * @copyright  1997-2005 The PHP Group
+- * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
+- * @version    CVS: $Id: Getargs_getValues_testcase.php 269139 2008-11-17 10:02:30Z clockwerx $
+- * @link       http://pear.php.net/package/Console_Getargs
+- */
+-if (!defined('PHPUnit_MAIN_METHOD')) {
+-    define('PHPUnit_MAIN_METHOD', 'Getargs_getValues_testCase::main');
+-}
+-
+-require_once 'Console/Getargs.php';
+-require_once 'PHPUnit/Framework.php';
+-
+-/**
+- * getValues Test case for Console_Getargs
+- *
+- * @category   Console
+- * @package    Console_Getargs
+- * @subpackage Tests
+- * @author     Stephan Schmidt <schst at php.net>
+- * @copyright  1997-2005 The PHP Group
+- * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
+- * @version    Release: @package_version@
+- * @link       http://pear.php.net/package/Console_Getargs
+- */
+-class Getargs_getValues_testCase extends PHPUnit_Framework_TestCase
+-{
+-    /**
+-     * Runs the test methods of this class.
+-     *
+-     * @access public
+-     * @static
+-     */
+-    public static function main() {
+-        require_once 'PHPUnit/TextUI/TestRunner.php';
+-
+-        $suite  = new PHPUnit_Framework_TestSuite('Getargs_getValues_testCase');
+-        PHPUnit_TextUI_TestRunner::run($suite);
+-    }
+-
+-
+-
+-   /**
+-    * Test getValues('long') with one argument
+-    *
+-    * @access  public
+-    * @return  void
+-    */
+-    function testLong1()
+-    {
+-        $config = array(
+-                    'name' => array(
+-                        'short' => 'n',
+-                        'min'   => 1,
+-                        'max'   => 1,
+-                        'desc'  => 'An argument.')
+-                       );
+-
+-        $args = array('-n', 'arg1');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' " . $obj->getMessage());
+-        } else {
+-            $this->assertEquals(array('name' => 'arg1'), $obj->getValues('long'), "'$message' Incorrect value returned");
+-        }
+-
+-        $args = array('--name', 'arg1');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' " . $obj->getMessage());
+-        } else {
+-            $this->assertEquals(array('name' => 'arg1'), $obj->getValues('long'), "'$message' Incorrect value returned");
+-        }
+-    }
+-
+-   /**
+-    * Test getValues('long') with one argument and two values
+-    *
+-    * @access  public
+-    * @return  void
+-    */
+-    function testLong2()
+-    {
+-        $config = array(
+-                    'name' => array(
+-                        'short' => 'n',
+-                        'min'   => 2,
+-                        'max'   => 2,
+-                        'desc'  => 'Two arguments.')
+-                       );
+-
+-        $args = array('-n', 'arg1', 'arg2');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' " . $obj->getMessage());
+-        } else {
+-            $this->assertEquals(array('name' => array('arg1', 'arg2')), $obj->getValues('long'), "'$message' Incorrect value returned");
+-        }
+-
+-        $args = array('--name', 'arg1', 'arg2');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' " . $obj->getMessage());
+-        } else {
+-            $this->assertEquals(array('name' => array('arg1', 'arg2')), $obj->getValues('long'), "'$message' Incorrect value returned");
+-        }
+-    }
+-
+-   /**
+-    * Test getValues('short') with one argument
+-    *
+-    * @access  public
+-    * @return  void
+-    */
+-    function testShort()
+-    {
+-        $config = array(
+-                    'name' => array(
+-                        'short' => 'n',
+-                        'min'   => 1,
+-                        'max'   => 1,
+-                        'desc'  => 'An argument.')
+-                       );
+-
+-        $args = array('-n', 'arg1');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' " . $obj->getMessage());
+-        } else {
+-            $this->assertEquals(array('n' => 'arg1'), $obj->getValues('short'), "'$message' Incorrect value returned");
+-        }
+-
+-        $args = array('--name', 'arg1');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' " . $obj->getMessage());
+-        } else {
+-            $this->assertEquals(array('n' => 'arg1'), $obj->getValues('short'), "'$message' Incorrect value returned");
+-        }
+-    }
+-
+-   /**
+-    * Test getValues('short') with one argument and two values
+-    *
+-    * @access  public
+-    * @return  void
+-    */
+-    function testShort2()
+-    {
+-        $config = array(
+-                    'name' => array(
+-                        'short' => 'n',
+-                        'min'   => 2,
+-                        'max'   => 2,
+-                        'desc'  => 'Two arguments.')
+-                       );
+-
+-        $args = array('-n', 'arg1', 'arg2');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' " . $obj->getMessage());
+-        } else {
+-            $this->assertEquals(array('n' => array('arg1', 'arg2')), $obj->getValues('short'), "'$message' Incorrect value returned");
+-        }
+-
+-        $args = array('--name', 'arg1', 'arg2');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' " . $obj->getMessage());
+-        } else {
+-            $this->assertEquals(array('n' => array('arg1', 'arg2')), $obj->getValues('short'), "'$message' Incorrect value returned");
+-        }
+-    }
+-
+-   /**
+-    * Test getValues('short') and getValues('long') with a switch
+-    *
+-    * @access  public
+-    * @return  void
+-    */
+-    function testSwitch()
+-    {
+-        $config = array(
+-                    'switch' => array(
+-                        'short' => 's',
+-                        'max'   => 0,
+-                        'desc'  => 'A switch.')
+-                        );
+-
+-        $args = array('-s');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' " . $obj->getMessage());
+-        } else {
+-            $this->assertTrue($obj->isDefined('s'), "'$message' Switch not defined");
+-            $this->assertTrue($obj->isDefined('switch'), "'$message' Switch not defined");
+-        }
+-
+-        $args = array('--switch');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' " . $obj->getMessage());
+-        } else {
+-            $this->assertEquals(array('switch' => true), $obj->getValues('long'), "'$message' Switch not defined");
+-            $this->assertEquals(array('s' => true), $obj->getValues('short'), "'$message' Switch not defined");
+-        }
+-
+-    }
+-
+-   /**
+-    * Test getValues('long') and getValues('short') with two arguments
+-    *
+-    * @access  public
+-    * @return  void
+-    */
+-    function testMultiple()
+-    {
+-        $config = array(
+-                    'name' => array(
+-                        'short' => 'n',
+-                        'min'   => 1,
+-                        'max'   => 1,
+-                        'desc'  => 'One argument.'),
+-                    'email' => array(
+-                        'short' => 'e',
+-                        'min'   => 2,
+-                        'max'   => 2,
+-                        'desc'  => 'Two arguments.'),
+-                       );
+-
+-        $args = array('-n', 'arg1', '-e', 'schst at php.net', 'wenz at php.net');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' " . $obj->getMessage());
+-        } else {
+-            $this->assertEquals(array('name' => $args[1], 'email' => array($args[3], $args[4])), $obj->getValues('long'), "'$message' Incorrect value returned");
+-            $this->assertEquals(array('n' => $args[1], 'e' => array($args[3], $args[4])), $obj->getValues('short'), "'$message' Incorrect value returned");
+-        }
+-        
+-        $args = array('--name', 'arg1', '--email', 'schst at php.net', 'wenz at php.net');
+-        $message = implode(' ', $args);
+-        $obj =& Console_Getargs::factory($config, $args);
+-
+-        if (PEAR::isError($obj)) {
+-            $this->fail("'$message' " . $obj->getMessage());
+-        } else {
+-            $this->assertEquals(array('name' => $args[1], 'email' => array($args[3], $args[4])), $obj->getValues('long'), "'$message' Incorrect value returned");
+-            $this->assertEquals(array('n' => $args[1], 'e' => array($args[3], $args[4])), $obj->getValues('short'), "'$message' Incorrect value returned");
+-        }
+-    }
+-}
+-
+-if (PHPUnit_MAIN_METHOD == 'Getargs_getValues_testCase::main') {
+-    Getargs_getValues_testCase::main();
+-}
+-
+-?>
+\ Pas de fin de ligne à la fin du fichier
+diff -ruN Console_Getargs-1.3.5/tests.old/Getargs_getValuesTest.php Console_Getargs-1.3.5/tests/Getargs_getValuesTest.php
+--- Console_Getargs-1.3.5/tests.old/Getargs_getValuesTest.php	1970-01-01 01:00:00.000000000 +0100
++++ Console_Getargs-1.3.5/tests/Getargs_getValuesTest.php	2012-01-16 09:49:05.000000000 +0100
+@@ -0,0 +1,277 @@
++<?php
++/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
++
++/**
++ * getValues Test case for Console_Getargs
++ *
++ * PHP versions 4 and 5
++ *
++ * LICENSE: This source file is subject to version 3.0 of the PHP license
++ * that is available through the world-wide-web at the following URI:
++ * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
++ * the PHP License and are unable to obtain it through the web, please
++ * send a note to license at php.net so we can mail you a copy immediately.
++ *
++ * @category   Console
++ * @package    Console_Getargs
++ * @subpackage Tests
++ * @author     Stephan Schmidt <schst at php.net>
++ * @copyright  1997-2005 The PHP Group
++ * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
++ * @version    CVS: $Id$
++ * @link       http://pear.php.net/package/Console_Getargs
++ */
++if (!defined('PHPUnit_MAIN_METHOD')) {
++    define('PHPUnit_MAIN_METHOD', 'Getargs_getValues_testCase::main');
++}
++
++require_once 'Console/Getargs.php';
++require_once 'PHPUnit/Framework/TestCase.php';
++
++/**
++ * getValues Test case for Console_Getargs
++ *
++ * @category   Console
++ * @package    Console_Getargs
++ * @subpackage Tests
++ * @author     Stephan Schmidt <schst at php.net>
++ * @copyright  1997-2005 The PHP Group
++ * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
++ * @version    Release: @package_version@
++ * @link       http://pear.php.net/package/Console_Getargs
++ */
++class Getargs_getValuesTest extends PHPUnit_Framework_TestCase
++{
++
++   /**
++    * Test getValues('long') with one argument
++    *
++    * @access  public
++    * @return  void
++    */
++    function testLong1()
++    {
++        $config = array(
++                    'name' => array(
++                        'short' => 'n',
++                        'min'   => 1,
++                        'max'   => 1,
++                        'desc'  => 'An argument.')
++                       );
++
++        $args = array('-n', 'arg1');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' " . $obj->getMessage());
++        } else {
++            $this->assertEquals(array('name' => 'arg1'), $obj->getValues('long'), "'$message' Incorrect value returned");
++        }
++
++        $args = array('--name', 'arg1');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' " . $obj->getMessage());
++        } else {
++            $this->assertEquals(array('name' => 'arg1'), $obj->getValues('long'), "'$message' Incorrect value returned");
++        }
++    }
++
++   /**
++    * Test getValues('long') with one argument and two values
++    *
++    * @access  public
++    * @return  void
++    */
++    function testLong2()
++    {
++        $config = array(
++                    'name' => array(
++                        'short' => 'n',
++                        'min'   => 2,
++                        'max'   => 2,
++                        'desc'  => 'Two arguments.')
++                       );
++
++        $args = array('-n', 'arg1', 'arg2');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' " . $obj->getMessage());
++        } else {
++            $this->assertEquals(array('name' => array('arg1', 'arg2')), $obj->getValues('long'), "'$message' Incorrect value returned");
++        }
++
++        $args = array('--name', 'arg1', 'arg2');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' " . $obj->getMessage());
++        } else {
++            $this->assertEquals(array('name' => array('arg1', 'arg2')), $obj->getValues('long'), "'$message' Incorrect value returned");
++        }
++    }
++
++   /**
++    * Test getValues('short') with one argument
++    *
++    * @access  public
++    * @return  void
++    */
++    function testShort()
++    {
++        $config = array(
++                    'name' => array(
++                        'short' => 'n',
++                        'min'   => 1,
++                        'max'   => 1,
++                        'desc'  => 'An argument.')
++                       );
++
++        $args = array('-n', 'arg1');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' " . $obj->getMessage());
++        } else {
++            $this->assertEquals(array('n' => 'arg1'), $obj->getValues('short'), "'$message' Incorrect value returned");
++        }
++
++        $args = array('--name', 'arg1');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' " . $obj->getMessage());
++        } else {
++            $this->assertEquals(array('n' => 'arg1'), $obj->getValues('short'), "'$message' Incorrect value returned");
++        }
++    }
++
++   /**
++    * Test getValues('short') with one argument and two values
++    *
++    * @access  public
++    * @return  void
++    */
++    function testShort2()
++    {
++        $config = array(
++                    'name' => array(
++                        'short' => 'n',
++                        'min'   => 2,
++                        'max'   => 2,
++                        'desc'  => 'Two arguments.')
++                       );
++
++        $args = array('-n', 'arg1', 'arg2');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' " . $obj->getMessage());
++        } else {
++            $this->assertEquals(array('n' => array('arg1', 'arg2')), $obj->getValues('short'), "'$message' Incorrect value returned");
++        }
++
++        $args = array('--name', 'arg1', 'arg2');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' " . $obj->getMessage());
++        } else {
++            $this->assertEquals(array('n' => array('arg1', 'arg2')), $obj->getValues('short'), "'$message' Incorrect value returned");
++        }
++    }
++
++   /**
++    * Test getValues('short') and getValues('long') with a switch
++    *
++    * @access  public
++    * @return  void
++    */
++    function testSwitch()
++    {
++        $config = array(
++                    'switch' => array(
++                        'short' => 's',
++                        'max'   => 0,
++                        'desc'  => 'A switch.')
++                        );
++
++        $args = array('-s');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' " . $obj->getMessage());
++        } else {
++            $this->assertTrue($obj->isDefined('s'), "'$message' Switch not defined");
++            $this->assertTrue($obj->isDefined('switch'), "'$message' Switch not defined");
++        }
++
++        $args = array('--switch');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' " . $obj->getMessage());
++        } else {
++            $this->assertEquals(array('switch' => true), $obj->getValues('long'), "'$message' Switch not defined");
++            $this->assertEquals(array('s' => true), $obj->getValues('short'), "'$message' Switch not defined");
++        }
++
++    }
++
++   /**
++    * Test getValues('long') and getValues('short') with two arguments
++    *
++    * @access  public
++    * @return  void
++    */
++    function testMultiple()
++    {
++        $config = array(
++                    'name' => array(
++                        'short' => 'n',
++                        'min'   => 1,
++                        'max'   => 1,
++                        'desc'  => 'One argument.'),
++                    'email' => array(
++                        'short' => 'e',
++                        'min'   => 2,
++                        'max'   => 2,
++                        'desc'  => 'Two arguments.'),
++                       );
++
++        $args = array('-n', 'arg1', '-e', 'schst at php.net', 'wenz at php.net');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' " . $obj->getMessage());
++        } else {
++            $this->assertEquals(array('name' => $args[1], 'email' => array($args[3], $args[4])), $obj->getValues('long'), "'$message' Incorrect value returned");
++            $this->assertEquals(array('n' => $args[1], 'e' => array($args[3], $args[4])), $obj->getValues('short'), "'$message' Incorrect value returned");
++        }
++        
++        $args = array('--name', 'arg1', '--email', 'schst at php.net', 'wenz at php.net');
++        $message = implode(' ', $args);
++        $obj = Console_Getargs::factory($config, $args);
++
++        if (PEAR::isError($obj)) {
++            $this->fail("'$message' " . $obj->getMessage());
++        } else {
++            $this->assertEquals(array('name' => $args[1], 'email' => array($args[3], $args[4])), $obj->getValues('long'), "'$message' Incorrect value returned");
++            $this->assertEquals(array('n' => $args[1], 'e' => array($args[3], $args[4])), $obj->getValues('short'), "'$message' Incorrect value returned");
++        }
++    }
++}
+--- Console_Getargs-1.3.5/Console/Getargs.php.old	2012-01-16 09:53:39.000000000 +0100
++++ Console_Getargs-1.3.5/Console/Getargs.php	2012-01-16 09:53:51.000000000 +0100
+@@ -224,7 +224,7 @@
+     function &factory($config = array(), $arguments = null)
+     {
+         // Create the options object.
+-        $obj = & new Console_Getargs_Options();
++        $obj = new Console_Getargs_Options();
+ 
+         // Try to set up the arguments.
+         $err = $obj->init($config, $arguments);
+--- Console_Getargs-1.3.5/php-pear-Console-Getargs.xml.old	2012-01-16 09:55:00.000000000 +0100
++++ Console_Getargs-1.3.5/php-pear-Console-Getargs.xml	2012-01-16 09:56:30.000000000 +0100
+@@ -49,14 +49,13 @@
+  </notes>
+  <contents>
+   <dir baseinstalldir="/" name="/">
+-   <file baseinstalldir="/" md5sum="14652e17d6c288967fe5fc68d2c1b658" name="Console/Getargs.php" role="php">
++   <file baseinstalldir="/" name="Console/Getargs.php" role="php">
+     <replace from="@package_version@" to="version" type="package-info" />
+    </file>
+    <file baseinstalldir="Console" md5sum="1ecd39fd0b3b950faacbdae5839630f2" name="examples/example.php" role="doc" />
+    <file baseinstalldir="Console" md5sum="fc1f86032b8c5386ebe5ae96ed1f306f" name="examples/example2.php" role="doc" />
+-   <file baseinstalldir="/" md5sum="dfa4fedac68a13247f94b89c9dbd36ce" name="tests/AllTests.php" role="test" />
+-   <file baseinstalldir="Console" md5sum="143ba121704e21596793435ee9d042ba" name="tests/Getargs_basic_testcase.php" role="test" />
+-   <file baseinstalldir="" md5sum="273e593a69eabdd041f2f4f74e08318b" name="tests/Getargs_getValues_testcase.php" role="test" />
++   <file baseinstalldir="" name="tests/Getargs_BasicTest.php" role="test" />
++   <file baseinstalldir="" name="tests/Getargs_getValuesTest.php" role="test" />
+   </dir>
+  </contents>
+  <dependencies>
diff --git a/php-pear-Console-Getargs.spec b/php-pear-Console-Getargs.spec
index ca8e154..809ff86 100644
--- a/php-pear-Console-Getargs.spec
+++ b/php-pear-Console-Getargs.spec
@@ -3,7 +3,7 @@
 
 Name:           php-pear-Console-Getargs
 Version:        1.3.5
-Release:        4%{?dist}
+Release:        5%{?dist}
 Summary:        Command-line arguments and parameters parser
 Summary(fr):    Analyseur des arguments et paramètres en ligne de commande
 
@@ -13,6 +13,10 @@ URL:            http://pear.php.net/package/Console_Getargs
 Source0:        http://pear.php.net/get/%{pear_name}-%{version}.tgz
 Source2:        xml2changelog
 
+# https://github.com/pear/Console_Getargs/commit/a21a71cd3a561711b3880cbad466c24d39899644
+# https://github.com/pear/Console_Getargs/commit/c769f79831c43f1cad0b4f8831276da93d28f479
+Patch1:         Console_Getargs-git.patch
+
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildArch:      noarch
 BuildRequires:  php-pear >= 1:1.4.9-1.2
@@ -41,14 +45,12 @@ automatiquement un texte d'aide à partir de la configuration fournie.
 %setup -c -q
 %{_bindir}/php -n %{SOURCE2} package.xml | tee CHANGELOG | head -n 2
 
-# Create a "localized" php.ini to avoid build warning
-cp /etc/php.ini .
-echo "date.timezone=UTC" >>php.ini
-
 cd %{pear_name}-%{version}
 # package.xml is V2
 mv ../package.xml %{name}.xml
 
+%patch1 -p1 -b .orig
+
 
 %build
 cd %{pear_name}-%{version}
@@ -58,7 +60,7 @@ cd %{pear_name}-%{version}
 %install
 rm -rf $RPM_BUILD_ROOT
 cd %{pear_name}-%{version}
-PHPRC=../php.ini %{__pear} install --nodeps --packagingroot $RPM_BUILD_ROOT %{name}.xml
+%{__pear} install --nodeps --packagingroot $RPM_BUILD_ROOT %{name}.xml
 
 # Clean up unnecessary files
 rm -rf $RPM_BUILD_ROOT%{pear_phpdir}/.??*
@@ -69,11 +71,11 @@ install -pm 644 %{name}.xml $RPM_BUILD_ROOT%{pear_xmldir}
 
 
 %check
-cd %{pear_name}-%{version}/tests
+cd %{pear_name}-%{version}
 %{_bindir}/phpunit \
    -d date.timezone=UTC \
    -d include_path=$RPM_BUILD_ROOT%{pear_phpdir}:%{pear_phpdir} \
-   AllTests.php
+   tests
 
 
 %clean
@@ -101,6 +103,9 @@ fi
 
 
 %changelog
+* Mon Jan 16 2012 Remi Collet <remi at fedoraproject.org> - 1.3.5-5
+- fix from GIT for test suite
+
 * Sat Jan 14 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.3.5-4
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
 
diff --git a/xml2changelog b/xml2changelog
index eb6bd31..3a31be6 100644
--- a/xml2changelog
+++ b/xml2changelog
@@ -7,11 +7,14 @@ $file=array_shift($_SERVER['argv']);
 if (in_array("--debug", $_SERVER['argv'])) print_r($xml);
 
 if ($xml['version'] >= "2"){ // Package.xml V 2.0
-	printf("*** Version %s (%s) - API %s (%s) - %s\n\n%s\n\n",
-		$xml->version->release, $xml->stability->release, 
-		$xml->version->api, $xml->stability->api, 
-		$xml->date, $xml->notes);
-	$new=$xml->version->release;
+	$new = "";
+	if (strlen(trim($xml->notes))>1) { // Ignore too short descr.
+		printf("*** Version %s (%s) - API %s (%s) - %s\n\n%s\n\n",
+			$xml->version->release, $xml->stability->release,
+			$xml->version->api, $xml->stability->api,
+			$xml->date, $xml->notes);
+		$new=$xml->version->release;
+	}
 
 	if (isset($xml->changelog->release) && count($xml->changelog->release)) {
 		$tab = array();
@@ -20,14 +23,14 @@ if ($xml['version'] >= "2"){ // Package.xml V 2.0
 			if ("$old" != "$new") {
 				$tab[''.$rel->date] = $rel;
 			}
-		}	
+		}
 		krsort($tab);
 		foreach($tab as $rel) {
 			printf("*** Version %s (%s) - API %s (%s) - %s\n\n%s\n\n",
-				$rel->version->release, $rel->stability->release, 
-				$rel->version->api, $rel->stability->api, 
+				$rel->version->release, $rel->stability->release,
+				$rel->version->api, $rel->stability->api,
 				$rel->date, $rel->notes);
-	    	}
+		}
 	}
 } else { // Package.xml V 1.0
 	printf("* Version %s (%s) - %s\n\n%s\n\n",


More information about the scm-commits mailing list