cvs: pear /PEAR_PackageFileManager package.xml /PEAR_PackageFileManager/tests PEAR_PackageFileManager_TestCase_generateNewPackageXML.php
PEAR_PackageFileManager_TestCase_getExistingPackageXML.php testsuite.php
| From: | Greg Beaver | Date: | Wed, 15 Oct 2003 00:02:17 +0000 |
| Subject: | cvs: pear /PEAR_PackageFileManager package.xml /PEAR_PackageFileManager/tests PEAR_PackageFileManager_TestCase_generateNewPackageXML.php PEAR_PackageFileManager_TestCase_getExistingPackageXML.php testsuite.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-13611@lists.php.net to get a copy of this message | ||
cellog Tue Oct 14 20:02:17 2003 EDT
Modified files:
/pear/PEAR_PackageFileManager package.xml
/pear/PEAR_PackageFileManager/tests
PEAR_PackageFileManager_TestCase_generateNewPackageXML.php
PEAR_PackageFileManager_TestCase_getExistingPackageXML.php
testsuite.php
Log:
next testcase finished, plus a few tweaks to the old one
Index: pear/PEAR_PackageFileManager/package.xml diff -u pear/PEAR_PackageFileManager/package.xml:1.14 pear/PEAR_PackageFileManager/package.xml:1.15 --- pear/PEAR_PackageFileManager/package.xml:1.14 Tue Oct 14 19:31:08 2003 +++ pear/PEAR_PackageFileManager/package.xml Tue Oct 14 20:02:16 2003 @@ -61,11 +61,13 @@ <file role="php" baseinstalldir="PEAR" md5sum="af363df56194c252f85275d6657fadeb" name="PackageFileManager/Cvs.php"/> <file role="php" baseinstalldir="PEAR" md5sum="d2a9735d0d3321285af4f4c69c44f0c0" name="PackageFileManager/File.php"/> <file role="test" baseinstalldir="PEAR" md5sum="66b8173f17d40343769505477561a51e" name="tests/HTML_TestListener.php"/> - <file role="test" baseinstalldir="PEAR" md5sum="6e405d20c2c514cdf2a8486c4172862a" name="tests/PEAR_PackageFileManager_TestCase_generateNewPackageXML.php"/> + <file role="test" baseinstalldir="PEAR" md5sum="ca819bc846abe16e3212f968c379c0cf" name="tests/PEAR_PackageFileManager_TestCase_generateNewPackageXML.php"/> + <file role="test" baseinstalldir="PEAR" md5sum="a6ba0ebca71e12d832e1f9ac3b0b3d48" name="tests/PEAR_PackageFileManager_TestCase_getExistingPackageXML.php"/> <file role="test" baseinstalldir="PEAR" md5sum="576820df16c6366b1112fc3b7d63047e" name="tests/stylesheet.css"/> - <file role="test" baseinstalldir="PEAR" md5sum="daaad0c62382f67dc87d3e2803759d46" name="tests/testsuite.php"/> + <file role="test" baseinstalldir="PEAR" md5sum="d2ee96487dda5783445202f9870fea58" name="tests/test1_package.xml"/> + <file role="test" baseinstalldir="PEAR" md5sum="b130dd310c82a7e4ffec68a5797f6840" name="tests/testsuite.php"/> <file role="test" baseinstalldir="PEAR" md5sum="991373ae7e4a9d4fe00c08d75873a785" name="tests/TestUnit.php"/> - <file role="php" baseinstalldir="PEAR" md5sum="6cb983b0b24d25922cbc202e7c70e0be" name="PackageFileManager.php"/> + <file role="php" baseinstalldir="PEAR" md5sum="088a9045346469b9d4ae4938d8bbdbe2" name="PackageFileManager.php"/> </filelist> </release> <changelog> Index: pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_generateNewPackageXML.php diff -u pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_generateNewPackageXML.php:1.4 pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_generateNewPackageXML.php:1.5 --- pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_generateNewPackageXML.php:1.4 Tue Oct 14 19:33:24 2003 +++ pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_generateNewPackageXML.php Tue Oct 14 20:02:16 2003 @@ -3,7 +3,7 @@ /** * API Unit tests for PEAR_PackageFileManager package. * - * @version $Id: PEAR_PackageFileManager_TestCase_generateNewPackageXML.php,v 1.4 2003/10/14 23:33:24 cellog Exp $ + * @version $Id: PEAR_PackageFileManager_TestCase_generateNewPackageXML.php,v 1.5 2003/10/15 00:02:16 cellog Exp $ * @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS * @author Greg Beaver * @package PEAR_PackageFileManager @@ -34,6 +34,10 @@ $this->packagexml = new PEAR_PackageFileManager; PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, array(&$this, 'PEARerrorHandler')); + $this->errorThrown = false; + $this->_expectedMessage = 'ERROR TRIGGERED'; + $this->_expectedCode = -1; + $this->_testMethod = 'unknown'; } function tearDown() @@ -45,6 +49,7 @@ function errorCodeToString($code) { $codes = array_flip(array( + 'OOPS' => -1, 'PEAR_PACKAGEFILEMANAGER_NOSTATE' => PEAR_PACKAGEFILEMANAGER_NOSTATE, 'PEAR_PACKAGEFILEMANAGER_NOVERSION' => PEAR_PACKAGEFILEMANAGER_NOVERSION, 'PEAR_PACKAGEFILEMANAGER_NOPKGDIR' => PEAR_PACKAGEFILEMANAGER_NOPKGDIR, @@ -96,8 +101,10 @@ function PEARerrorHandler($error) { $this->assertEquals($this->_expectedCode, $error->getCode(), - $this->_testMethod . ' ' . $this->errorCodeToString($this->_expectedCode)); + $this->_testMethod . ' ' . $this->errorCodeToString($this->_expectedCode) + . ' actual: ' . $this->errorCodeToString($error->getCode())); $this->assertEquals($this->_expectedMessage, $error->getMessage(), $this->_testMethod); + $this->errorThrown = 'true'; } function expectPEARError($method, $msg, $code = null) @@ -117,6 +124,7 @@ 'must by specified in PEAR_PackageFileManager '. 'setOptions to create a new package.xml', PEAR_PACKAGEFILEMANAGER_NOPACKAGE); $this->packagexml->_generateNewPackageXML(); + $this->assertEquals('true', $this->errorThrown, 'no error thrown'); } function test_invalid_nosummary() @@ -130,6 +138,7 @@ '\'summary\') must by specified in PEAR_PackageFileManager '. 'setOptions to create a new package.xml', PEAR_PACKAGEFILEMANAGER_NOSUMMARY); $this->packagexml->_generateNewPackageXML(); + $this->assertEquals('true', $this->errorThrown, 'no error thrown'); } function test_invalid_nodescription() @@ -145,6 +154,7 @@ ' specified in PEAR_PackageFileManager setOptions to ' . 'create a new package.xml', PEAR_PACKAGEFILEMANAGER_NODESC); $this->packagexml->_generateNewPackageXML(); + $this->assertEquals('true', $this->errorThrown, 'no error thrown'); } function test_valid_simple() Index: pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_getExistingPackageXML.php diff -u pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_getExistingPackageXML.php:1.1 pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_getExistingPackageXML.php:1.2 --- pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_getExistingPackageXML.php:1.1 Tue Oct 14 19:36:57 2003 +++ pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_getExistingPackageXML.php Tue Oct 14 20:02:16 2003 @@ -3,7 +3,7 @@ /** * API Unit tests for PEAR_PackageFileManager package. * - * @version $Id: PEAR_PackageFileManager_TestCase_getExistingPackageXML.php,v 1.1 2003/10/14 23:36:57 cellog Exp $ + * @version $Id: PEAR_PackageFileManager_TestCase_getExistingPackageXML.php,v 1.2 2003/10/15 00:02:16 cellog Exp $ * @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS * @author Greg Beaver * @package PEAR_PackageFileManager @@ -34,6 +34,10 @@ $this->packagexml = new PEAR_PackageFileManager; PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, array(&$this, 'PEARerrorHandler')); + $this->errorThrown = false; + $this->_expectedMessage = 'ERROR TRIGGERED'; + $this->_expectedCode = -1; + $this->_testMethod = 'unknown'; } function tearDown() @@ -45,6 +49,7 @@ function errorCodeToString($code) { $codes = array_flip(array( + 'OOPS' => -1, 'PEAR_PACKAGEFILEMANAGER_NOSTATE' => PEAR_PACKAGEFILEMANAGER_NOSTATE, 'PEAR_PACKAGEFILEMANAGER_NOVERSION' => PEAR_PACKAGEFILEMANAGER_NOVERSION, 'PEAR_PACKAGEFILEMANAGER_NOPKGDIR' => PEAR_PACKAGEFILEMANAGER_NOPKGDIR, @@ -96,8 +101,10 @@ function PEARerrorHandler($error) { $this->assertEquals($this->_expectedCode, $error->getCode(), - $this->_testMethod . ' ' . $this->errorCodeToString($this->_expectedCode)); + $this->_testMethod . ' ' . $this->errorCodeToString($this->_expectedCode) + . ' actual: ' . $this->errorCodeToString($error->getCode())); $this->assertEquals($this->_expectedMessage, $error->getMessage(), $this->_testMethod); + $this->errorThrown = 'true'; } function expectPEARError($method, $msg, $code = null) @@ -113,13 +120,13 @@ return; } $this->expectPEARError('invalid nopackage', - 'PEAR_PackageFileManager Error: Package Name (option \'package\') ' . - 'must by specified in PEAR_PackageFileManager '. - 'setOptions to create a new package.xml', PEAR_PACKAGEFILEMANAGER_PATH_DOESNT_EXIST); + 'PEAR_PackageFileManager Error: package.xml file path "array" ' . + 'doesn\'t exist or isn\'t a directory', PEAR_PACKAGEFILEMANAGER_PATH_DOESNT_EXIST); $this->packagexml->_getExistingPackageXML(array(), 'package.xml'); + $this->assertEquals('true', $this->errorThrown, 'no error thrown'); } - function test_invalid_nopackage() + function test_invalid_notexists_nopackage() { if (!$this->_methodExists('_getExistingPackageXML')) { return; @@ -128,7 +135,80 @@ 'PEAR_PackageFileManager Error: Package Name (option \'package\') ' . 'must by specified in PEAR_PackageFileManager '. 'setOptions to create a new package.xml', PEAR_PACKAGEFILEMANAGER_NOPACKAGE); - $this->packagexml->_generateNewPackageXML(); + $this->packagexml->_getExistingPackageXML(dirname(__FILE__), 'blah.xml'); + $this->assertEquals('true', $this->errorThrown, 'no error thrown'); + } + + function test_valid_simple() + { + if (!$this->_methodExists('_getExistingPackageXML')) { + return; + } + $res = $this->packagexml->_getExistingPackageXML(dirname(__FILE__) . '/', 'test1_package.xml'); + $this->assertFalse(is_object($res), 'returned error'); + $PEAR_Common = $this->packagexml->_options['pearcommonclass']; + $common = new $PEAR_Common; + $contents = $common->infoFromAny(dirname(__FILE__) . '/test1_package.xml'); + $this->assertEquals($contents['release_deps'], $this->packagexml->_packageXml['release_deps'], 'wrong deps'); + $this->assertEquals($contents['maintainers'], $this->packagexml->_packageXml['maintainers'], 'wrong maintainers'); + $this->assertEquals($this->packagexml->_packageXml['release_deps'], + $this->packagexml->_options['deps'], 'wrong deps'); + $this->assertEquals($this->packagexml->_packageXml['maintainers'], + $this->packagexml->_options['maintainers'], 'wrong maintainers'); + } + + function test_valid_deps() + { + if (!$this->_methodExists('_getExistingPackageXML')) { + return; + } + $this->packagexml->_options['deps'] = + array( + array('name' => 'pork', 'rel' => 'ge', 'version' => '1.0.0', + 'optional' => 'yes') + ); + $res = $this->packagexml->_getExistingPackageXML(dirname(__FILE__) . '/', 'test1_package.xml'); + $this->assertFalse(is_object($res), 'returned error'); + $PEAR_Common = $this->packagexml->_options['pearcommonclass']; + $common = new $PEAR_Common; + $contents = $common->infoFromAny(dirname(__FILE__) . '/test1_package.xml'); + $this->assertEquals(array( + array('name' => 'pork', 'rel' => 'ge', 'version' => '1.0.0', + 'optional' => 'yes') + ), $this->packagexml->_packageXml['release_deps'], 'wrong deps'); + $this->assertEquals($contents['maintainers'], $this->packagexml->_packageXml['maintainers'], 'wrong maintainers'); + $this->assertEquals($this->packagexml->_packageXml['release_deps'], + $this->packagexml->_options['deps'], 'wrong deps'); + $this->assertEquals($this->packagexml->_packageXml['maintainers'], + $this->packagexml->_options['maintainers'], 'wrong maintainers'); + } + + function test_valid_maintainers() + { + if (!$this->_methodExists('_getExistingPackageXML')) { + return; + } + $this->packagexml->_options['maintainers'] = + array( + array('name' => 'Gerg', 'email' => 'foo@example.com', + 'role' => 'lead', + 'handle' => 'cellogerg') + ); + $res = $this->packagexml->_getExistingPackageXML(dirname(__FILE__) . '/', 'test1_package.xml'); + $this->assertFalse(is_object($res), 'returned error'); + $PEAR_Common = $this->packagexml->_options['pearcommonclass']; + $common = new $PEAR_Common; + $contents = $common->infoFromAny(dirname(__FILE__) . '/test1_package.xml'); + $this->assertEquals($contents['release_deps'], $this->packagexml->_packageXml['release_deps'], 'wrong deps'); + $this->assertEquals(array( + array('name' => 'Gerg', 'email' => 'foo@example.com', + 'role' => 'lead', + 'handle' => 'cellogerg') + ), $this->packagexml->_packageXml['maintainers'], 'wrong maintainers'); + $this->assertEquals($this->packagexml->_packageXml['release_deps'], + $this->packagexml->_options['deps'], 'wrong deps'); + $this->assertEquals($this->packagexml->_packageXml['maintainers'], + $this->packagexml->_options['maintainers'], 'wrong maintainers'); } } Index: pear/PEAR_PackageFileManager/tests/testsuite.php diff -u pear/PEAR_PackageFileManager/tests/testsuite.php:1.1 pear/PEAR_PackageFileManager/tests/testsuite.php:1.2 --- pear/PEAR_PackageFileManager/tests/testsuite.php:1.1 Tue Oct 14 00:31:39 2003 +++ pear/PEAR_PackageFileManager/tests/testsuite.php Tue Oct 14 20:02:16 2003 @@ -4,7 +4,7 @@ * HTML output for PHPUnit suite tests. * * Copied for PEAR_PackageFileManager from HTML_CSS - * @version $Id: testsuite.php,v 1.1 2003/10/14 04:31:39 cellog Exp $ + * @version $Id: testsuite.php,v 1.2 2003/10/15 00:02:16 cellog Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_CSS */ @@ -47,6 +47,7 @@ <?php $testcases = array( 'PEAR_PackageFileManager_TestCase_generateNewPackageXML', + 'PEAR_PackageFileManager_TestCase_getExistingPackageXML', );
Index: pear/PEAR_PackageFileManager/package.xml diff -u pear/PEAR_PackageFileManager/package.xml:1.14 pear/PEAR_PackageFileManager/package.xml:1.15 --- pear/PEAR_PackageFileManager/package.xml:1.14 Tue Oct 14 19:31:08 2003 +++ pear/PEAR_PackageFileManager/package.xml Tue Oct 14 20:02:16 2003 @@ -61,11 +61,13 @@ <file role="php" baseinstalldir="PEAR" md5sum="af363df56194c252f85275d6657fadeb" name="PackageFileManager/Cvs.php"/> <file role="php" baseinstalldir="PEAR" md5sum="d2a9735d0d3321285af4f4c69c44f0c0" name="PackageFileManager/File.php"/> <file role="test" baseinstalldir="PEAR" md5sum="66b8173f17d40343769505477561a51e" name="tests/HTML_TestListener.php"/> - <file role="test" baseinstalldir="PEAR" md5sum="6e405d20c2c514cdf2a8486c4172862a" name="tests/PEAR_PackageFileManager_TestCase_generateNewPackageXML.php"/> + <file role="test" baseinstalldir="PEAR" md5sum="ca819bc846abe16e3212f968c379c0cf" name="tests/PEAR_PackageFileManager_TestCase_generateNewPackageXML.php"/> + <file role="test" baseinstalldir="PEAR" md5sum="a6ba0ebca71e12d832e1f9ac3b0b3d48" name="tests/PEAR_PackageFileManager_TestCase_getExistingPackageXML.php"/> <file role="test" baseinstalldir="PEAR" md5sum="576820df16c6366b1112fc3b7d63047e" name="tests/stylesheet.css"/> - <file role="test" baseinstalldir="PEAR" md5sum="daaad0c62382f67dc87d3e2803759d46" name="tests/testsuite.php"/> + <file role="test" baseinstalldir="PEAR" md5sum="d2ee96487dda5783445202f9870fea58" name="tests/test1_package.xml"/> + <file role="test" baseinstalldir="PEAR" md5sum="b130dd310c82a7e4ffec68a5797f6840" name="tests/testsuite.php"/> <file role="test" baseinstalldir="PEAR" md5sum="991373ae7e4a9d4fe00c08d75873a785" name="tests/TestUnit.php"/> - <file role="php" baseinstalldir="PEAR" md5sum="6cb983b0b24d25922cbc202e7c70e0be" name="PackageFileManager.php"/> + <file role="php" baseinstalldir="PEAR" md5sum="088a9045346469b9d4ae4938d8bbdbe2" name="PackageFileManager.php"/> </filelist> </release> <changelog> Index: pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_generateNewPackageXML.php diff -u pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_generateNewPackageXML.php:1.4 pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_generateNewPackageXML.php:1.5 --- pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_generateNewPackageXML.php:1.4 Tue Oct 14 19:33:24 2003 +++ pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_generateNewPackageXML.php Tue Oct 14 20:02:16 2003 @@ -3,7 +3,7 @@ /** * API Unit tests for PEAR_PackageFileManager package. * - * @version $Id: PEAR_PackageFileManager_TestCase_generateNewPackageXML.php,v 1.4 2003/10/14 23:33:24 cellog Exp $ + * @version $Id: PEAR_PackageFileManager_TestCase_generateNewPackageXML.php,v 1.5 2003/10/15 00:02:16 cellog Exp $ * @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS * @author Greg Beaver * @package PEAR_PackageFileManager @@ -34,6 +34,10 @@ $this->packagexml = new PEAR_PackageFileManager; PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, array(&$this, 'PEARerrorHandler')); + $this->errorThrown = false; + $this->_expectedMessage = 'ERROR TRIGGERED'; + $this->_expectedCode = -1; + $this->_testMethod = 'unknown'; } function tearDown() @@ -45,6 +49,7 @@ function errorCodeToString($code) { $codes = array_flip(array( + 'OOPS' => -1, 'PEAR_PACKAGEFILEMANAGER_NOSTATE' => PEAR_PACKAGEFILEMANAGER_NOSTATE, 'PEAR_PACKAGEFILEMANAGER_NOVERSION' => PEAR_PACKAGEFILEMANAGER_NOVERSION, 'PEAR_PACKAGEFILEMANAGER_NOPKGDIR' => PEAR_PACKAGEFILEMANAGER_NOPKGDIR, @@ -96,8 +101,10 @@ function PEARerrorHandler($error) { $this->assertEquals($this->_expectedCode, $error->getCode(), - $this->_testMethod . ' ' . $this->errorCodeToString($this->_expectedCode)); + $this->_testMethod . ' ' . $this->errorCodeToString($this->_expectedCode) + . ' actual: ' . $this->errorCodeToString($error->getCode())); $this->assertEquals($this->_expectedMessage, $error->getMessage(), $this->_testMethod); + $this->errorThrown = 'true'; } function expectPEARError($method, $msg, $code = null) @@ -117,6 +124,7 @@ 'must by specified in PEAR_PackageFileManager '. 'setOptions to create a new package.xml', PEAR_PACKAGEFILEMANAGER_NOPACKAGE); $this->packagexml->_generateNewPackageXML(); + $this->assertEquals('true', $this->errorThrown, 'no error thrown'); } function test_invalid_nosummary() @@ -130,6 +138,7 @@ '\'summary\') must by specified in PEAR_PackageFileManager '. 'setOptions to create a new package.xml', PEAR_PACKAGEFILEMANAGER_NOSUMMARY); $this->packagexml->_generateNewPackageXML(); + $this->assertEquals('true', $this->errorThrown, 'no error thrown'); } function test_invalid_nodescription() @@ -145,6 +154,7 @@ ' specified in PEAR_PackageFileManager setOptions to ' . 'create a new package.xml', PEAR_PACKAGEFILEMANAGER_NODESC); $this->packagexml->_generateNewPackageXML(); + $this->assertEquals('true', $this->errorThrown, 'no error thrown'); } function test_valid_simple() Index: pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_getExistingPackageXML.php diff -u pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_getExistingPackageXML.php:1.1 pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_getExistingPackageXML.php:1.2 --- pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_getExistingPackageXML.php:1.1 Tue Oct 14 19:36:57 2003 +++ pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_getExistingPackageXML.php Tue Oct 14 20:02:16 2003 @@ -3,7 +3,7 @@ /** * API Unit tests for PEAR_PackageFileManager package. * - * @version $Id: PEAR_PackageFileManager_TestCase_getExistingPackageXML.php,v 1.1 2003/10/14 23:36:57 cellog Exp $ + * @version $Id: PEAR_PackageFileManager_TestCase_getExistingPackageXML.php,v 1.2 2003/10/15 00:02:16 cellog Exp $ * @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS * @author Greg Beaver * @package PEAR_PackageFileManager @@ -34,6 +34,10 @@ $this->packagexml = new PEAR_PackageFileManager; PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, array(&$this, 'PEARerrorHandler')); + $this->errorThrown = false; + $this->_expectedMessage = 'ERROR TRIGGERED'; + $this->_expectedCode = -1; + $this->_testMethod = 'unknown'; } function tearDown() @@ -45,6 +49,7 @@ function errorCodeToString($code) { $codes = array_flip(array( + 'OOPS' => -1, 'PEAR_PACKAGEFILEMANAGER_NOSTATE' => PEAR_PACKAGEFILEMANAGER_NOSTATE, 'PEAR_PACKAGEFILEMANAGER_NOVERSION' => PEAR_PACKAGEFILEMANAGER_NOVERSION, 'PEAR_PACKAGEFILEMANAGER_NOPKGDIR' => PEAR_PACKAGEFILEMANAGER_NOPKGDIR, @@ -96,8 +101,10 @@ function PEARerrorHandler($error) { $this->assertEquals($this->_expectedCode, $error->getCode(), - $this->_testMethod . ' ' . $this->errorCodeToString($this->_expectedCode)); + $this->_testMethod . ' ' . $this->errorCodeToString($this->_expectedCode) + . ' actual: ' . $this->errorCodeToString($error->getCode())); $this->assertEquals($this->_expectedMessage, $error->getMessage(), $this->_testMethod); + $this->errorThrown = 'true'; } function expectPEARError($method, $msg, $code = null) @@ -113,13 +120,13 @@ return; } $this->expectPEARError('invalid nopackage', - 'PEAR_PackageFileManager Error: Package Name (option \'package\') ' . - 'must by specified in PEAR_PackageFileManager '. - 'setOptions to create a new package.xml', PEAR_PACKAGEFILEMANAGER_PATH_DOESNT_EXIST); + 'PEAR_PackageFileManager Error: package.xml file path "array" ' . + 'doesn\'t exist or isn\'t a directory', PEAR_PACKAGEFILEMANAGER_PATH_DOESNT_EXIST); $this->packagexml->_getExistingPackageXML(array(), 'package.xml'); + $this->assertEquals('true', $this->errorThrown, 'no error thrown'); } - function test_invalid_nopackage() + function test_invalid_notexists_nopackage() { if (!$this->_methodExists('_getExistingPackageXML')) { return; @@ -128,7 +135,80 @@ 'PEAR_PackageFileManager Error: Package Name (option \'package\') ' . 'must by specified in PEAR_PackageFileManager '. 'setOptions to create a new package.xml', PEAR_PACKAGEFILEMANAGER_NOPACKAGE); - $this->packagexml->_generateNewPackageXML(); + $this->packagexml->_getExistingPackageXML(dirname(__FILE__), 'blah.xml'); + $this->assertEquals('true', $this->errorThrown, 'no error thrown'); + } + + function test_valid_simple() + { + if (!$this->_methodExists('_getExistingPackageXML')) { + return; + } + $res = $this->packagexml->_getExistingPackageXML(dirname(__FILE__) . '/', 'test1_package.xml'); + $this->assertFalse(is_object($res), 'returned error'); + $PEAR_Common = $this->packagexml->_options['pearcommonclass']; + $common = new $PEAR_Common; + $contents = $common->infoFromAny(dirname(__FILE__) . '/test1_package.xml'); + $this->assertEquals($contents['release_deps'], $this->packagexml->_packageXml['release_deps'], 'wrong deps'); + $this->assertEquals($contents['maintainers'], $this->packagexml->_packageXml['maintainers'], 'wrong maintainers'); + $this->assertEquals($this->packagexml->_packageXml['release_deps'], + $this->packagexml->_options['deps'], 'wrong deps'); + $this->assertEquals($this->packagexml->_packageXml['maintainers'], + $this->packagexml->_options['maintainers'], 'wrong maintainers'); + } + + function test_valid_deps() + { + if (!$this->_methodExists('_getExistingPackageXML')) { + return; + } + $this->packagexml->_options['deps'] = + array( + array('name' => 'pork', 'rel' => 'ge', 'version' => '1.0.0', + 'optional' => 'yes') + ); + $res = $this->packagexml->_getExistingPackageXML(dirname(__FILE__) . '/', 'test1_package.xml'); + $this->assertFalse(is_object($res), 'returned error'); + $PEAR_Common = $this->packagexml->_options['pearcommonclass']; + $common = new $PEAR_Common; + $contents = $common->infoFromAny(dirname(__FILE__) . '/test1_package.xml'); + $this->assertEquals(array( + array('name' => 'pork', 'rel' => 'ge', 'version' => '1.0.0', + 'optional' => 'yes') + ), $this->packagexml->_packageXml['release_deps'], 'wrong deps'); + $this->assertEquals($contents['maintainers'], $this->packagexml->_packageXml['maintainers'], 'wrong maintainers'); + $this->assertEquals($this->packagexml->_packageXml['release_deps'], + $this->packagexml->_options['deps'], 'wrong deps'); + $this->assertEquals($this->packagexml->_packageXml['maintainers'], + $this->packagexml->_options['maintainers'], 'wrong maintainers'); + } + + function test_valid_maintainers() + { + if (!$this->_methodExists('_getExistingPackageXML')) { + return; + } + $this->packagexml->_options['maintainers'] = + array( + array('name' => 'Gerg', 'email' => 'foo@example.com', + 'role' => 'lead', + 'handle' => 'cellogerg') + ); + $res = $this->packagexml->_getExistingPackageXML(dirname(__FILE__) . '/', 'test1_package.xml'); + $this->assertFalse(is_object($res), 'returned error'); + $PEAR_Common = $this->packagexml->_options['pearcommonclass']; + $common = new $PEAR_Common; + $contents = $common->infoFromAny(dirname(__FILE__) . '/test1_package.xml'); + $this->assertEquals($contents['release_deps'], $this->packagexml->_packageXml['release_deps'], 'wrong deps'); + $this->assertEquals(array( + array('name' => 'Gerg', 'email' => 'foo@example.com', + 'role' => 'lead', + 'handle' => 'cellogerg') + ), $this->packagexml->_packageXml['maintainers'], 'wrong maintainers'); + $this->assertEquals($this->packagexml->_packageXml['release_deps'], + $this->packagexml->_options['deps'], 'wrong deps'); + $this->assertEquals($this->packagexml->_packageXml['maintainers'], + $this->packagexml->_options['maintainers'], 'wrong maintainers'); } } Index: pear/PEAR_PackageFileManager/tests/testsuite.php diff -u pear/PEAR_PackageFileManager/tests/testsuite.php:1.1 pear/PEAR_PackageFileManager/tests/testsuite.php:1.2 --- pear/PEAR_PackageFileManager/tests/testsuite.php:1.1 Tue Oct 14 00:31:39 2003 +++ pear/PEAR_PackageFileManager/tests/testsuite.php Tue Oct 14 20:02:16 2003 @@ -4,7 +4,7 @@ * HTML output for PHPUnit suite tests. * * Copied for PEAR_PackageFileManager from HTML_CSS - * @version $Id: testsuite.php,v 1.1 2003/10/14 04:31:39 cellog Exp $ + * @version $Id: testsuite.php,v 1.2 2003/10/15 00:02:16 cellog Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_CSS */ @@ -47,6 +47,7 @@ <?php $testcases = array( 'PEAR_PackageFileManager_TestCase_generateNewPackageXML', + 'PEAR_PackageFileManager_TestCase_getExistingPackageXML', );