cvs: pear /PhpDocumentor/Documentation/tests bug1602961.php /PhpDocumentor/phpDocumentor Setup.inc.php
| From: | Chuck Burgess | Date: | Fri, 09 Feb 2007 14:09:17 +0000 |
| Subject: | cvs: pear /PhpDocumentor/Documentation/tests bug1602961.php /PhpDocumentor/phpDocumentor Setup.inc.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-44591@lists.php.net to get a copy of this message | ||
ashnazg Fri Feb 9 14:09:17 2007 UTC
Added files:
/pear/PhpDocumentor/Documentation/tests bug1602961.php
Modified files:
/pear/PhpDocumentor/phpDocumentor Setup.inc.php
Log:
fix sourceforge bug
[1602961] "--hidden off" / "-dh off" results in hidden=true
[1611861] Fix --hidden flag handling
http://cvs.php.net/viewvc.cgi/pear/PhpDocumentor/phpDocumentor/Setup.inc.php?r1=1.17&r2=1.18&diff_format=u Index: pear/PhpDocumentor/phpDocumentor/Setup.inc.php diff -u pear/PhpDocumentor/phpDocumentor/Setup.inc.php:1.17 pear/PhpDocumentor/phpDocumentor/Setup.inc.php:1.18 --- pear/PhpDocumentor/phpDocumentor/Setup.inc.php:1.17 Thu Feb 8 22:44:25 2007 +++ pear/PhpDocumentor/phpDocumentor/Setup.inc.php Fri Feb 9 14:09:17 2007 @@ -30,7 +30,7 @@ * @author Gregory Beaver <cellog@php.net> * @copyright 2002-2006 Gregory Beaver * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @version CVS: $Id: Setup.inc.php,v 1.17 2007/02/08 22:44:25 ashnazg Exp $ + * @version CVS: $Id: Setup.inc.php,v 1.18 2007/02/09 14:09:17 ashnazg Exp $ * @link http://www.phpdoc.org * @link http://pear.php.net/PhpDocumentor * @since 1.2 @@ -255,15 +255,13 @@ echo $this->setup->displayHelpMsg(); die(); } - - if (isset($_phpDocumentor_setting['hidden'])) $this->hidden = true; + + // set to parse hidden files + $this->hidden = (isset($_phpDocumentor_setting['hidden'])) ? decideOnOrOff($_phpDocumentor_setting['hidden']) : false; // set to parse elements marked private with @access private - if (isset($_phpDocumentor_setting['parseprivate']) && $_phpDocumentor_setting['parseprivate'] == 'on') - { - $this->render->setParsePrivate(true); - } - + $this->render->setParsePrivate((isset($_phpDocumentor_setting['parseprivate'])) ? decideOnOrOff($_phpDocumentor_setting['parseprivate']) : false); + if (isset($_phpDocumentor_setting['ignoretags'])) { $ignoretags = explode(',', $_phpDocumentor_setting['ignoretags']); @@ -343,13 +341,8 @@ } // set the mode (quiet or verbose) - if ( isset($_phpDocumentor_setting['quiet']) || strcasecmp($_phpDocumentor_setting['junk'], "-q") == 0 || strcasecmp($_phpDocumentor_setting['junk'], "--quiet") == 0) - { - if (isset($_phpDocumentor_setting['quiet']) && $_phpDocumentor_setting['quiet'] != 'on'); - else - $this->render->setQuietMode(true); - } - + $this->render->setQuietMode((isset($_phpDocumentor_setting['quiet'])) ? decideOnOrOff($_phpDocumentor_setting['quiet']) : false); + // Setup the different classes if (isset($_phpDocumentor_setting['templatebase'])) { @@ -450,14 +443,14 @@ $this->parse->eventHandlers[PARSER_EVENT_DOCBLOCK] = 'JavaDochandleDocblock'; } - function setParsePrivate() + function setParsePrivate($flag = true) { - $this->render->setParsePrivate(true); + $this->render->setParsePrivate($flag); } - function setQuietMode() + function setQuietMode($flag = true) { - $this->render->setQuietMode(true); + $this->render->setQuietMode($flag); } function setTargetDir($target) @@ -491,9 +484,9 @@ $this->dirs = $dirs; } - function parseHiddenFiles() + function parseHiddenFiles($flag = true) { - $this->hidden = true; + $this->hidden = $flag; } function setIgnore($ig) @@ -872,12 +865,35 @@ } /** + * Fuzzy logic to interpret the boolean args' intent + * @param string the command-line option to analyze + * @return boolean our best guess of the value's boolean intent + */ +function decideOnOrOff($value_to_guess = 'NO VALUE WAS PASSED') +{ + $these_probably_mean_yes = array( + '', // "--hidden" with no value + 'on', // "--hidden on" + 'y', 'yes', // "--hidden y" + 'true', // "--hidden true" + '1' // "--hidden 1" + ); + $best_guess = false; // default to "false", "off", "no", "take a hike" + + if (in_array(strtolower(trim($value_to_guess)), $these_probably_mean_yes)) + { + $best_guess = true; + } + return $best_guess; +} + +/** * Print parse information if quiet setting is off */ function phpDocumentor_out($string) { global $_phpDocumentor_setting; - if (!isset($_phpDocumentor_setting['quiet']) || !$_phpDocumentor_setting['quiet']) + if ((isset($_phpDocumentor_setting['quiet'])) ? !decideOnOrOff($_phpDocumentor_setting['quiet']) : true) { print $string; } http://cvs.php.net/viewvc.cgi/pear/PhpDocumentor/Documentation/tests/bug1602961.php?view=markup&rev=1.1 Index: pear/PhpDocumentor/Documentation/tests/bug1602961.php +++ pear/PhpDocumentor/Documentation/tests/bug1602961.php <?php // Call phpDocumentor_setupTest::main() if this source file is executed directly. if (!defined("PHPUnit_MAIN_METHOD")) { define("PHPUnit_MAIN_METHOD", "phpDocumentor_setupTest::main"); } require_once "PHPUnit/Framework/TestCase.php"; require_once "PHPUnit/Framework/TestSuite.php"; require_once 'phpDocumentor/Setup.inc.php'; /** * Test class for phpDocumentor_setup. */ class Documentation_tests_bug1602961 extends PHPUnit_Framework_TestCase { private $ps; /** * 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("phpDocumentor_setupTest"); $result = PHPUnit_TextUI_TestRunner::run($suite); } /** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $GLOBALS['_phpDocumentor_install_dir'] = "."; $GLOBALS['_phpDocumentor_setting']['quiet'] = "true"; // $this->ps = new phpDocumentor_setup; // setTitle("Unit Testing"); // this step is necessary to ensure ps->render is instantiated } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * * @access protected */ protected function tearDown() { } /** * verify the fuzzy logic that guesses * the intent of boolean arg values */ public function testDecideOnOrOff() { // verify all expected values are interpreted correctly $this->assertFalse(decideOnOrOff('off')); $this->assertTrue(decideOnOrOff('on')); // verify all the fuzzy values we know to recognize // no $this->assertFalse(decideOnOrOff('Off')); $this->assertFalse(decideOnOrOff('OFF')); $this->assertFalse(decideOnOrOff('no')); $this->assertFalse(decideOnOrOff('No')); $this->assertFalse(decideOnOrOff('NO')); $this->assertFalse(decideOnOrOff('false')); $this->assertFalse(decideOnOrOff('False')); $this->assertFalse(decideOnOrOff('FALSE')); $this->assertFalse(decideOnOrOff(0)); // yes $this->assertTrue(decideOnOrOff('')); $this->assertTrue(decideOnOrOff('On')); $this->assertTrue(decideOnOrOff('ON')); $this->assertTrue(decideOnOrOff('y')); $this->assertTrue(decideOnOrOff('Y')); $this->assertTrue(decideOnOrOff('yes')); $this->assertTrue(decideOnOrOff('Yes')); $this->assertTrue(decideOnOrOff('YES')); $this->assertTrue(decideOnOrOff('true')); $this->assertTrue(decideOnOrOff('True')); $this->assertTrue(decideOnOrOff('TRUE')); $this->assertFalse(decideOnOrOff(1)); // unexpected $this->assertTrue(decideOnOrOff(' ')); $this->assertFalse(decideOnOrOff()); $this->assertFalse(decideOnOrOff(-1)); $this->assertFalse(decideOnOrOff(10)); $this->assertFalse(decideOnOrOff("ash nazg durbatuluk")); } } // Call phpDocumentor_setupTest::main() if this source file is executed directly. if (PHPUnit_MAIN_METHOD == "phpDocumentor_setupTest::main") { phpDocumentor_setupTest::main(); } ?>
http://cvs.php.net/viewvc.cgi/pear/PhpDocumentor/phpDocumentor/Setup.inc.php?r1=1.17&r2=1.18&diff_format=u Index: pear/PhpDocumentor/phpDocumentor/Setup.inc.php diff -u pear/PhpDocumentor/phpDocumentor/Setup.inc.php:1.17 pear/PhpDocumentor/phpDocumentor/Setup.inc.php:1.18 --- pear/PhpDocumentor/phpDocumentor/Setup.inc.php:1.17 Thu Feb 8 22:44:25 2007 +++ pear/PhpDocumentor/phpDocumentor/Setup.inc.php Fri Feb 9 14:09:17 2007 @@ -30,7 +30,7 @@ * @author Gregory Beaver <cellog@php.net> * @copyright 2002-2006 Gregory Beaver * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @version CVS: $Id: Setup.inc.php,v 1.17 2007/02/08 22:44:25 ashnazg Exp $ + * @version CVS: $Id: Setup.inc.php,v 1.18 2007/02/09 14:09:17 ashnazg Exp $ * @link http://www.phpdoc.org * @link http://pear.php.net/PhpDocumentor * @since 1.2 @@ -255,15 +255,13 @@ echo $this->setup->displayHelpMsg(); die(); } - - if (isset($_phpDocumentor_setting['hidden'])) $this->hidden = true; + + // set to parse hidden files + $this->hidden = (isset($_phpDocumentor_setting['hidden'])) ? decideOnOrOff($_phpDocumentor_setting['hidden']) : false; // set to parse elements marked private with @access private - if (isset($_phpDocumentor_setting['parseprivate']) && $_phpDocumentor_setting['parseprivate'] == 'on') - { - $this->render->setParsePrivate(true); - } - + $this->render->setParsePrivate((isset($_phpDocumentor_setting['parseprivate'])) ? decideOnOrOff($_phpDocumentor_setting['parseprivate']) : false); + if (isset($_phpDocumentor_setting['ignoretags'])) { $ignoretags = explode(',', $_phpDocumentor_setting['ignoretags']); @@ -343,13 +341,8 @@ } // set the mode (quiet or verbose) - if ( isset($_phpDocumentor_setting['quiet']) || strcasecmp($_phpDocumentor_setting['junk'], "-q") == 0 || strcasecmp($_phpDocumentor_setting['junk'], "--quiet") == 0) - { - if (isset($_phpDocumentor_setting['quiet']) && $_phpDocumentor_setting['quiet'] != 'on'); - else - $this->render->setQuietMode(true); - } - + $this->render->setQuietMode((isset($_phpDocumentor_setting['quiet'])) ? decideOnOrOff($_phpDocumentor_setting['quiet']) : false); + // Setup the different classes if (isset($_phpDocumentor_setting['templatebase'])) { @@ -450,14 +443,14 @@ $this->parse->eventHandlers[PARSER_EVENT_DOCBLOCK] = 'JavaDochandleDocblock'; } - function setParsePrivate() + function setParsePrivate($flag = true) { - $this->render->setParsePrivate(true); + $this->render->setParsePrivate($flag); } - function setQuietMode() + function setQuietMode($flag = true) { - $this->render->setQuietMode(true); + $this->render->setQuietMode($flag); } function setTargetDir($target) @@ -491,9 +484,9 @@ $this->dirs = $dirs; } - function parseHiddenFiles() + function parseHiddenFiles($flag = true) { - $this->hidden = true; + $this->hidden = $flag; } function setIgnore($ig) @@ -872,12 +865,35 @@ } /** + * Fuzzy logic to interpret the boolean args' intent + * @param string the command-line option to analyze + * @return boolean our best guess of the value's boolean intent + */ +function decideOnOrOff($value_to_guess = 'NO VALUE WAS PASSED') +{ + $these_probably_mean_yes = array( + '', // "--hidden" with no value + 'on', // "--hidden on" + 'y', 'yes', // "--hidden y" + 'true', // "--hidden true" + '1' // "--hidden 1" + ); + $best_guess = false; // default to "false", "off", "no", "take a hike" + + if (in_array(strtolower(trim($value_to_guess)), $these_probably_mean_yes)) + { + $best_guess = true; + } + return $best_guess; +} + +/** * Print parse information if quiet setting is off */ function phpDocumentor_out($string) { global $_phpDocumentor_setting; - if (!isset($_phpDocumentor_setting['quiet']) || !$_phpDocumentor_setting['quiet']) + if ((isset($_phpDocumentor_setting['quiet'])) ? !decideOnOrOff($_phpDocumentor_setting['quiet']) : true) { print $string; } http://cvs.php.net/viewvc.cgi/pear/PhpDocumentor/Documentation/tests/bug1602961.php?view=markup&rev=1.1 Index: pear/PhpDocumentor/Documentation/tests/bug1602961.php +++ pear/PhpDocumentor/Documentation/tests/bug1602961.php <?php // Call phpDocumentor_setupTest::main() if this source file is executed directly. if (!defined("PHPUnit_MAIN_METHOD")) { define("PHPUnit_MAIN_METHOD", "phpDocumentor_setupTest::main"); } require_once "PHPUnit/Framework/TestCase.php"; require_once "PHPUnit/Framework/TestSuite.php"; require_once 'phpDocumentor/Setup.inc.php'; /** * Test class for phpDocumentor_setup. */ class Documentation_tests_bug1602961 extends PHPUnit_Framework_TestCase { private $ps; /** * 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("phpDocumentor_setupTest"); $result = PHPUnit_TextUI_TestRunner::run($suite); } /** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $GLOBALS['_phpDocumentor_install_dir'] = "."; $GLOBALS['_phpDocumentor_setting']['quiet'] = "true"; // $this->ps = new phpDocumentor_setup; // setTitle("Unit Testing"); // this step is necessary to ensure ps->render is instantiated } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * * @access protected */ protected function tearDown() { } /** * verify the fuzzy logic that guesses * the intent of boolean arg values */ public function testDecideOnOrOff() { // verify all expected values are interpreted correctly $this->assertFalse(decideOnOrOff('off')); $this->assertTrue(decideOnOrOff('on')); // verify all the fuzzy values we know to recognize // no $this->assertFalse(decideOnOrOff('Off')); $this->assertFalse(decideOnOrOff('OFF')); $this->assertFalse(decideOnOrOff('no')); $this->assertFalse(decideOnOrOff('No')); $this->assertFalse(decideOnOrOff('NO')); $this->assertFalse(decideOnOrOff('false')); $this->assertFalse(decideOnOrOff('False')); $this->assertFalse(decideOnOrOff('FALSE')); $this->assertFalse(decideOnOrOff(0)); // yes $this->assertTrue(decideOnOrOff('')); $this->assertTrue(decideOnOrOff('On')); $this->assertTrue(decideOnOrOff('ON')); $this->assertTrue(decideOnOrOff('y')); $this->assertTrue(decideOnOrOff('Y')); $this->assertTrue(decideOnOrOff('yes')); $this->assertTrue(decideOnOrOff('Yes')); $this->assertTrue(decideOnOrOff('YES')); $this->assertTrue(decideOnOrOff('true')); $this->assertTrue(decideOnOrOff('True')); $this->assertTrue(decideOnOrOff('TRUE')); $this->assertFalse(decideOnOrOff(1)); // unexpected $this->assertTrue(decideOnOrOff(' ')); $this->assertFalse(decideOnOrOff()); $this->assertFalse(decideOnOrOff(-1)); $this->assertFalse(decideOnOrOff(10)); $this->assertFalse(decideOnOrOff("ash nazg durbatuluk")); } } // Call phpDocumentor_setupTest::main() if this source file is executed directly. if (PHPUnit_MAIN_METHOD == "phpDocumentor_setupTest::main") { phpDocumentor_setupTest::main(); } ?>