cvs: pear /PEAR_PackageFileManager/tests PEAR_PackageFileManager_TestCase_addReplacement.php PEAR_PackageFileManager_TestCase_addRole.php
testsuite.php

From: Date: Thu, 16 Oct 2003 04:15:40 +0000
Subject: cvs: pear /PEAR_PackageFileManager/tests PEAR_PackageFileManager_TestCase_addReplacement.php PEAR_PackageFileManager_TestCase_addRole.php
testsuite.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-13654@lists.php.net to get a copy of this message
cellog Thu Oct 16 00:15:40 2003 EDT Added files: /pear/PEAR_PackageFileManager/tests PEAR_PackageFileManager_TestCase_addReplacement.php Modified files: /pear/PEAR_PackageFileManager/tests PEAR_PackageFileManager_TestCase_addRole.php testsuite.php Log: new test case, fix bug in last one

Index: pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_addRole.php diff -u pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_addRole.php:1.1 pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_addRole.php:1.2 --- pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_addRole.php:1.1 Thu Oct 16 00:04:18 2003 +++ pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_addRole.php Thu Oct 16 00:15:40 2003 @@ -3,7 +3,7 @@ /** * API Unit tests for PEAR_PackageFileManager package. * - * @version $Id: PEAR_PackageFileManager_TestCase_addRole.php,v 1.1 2003/10/16 04:04:18 cellog Exp $ + * @version $Id: PEAR_PackageFileManager_TestCase_addRole.php,v 1.2 2003/10/16 04:15:40 cellog Exp $ * @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS * @author Greg Beaver * @package PEAR_PackageFileManager @@ -154,7 +154,7 @@ $this->assertFalse($this->errorThrown, 'error thrown'); $this->packagexml->addRole('frog', 'php'); $this->assertFalse($this->errorThrown, 'error thrown'); - $this->assertTrue('php', $this->packagexml->_options['roles']['frog'], + $this->assertEquals('php', $this->packagexml->_options['roles']['frog'], 'extension was not set, should be'); } } Index: pear/PEAR_PackageFileManager/tests/testsuite.php diff -u pear/PEAR_PackageFileManager/tests/testsuite.php:1.4 pear/PEAR_PackageFileManager/tests/testsuite.php:1.5 --- pear/PEAR_PackageFileManager/tests/testsuite.php:1.4 Thu Oct 16 00:04:37 2003 +++ pear/PEAR_PackageFileManager/tests/testsuite.php Thu Oct 16 00:15:40 2003 @@ -4,7 +4,7 @@ * HTML output for PHPUnit suite tests. * * Copied for PEAR_PackageFileManager from HTML_CSS - * @version $Id: testsuite.php,v 1.4 2003/10/16 04:04:37 cellog Exp $ + * @version $Id: testsuite.php,v 1.5 2003/10/16 04:15:40 cellog Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_CSS */ @@ -50,6 +50,7 @@ 'PEAR_PackageFileManager_TestCase_getExistingPackageXML', 'PEAR_PackageFileManager_TestCase_setOptions', 'PEAR_PackageFileManager_TestCase_addRole', + 'PEAR_PackageFileManager_TestCase_addReplacement', ); Index: pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_addReplacement.php +++ pear/PEAR_PackageFileManager/tests/PEAR_PackageFileManager_TestCase_addReplacement.php <?php /** * API Unit tests for PEAR_PackageFileManager package. * * @version $Id: PEAR_PackageFileManager_TestCase_addReplacement.php,v 1.1 2003/10/16 04:15:40 cellog Exp $ * @author Laurent Laville <pear@laurent-laville.org> portions from HTML_CSS * @author Greg Beaver * @package PEAR_PackageFileManager */ /** * @package PEAR_PackageFileManager */ class PEAR_PackageFileManager_TestCase_addReplacement extends PHPUnit_TestCase { /** * A PEAR_PackageFileManager object * @var object */ var $packagexml; function PEAR_PackageFileManager_TestCase_addReplacement($name) { $this->PHPUnit_TestCase($name); } function setUp() { error_reporting(E_ALL); $this->errorOccured = false; set_error_handler(array(&$this, 'errorHandler')); $this->packagexml = new PEAR_PackageFileManager; PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, array(&$this, 'PEARerrorHandler')); $this->errorThrown = false; $this->_expectedMessage = 'NO ERROR TRIGGERED'; $this->_expectedCode = -1; $this->_testMethod = 'unknown'; } function tearDown() { unset($this->packagexml); PEAR::popErrorHandling(); } 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, 'PEAR_PACKAGEFILEMANAGER_NOBASEDIR' => PEAR_PACKAGEFILEMANAGER_NOBASEDIR, 'PEAR_PACKAGEFILEMANAGER_GENERATOR_NOTFOUND' => PEAR_PACKAGEFILEMANAGER_GENERATOR_NOTFOUND, 'PEAR_PACKAGEFILEMANAGER_GENERATOR_NOTFOUND_ANYWHERE' => PEAR_PACKAGEFILEMANAGER_GENERATOR_NOTFOUND_ANYWHERE, 'PEAR_PACKAGEFILEMANAGER_CANTWRITE_PKGFILE' => PEAR_PACKAGEFILEMANAGER_CANTWRITE_PKGFILE, 'PEAR_PACKAGEFILEMANAGER_DEST_UNWRITABLE' => PEAR_PACKAGEFILEMANAGER_DEST_UNWRITABLE, 'PEAR_PACKAGEFILEMANAGER_CANTCOPY_PKGFILE' => PEAR_PACKAGEFILEMANAGER_CANTCOPY_PKGFILE, 'PEAR_PACKAGEFILEMANAGER_CANTOPEN_TMPPKGFILE' => PEAR_PACKAGEFILEMANAGER_CANTOPEN_TMPPKGFILE, 'PEAR_PACKAGEFILEMANAGER_PATH_DOESNT_EXIST' => PEAR_PACKAGEFILEMANAGER_PATH_DOESNT_EXIST, 'PEAR_PACKAGEFILEMANAGER_NOCVSENTRIES' => PEAR_PACKAGEFILEMANAGER_NOCVSENTRIES, 'PEAR_PACKAGEFILEMANAGER_DIR_DOESNT_EXIST' => PEAR_PACKAGEFILEMANAGER_DIR_DOESNT_EXIST, 'PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS' => PEAR_PACKAGEFILEMANAGER_RUN_SETOPTIONS, 'PEAR_PACKAGEFILEMANAGER_NOPACKAGE' => PEAR_PACKAGEFILEMANAGER_NOPACKAGE, 'PEAR_PACKAGEFILEMANAGER_WRONG_MROLE' => PEAR_PACKAGEFILEMANAGER_WRONG_MROLE, 'PEAR_PACKAGEFILEMANAGER_NOSUMMARY' => PEAR_PACKAGEFILEMANAGER_NOSUMMARY, 'PEAR_PACKAGEFILEMANAGER_NODESC' => PEAR_PACKAGEFILEMANAGER_NODESC, 'PEAR_PACKAGEFILEMANAGER_ADD_MAINTAINERS' => PEAR_PACKAGEFILEMANAGER_ADD_MAINTAINERS, 'PEAR_PACKAGEFILEMANAGER_NO_FILES' => PEAR_PACKAGEFILEMANAGER_NO_FILES, 'PEAR_PACKAGEFILEMANAGER_IGNORED_EVERYTHING' => PEAR_PACKAGEFILEMANAGER_IGNORED_EVERYTHING, 'PEAR_PACKAGEFILEMANAGER_INVALID_PACKAGE' => PEAR_PACKAGEFILEMANAGER_INVALID_PACKAGE, 'PEAR_PACKAGEFILEMANAGER_INVALID_REPLACETYPE' => PEAR_PACKAGEFILEMANAGER_INVALID_REPLACETYPE, 'PEAR_PACKAGEFILEMANAGER_INVALID_ROLE' => PEAR_PACKAGEFILEMANAGER_INVALID_ROLE, 'PEAR_PACKAGEFILEMANAGER_PHP_NOT_PACKAGE' => PEAR_PACKAGEFILEMANAGER_PHP_NOT_PACKAGE )); return $codes[$code]; } function _stripWhitespace($str) { return preg_replace('/\\s+/', '', $str); } function _methodExists($name) { if (in_array(strtolower($name), get_class_methods($this->packagexml))) { return true; } $this->assertTrue(false, 'method '. $name . ' not implemented in ' . get_class($this->packagexml)); return false; } function errorHandler($errno, $errstr, $errfile, $errline) { //die("$errstr in $errfile at line $errline: $errstr"); $this->errorOccured = true; $this->assertTrue(false, "$errstr at line $errline, $errfile"); } function PEARerrorHandler($error) { $this->assertEquals($this->_expectedCode, $error->getCode(), $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) { $this->_expectedMessage = $msg; $this->_expectedCode = $code; $this->_testMethod = $method; } function test_invalid_replacement() { if (!$this->_methodExists('setOptions')) { return; } if (!$this->_methodExists('addReplacement')) { return; } $this->packagexml->setOptions(array('state' => 'alpha', 'version' => '1.0', 'packagedirectory' => dirname(__FILE__), 'baseinstalldir' => 'Foo', 'packagefile' => 'test1_package.xml', 'filelistgenerator' => 'File')); $this->assertFalse($this->errorThrown, 'error thrown'); $this->expectPEARError('invalid role test', 'PEAR_PackageFileManager Error: Replacement Type must be one of "' . implode(PEAR_Common::getReplacementTypes(), ', ') . '", was passed "ribbit"', PEAR_PACKAGEFILEMANAGER_INVALID_REPLACETYPE ); $this->packagexml->addReplacement('peeber.php', 'ribbit', 'tadpole', 'frog'); $this->assertEquals('true', $this->errorThrown, 'error not thrown'); $this->assertTrue(empty($this->packagexml->_options['replacements']), 'replacements was set, should not be'); } function test_valid_replacement() { if (!$this->_methodExists('setOptions')) { return; } if (!$this->_methodExists('addReplacement')) { return; } $this->packagexml->setOptions(array('state' => 'alpha', 'version' => '1.0', 'packagedirectory' => dirname(__FILE__), 'baseinstalldir' => 'Foo', 'packagefile' => 'test1_package.xml', 'filelistgenerator' => 'File')); $this->assertFalse($this->errorThrown, 'error thrown'); $this->packagexml->addReplacement('peeber.php', 'package-info', '@version@', 'version'); $this->assertFalse($this->errorThrown, 'error thrown'); $this->assertEquals(array(array('type' => 'package-info', 'from' => '@version@', 'to' => 'version')), $this->packagexml->_options['replacements']['peeber.php'], 'extension was not set, should be'); } } ?>
« previous php.pear.cvs (#13654) next »