GetoptTest.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Console_Getop
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * Test helper
  24. */
  25. require_once dirname(__FILE__) . '/../../TestHelper.php';
  26. /**
  27. * Zend_Console_Getopt
  28. */
  29. require_once 'Zend/Console/Getopt.php';
  30. /**
  31. * @category Zend
  32. * @package Zend_Console_Getopt
  33. * @subpackage UnitTests
  34. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. * @group Zend_Console_Getopt
  37. */
  38. class Zend_Console_GetoptTest extends PHPUnit_Framework_TestCase
  39. {
  40. public function setUp()
  41. {
  42. if(ini_get('register_argc_argv') == false) {
  43. $this->markTestSkipped("Cannot Test Zend_Console_Getopt without 'register_argc_argv' ini option true.");
  44. }
  45. $_SERVER['argv'] = array('getopttest');
  46. }
  47. public function testGetoptShortOptionsGnuMode()
  48. {
  49. $opts = new Zend_Console_Getopt('abp:', array('-a', '-p', 'p_arg'));
  50. $this->assertEquals(true, $opts->a);
  51. $this->assertNull(@$opts->b);
  52. $this->assertEquals($opts->p, 'p_arg');
  53. }
  54. public function testGetoptLongOptionsZendMode()
  55. {
  56. $opts = new Zend_Console_Getopt(array(
  57. 'apple|a' => 'Apple option',
  58. 'banana|b' => 'Banana option',
  59. 'pear|p=s' => 'Pear option'
  60. ),
  61. array('-a', '-p', 'p_arg'));
  62. $this->assertTrue($opts->apple);
  63. $this->assertNull(@$opts->banana);
  64. $this->assertEquals($opts->pear, 'p_arg');
  65. }
  66. public function testGetoptZendModeEqualsParam()
  67. {
  68. $opts = new Zend_Console_Getopt(array(
  69. 'apple|a' => 'Apple option',
  70. 'banana|b' => 'Banana option',
  71. 'pear|p=s' => 'Pear option'
  72. ),
  73. array('--pear=pear.phpunit.de'));
  74. $this->assertEquals($opts->pear, 'pear.phpunit.de');
  75. }
  76. public function testGetoptToString()
  77. {
  78. $opts = new Zend_Console_Getopt('abp:', array('-a', '-p', 'p_arg'));
  79. $this->assertEquals($opts->__toString(), 'a=true p=p_arg');
  80. }
  81. public function testGetoptDumpString()
  82. {
  83. $opts = new Zend_Console_Getopt('abp:', array('-a', '-p', 'p_arg'));
  84. $this->assertEquals($opts->toString(), 'a=true p=p_arg');
  85. }
  86. public function testGetoptDumpArray()
  87. {
  88. $opts = new Zend_Console_Getopt('abp:', array('-a', '-p', 'p_arg'));
  89. $this->assertEquals(implode(',', $opts->toArray()), 'a,p,p_arg');
  90. }
  91. public function testGetoptDumpJson()
  92. {
  93. $opts = new Zend_Console_Getopt('abp:', array('-a', '-p', 'p_arg'));
  94. $this->assertEquals($opts->toJson(),
  95. '{"options":[{"option":{"flag":"a","parameter":true}},{"option":{"flag":"p","parameter":"p_arg"}}]}');
  96. }
  97. public function testGetoptDumpXml()
  98. {
  99. $opts = new Zend_Console_Getopt('abp:', array('-a', '-p', 'p_arg'));
  100. $this->assertEquals($opts->toXml(),
  101. "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<options><option flag=\"a\"/><option flag=\"p\" parameter=\"p_arg\"/></options>\n");
  102. }
  103. public function testGetoptExceptionForMissingFlag()
  104. {
  105. try {
  106. $opts = new Zend_Console_Getopt(array('|a'=>'Apple option'));
  107. $this->fail('Expected to catch Zend_Console_Getopt_Exception');
  108. } catch (Zend_Exception $e) {
  109. $this->assertType('Zend_Console_Getopt_Exception', $e,
  110. 'Expected Zend_Console_Getopt_Exception, got '.get_class($e));
  111. $this->assertEquals($e->getMessage(),
  112. 'Blank flag not allowed in rule "|a".');
  113. }
  114. }
  115. public function testGetoptExceptionForDuplicateFlag()
  116. {
  117. try {
  118. $opts = new Zend_Console_Getopt(
  119. array('apple|apple'=>'apple-option'));
  120. $this->fail('Expected to catch Zend_Console_Getopt_Exception');
  121. } catch (Zend_Exception $e) {
  122. $this->assertType('Zend_Console_Getopt_Exception', $e,
  123. 'Expected Zend_Console_Getopt_Exception, got '.get_class($e));
  124. $this->assertEquals($e->getMessage(),
  125. 'Option "--apple" is being defined more than once.');
  126. }
  127. try {
  128. $opts = new Zend_Console_Getopt(
  129. array('a'=>'Apple option', 'apple|a'=>'Apple option'));
  130. $this->fail('Expected to catch Zend_Console_Getopt_Exception');
  131. } catch (Zend_Exception $e) {
  132. $this->assertType('Zend_Console_Getopt_Exception', $e,
  133. 'Expected Zend_Console_Getopt_Exception, got '.get_class($e));
  134. $this->assertEquals($e->getMessage(),
  135. 'Option "-a" is being defined more than once.');
  136. }
  137. }
  138. public function testGetoptAddRules()
  139. {
  140. $opts = new Zend_Console_Getopt(
  141. array(
  142. 'apple|a' => 'Apple option',
  143. 'banana|b' => 'Banana option'
  144. ),
  145. array('--pear', 'pear_param'));
  146. try {
  147. $opts->parse();
  148. $this->fail('Expected to catch Zend_Console_Getopt_Exception');
  149. } catch (Zend_Exception $e) {
  150. $this->assertType('Zend_Console_Getopt_Exception', $e,
  151. 'Expected Zend_Console_Getopt_Exception, got '.get_class($e));
  152. $this->assertEquals($e->getMessage(), 'Option "pear" is not recognized.');
  153. }
  154. $opts->addRules(array('pear|p=s' => 'Pear option'));
  155. $this->assertEquals($opts->pear, 'pear_param');
  156. }
  157. public function testGetoptExceptionMissingParameter()
  158. {
  159. $opts = new Zend_Console_Getopt(
  160. array(
  161. 'apple|a=s' => 'Apple with required parameter',
  162. 'banana|b' => 'Banana'
  163. ),
  164. array('--apple'));
  165. try {
  166. $opts->parse();
  167. $this->fail('Expected to catch Zend_Console_Getopt_Exception');
  168. } catch (Zend_Exception $e) {
  169. $this->assertType('Zend_Console_Getopt_Exception', $e,
  170. 'Expected Zend_Console_Getopt_Exception, got '.get_class($e));
  171. $this->assertEquals($e->getMessage(), 'Option "apple" requires a parameter.');
  172. }
  173. }
  174. public function testGetoptOptionalParameter()
  175. {
  176. $opts = new Zend_Console_Getopt(
  177. array(
  178. 'apple|a-s' => 'Apple with optional parameter',
  179. 'banana|b' => 'Banana'
  180. ),
  181. array('--apple', '--banana'));
  182. $this->assertTrue($opts->apple);
  183. $this->assertTrue($opts->banana);
  184. }
  185. public function testGetoptIgnoreCaseGnuMode()
  186. {
  187. $opts = new Zend_Console_Getopt('aB', array('-A', '-b'),
  188. array(Zend_Console_Getopt::CONFIG_IGNORECASE => true));
  189. $this->assertEquals(true, $opts->a);
  190. $this->assertEquals(true, $opts->B);
  191. }
  192. public function testGetoptIgnoreCaseZendMode()
  193. {
  194. $opts = new Zend_Console_Getopt(
  195. array(
  196. 'apple|a' => 'Apple-option',
  197. 'Banana|B' => 'Banana-option'
  198. ),
  199. array('--Apple', '--bAnaNa'),
  200. array(Zend_Console_Getopt::CONFIG_IGNORECASE => true));
  201. $this->assertEquals(true, $opts->apple);
  202. $this->assertEquals(true, $opts->BANANA);
  203. }
  204. public function testGetoptIsSet()
  205. {
  206. $opts = new Zend_Console_Getopt('ab', array('-a'));
  207. $this->assertTrue(isset($opts->a));
  208. $this->assertFalse(isset($opts->b));
  209. }
  210. public function testGetoptIsSetAlias()
  211. {
  212. $opts = new Zend_Console_Getopt('ab', array('-a'));
  213. $opts->setAliases(array('a' => 'apple', 'b' => 'banana'));
  214. $this->assertTrue(isset($opts->apple));
  215. $this->assertFalse(isset($opts->banana));
  216. }
  217. public function testGetoptIsSetInvalid()
  218. {
  219. $opts = new Zend_Console_Getopt('ab', array('-a'));
  220. $opts->setAliases(array('a' => 'apple', 'b' => 'banana'));
  221. $this->assertFalse(isset($opts->cumquat));
  222. }
  223. public function testGetoptSet()
  224. {
  225. $opts = new Zend_Console_Getopt('ab', array('-a'));
  226. $this->assertFalse(isset($opts->b));
  227. $opts->b = true;
  228. $this->assertTrue(isset($opts->b));
  229. }
  230. public function testGetoptSetBeforeParse()
  231. {
  232. $opts = new Zend_Console_Getopt('ab', array('-a'));
  233. $opts->b = true;
  234. $this->assertTrue(isset($opts->b));
  235. }
  236. public function testGetoptUnSet()
  237. {
  238. $opts = new Zend_Console_Getopt('ab', array('-a'));
  239. $this->assertTrue(isset($opts->a));
  240. unset($opts->a);
  241. $this->assertFalse(isset($opts->a));
  242. }
  243. public function testGetoptUnSetBeforeParse()
  244. {
  245. $opts = new Zend_Console_Getopt('ab', array('-a'));
  246. unset($opts->a);
  247. $this->assertFalse(isset($opts->a));
  248. }
  249. /**
  250. * @group ZF-5948
  251. */
  252. public function testGetoptAddSetNonArrayArguments()
  253. {
  254. $opts = new Zend_Console_GetOpt('abp:', array('-foo'));
  255. try {
  256. $opts->setArguments('-a');
  257. $this->fail('Expected to catch a Zend_Console_Getopt_Exception');
  258. } catch(Zend_Exception $e) {
  259. $this->assertType('Zend_Console_Getopt_Exception', $e,
  260. 'Expected Zend_Console_Getopt_Exception, got '. get_class($e));
  261. $this->assertEquals("Parameter #1 to setArguments should be an array",
  262. $e->getMessage());
  263. }
  264. try {
  265. $opts->addArguments('-b');
  266. $this->fail('Expected to catch a Zend_Console_Getopt_Exception');
  267. } catch(Zend_Exception $e) {
  268. $this->assertType('Zend_Console_Getopt_Exception', $e,
  269. 'Expected Zend_Console_Getopt_Exception, got '. get_class($e));
  270. $this->assertEquals("Parameter #1 to addArguments should be an array",
  271. $e->getMessage());
  272. }
  273. }
  274. public function testGetoptAddArguments()
  275. {
  276. $opts = new Zend_Console_Getopt('abp:', array('-a'));
  277. $this->assertNull(@$opts->p);
  278. $opts->addArguments(array('-p', 'p_arg'));
  279. $this->assertEquals($opts->p, 'p_arg');
  280. }
  281. public function testGetoptRemainingArgs()
  282. {
  283. $opts = new Zend_Console_Getopt('abp:', array('-a', '--', 'file1', 'file2'));
  284. $this->assertEquals(implode(',', $opts->getRemainingArgs()), 'file1,file2');
  285. $opts = new Zend_Console_Getopt('abp:', array('-a', 'file1', 'file2'));
  286. $this->assertEquals(implode(',', $opts->getRemainingArgs()), 'file1,file2');
  287. }
  288. public function testGetoptDashDashFalse()
  289. {
  290. try {
  291. $opts = new Zend_Console_Getopt('abp:', array('-a', '--', '--fakeflag'),
  292. array(Zend_Console_Getopt::CONFIG_DASHDASH => false));
  293. $opts->parse();
  294. $this->fail('Expected to catch Zend_Console_Getopt_Exception');
  295. } catch (Zend_Exception $e) {
  296. $this->assertType('Zend_Console_Getopt_Exception', $e,
  297. 'Expected Zend_Console_Getopt_Exception, got '.get_class($e));
  298. $this->assertEquals($e->getMessage(), 'Option "fakeflag" is not recognized.');
  299. }
  300. }
  301. public function testGetoptGetOptions()
  302. {
  303. $opts = new Zend_Console_Getopt('abp:', array('-a', '-p', 'p_arg'));
  304. $this->assertEquals(implode(',', $opts->getOptions()), 'a,p');
  305. }
  306. public function testGetoptGetUsageMessage()
  307. {
  308. $opts = new Zend_Console_Getopt('abp:', array('-x'));
  309. $message = preg_replace('/Usage: .* \[ options \]/',
  310. 'Usage: <progname> [ options ]',
  311. $opts->getUsageMessage());
  312. $message = preg_replace('/ /', '_', $message);
  313. $this->assertEquals($message,
  314. "Usage:_<progname>_[_options_]\n-a___________________\n-b___________________\n-p_<string>__________\n");
  315. }
  316. public function testGetoptUsageMessageFromException()
  317. {
  318. try {
  319. $opts = new Zend_Console_Getopt(array(
  320. 'apple|a-s' => 'apple',
  321. 'banana1|banana2|banana3|banana4' => 'banana',
  322. 'pear=s' => 'pear'),
  323. array('-x'));
  324. $opts->parse();
  325. $this->fail('Expected to catch Zend_Console_Getopt_Exception');
  326. } catch (Zend_Exception $e) {
  327. $this->assertType('Zend_Console_Getopt_Exception', $e,
  328. 'Expected Zend_Console_Getopt_Exception, got '.get_class($e));
  329. $message = preg_replace('/Usage: .* \[ options \]/',
  330. 'Usage: <progname> [ options ]',
  331. $e->getUsageMessage());
  332. $message = preg_replace('/ /', '_', $message);
  333. $this->assertEquals($message,
  334. "Usage:_<progname>_[_options_]\n--apple|-a_[_<string>_]_________________apple\n--banana1|--banana2|--banana3|--banana4_banana\n--pear_<string>_________________________pear\n");
  335. }
  336. }
  337. public function testGetoptSetAliases()
  338. {
  339. $opts = new Zend_Console_Getopt('abp:', array('--apple'));
  340. $opts->setAliases(array('a' => 'apple'));
  341. $this->assertTrue($opts->a);
  342. }
  343. public function testGetoptSetAliasesIgnoreCase()
  344. {
  345. $opts = new Zend_Console_Getopt('abp:', array('--apple'),
  346. array(Zend_Console_Getopt::CONFIG_IGNORECASE => true));
  347. $opts->setAliases(array('a' => 'APPLE'));
  348. $this->assertTrue($opts->apple);
  349. }
  350. public function testGetoptSetAliasesWithNamingConflict()
  351. {
  352. $opts = new Zend_Console_Getopt('abp:', array('--apple'));
  353. $opts->setAliases(array('a' => 'apple'));
  354. try {
  355. $opts->setAliases(array('b' => 'apple'));
  356. $this->fail('Expected to catch Zend_Console_Getopt_Exception');
  357. } catch (Zend_Exception $e) {
  358. $this->assertType('Zend_Console_Getopt_Exception', $e,
  359. 'Expected Zend_Console_Getopt_Exception, got '.get_class($e));
  360. $this->assertEquals($e->getMessage(), 'Option "--apple" is being defined more than once.');
  361. }
  362. }
  363. public function testGetoptSetAliasesInvalid()
  364. {
  365. $opts = new Zend_Console_Getopt('abp:', array('--apple'));
  366. $opts->setAliases(array('c' => 'cumquat'));
  367. $opts->setArguments(array('-c'));
  368. try {
  369. $opts->parse();
  370. $this->fail('Expected to catch Zend_Console_Getopt_Exception');
  371. } catch (Zend_Exception $e) {
  372. $this->assertType('Zend_Console_Getopt_Exception', $e,
  373. 'Expected Zend_Console_Getopt_Exception, got '.get_class($e));
  374. $this->assertEquals('Option "c" is not recognized.', $e->getMessage());
  375. }
  376. }
  377. public function testGetoptSetHelp()
  378. {
  379. $opts = new Zend_Console_Getopt('abp:', array('-a'));
  380. $opts->setHelp(array(
  381. 'a' => 'apple',
  382. 'b' => 'banana',
  383. 'p' => 'pear'));
  384. $message = preg_replace('/Usage: .* \[ options \]/',
  385. 'Usage: <progname> [ options ]',
  386. $opts->getUsageMessage());
  387. $message = preg_replace('/ /', '_', $message);
  388. $this->assertEquals($message,
  389. "Usage:_<progname>_[_options_]\n-a___________________apple\n-b___________________banana\n-p_<string>__________pear\n");
  390. }
  391. public function testGetoptSetHelpInvalid()
  392. {
  393. $opts = new Zend_Console_Getopt('abp:', array('-a'));
  394. $opts->setHelp(array(
  395. 'a' => 'apple',
  396. 'b' => 'banana',
  397. 'p' => 'pear',
  398. 'c' => 'cumquat'));
  399. $message = preg_replace('/Usage: .* \[ options \]/',
  400. 'Usage: <progname> [ options ]',
  401. $opts->getUsageMessage());
  402. $message = preg_replace('/ /', '_', $message);
  403. $this->assertEquals($message,
  404. "Usage:_<progname>_[_options_]\n-a___________________apple\n-b___________________banana\n-p_<string>__________pear\n");
  405. }
  406. public function testGetoptCheckParameterType()
  407. {
  408. $opts = new Zend_Console_Getopt(array(
  409. 'apple|a=i' => 'apple with integer',
  410. 'banana|b=w' => 'banana with word',
  411. 'pear|p=s' => 'pear with string',
  412. 'orange|o-i' => 'orange with optional integer',
  413. 'lemon|l-w' => 'lemon with optional word',
  414. 'kumquat|k-s' => 'kumquat with optional string'));
  415. $opts->setArguments(array('-a', 327));
  416. $opts->parse();
  417. $this->assertEquals(327, $opts->a);
  418. $opts->setArguments(array('-a', 'noninteger'));
  419. try {
  420. $opts->parse();
  421. $this->fail('Expected to catch Zend_Console_Getopt_Exception');
  422. } catch (Zend_Exception $e) {
  423. $this->assertType('Zend_Console_Getopt_Exception', $e,
  424. 'Expected Zend_Console_Getopt_Exception, got '.get_class($e));
  425. $this->assertEquals($e->getMessage(), 'Option "apple" requires an integer parameter, but was given "noninteger".');
  426. }
  427. $opts->setArguments(array('-b', 'word'));
  428. $this->assertEquals('word', $opts->b);
  429. $opts->setArguments(array('-b', 'two words'));
  430. try {
  431. $opts->parse();
  432. $this->fail('Expected to catch Zend_Console_Getopt_Exception');
  433. } catch (Zend_Exception $e) {
  434. $this->assertType('Zend_Console_Getopt_Exception', $e,
  435. 'Expected Zend_Console_Getopt_Exception, got '.get_class($e));
  436. $this->assertEquals($e->getMessage(), 'Option "banana" requires a single-word parameter, but was given "two words".');
  437. }
  438. $opts->setArguments(array('-p', 'string'));
  439. $this->assertEquals('string', $opts->p);
  440. $opts->setArguments(array('-o', 327));
  441. $this->assertEquals(327, $opts->o);
  442. $opts->setArguments(array('-o'));
  443. $this->assertTrue($opts->o);
  444. $opts->setArguments(array('-l', 'word'));
  445. $this->assertEquals('word', $opts->l);
  446. $opts->setArguments(array('-k', 'string'));
  447. $this->assertEquals('string', $opts->k);
  448. }
  449. /**
  450. * @group ZF-2295
  451. */
  452. public function testRegisterArgcArgvOffThrowsException()
  453. {
  454. $argv = $_SERVER['argv'];
  455. unset($_SERVER['argv']);
  456. try {
  457. $opts = new Zend_Console_GetOpt('abp:');
  458. $this->fail();
  459. } catch(Zend_Console_GetOpt_Exception $e) {
  460. $this->assertContains('$_SERVER["argv"]', $e->getMessage());
  461. }
  462. $_SERVER['argv'] = $argv;
  463. }
  464. /**
  465. * Test to ensure that dashed long names will parse correctly
  466. *
  467. * @group ZF-4763
  468. */
  469. public function testDashWithinLongOptionGetsParsed()
  470. {
  471. $opts = new Zend_Console_Getopt(
  472. array( // rules
  473. 'man-bear|m-s' => 'ManBear with dash',
  474. 'man-bear-pig|b=s' => 'ManBearPid with dash',
  475. ),
  476. array( // arguments
  477. '--man-bear-pig=mbp',
  478. '--man-bear',
  479. 'foobar'
  480. )
  481. );
  482. $opts->parse();
  483. $this->assertEquals('foobar', $opts->getOption('man-bear'));
  484. $this->assertEquals('mbp', $opts->getOption('man-bear-pig'));
  485. }
  486. /**
  487. * @group ZF-2064
  488. */
  489. public function testAddRulesDoesNotThrowWarnings()
  490. {
  491. // Fails if warning is thrown: Should not happen!
  492. $opts = new Zend_Console_Getopt('abp:');
  493. $opts->addRules(
  494. array(
  495. 'verbose|v' => 'Print verbose output'
  496. )
  497. );
  498. }
  499. /**
  500. * @group ZF-5345
  501. */
  502. public function testUsingDashWithoutOptionNameAsLastArgumentIsRecognizedAsRemainingArgument()
  503. {
  504. $opts = new Zend_Console_Getopt("abp:", array("-"));
  505. $opts->parse();
  506. $this->assertEquals(1, count($opts->getRemainingArgs()));
  507. $this->assertEquals(array("-"), $opts->getRemainingArgs());
  508. }
  509. /**
  510. * @group ZF-5345
  511. */
  512. public function testUsingDashWithoutOptionNotAsLastArgumentThrowsException()
  513. {
  514. $opts = new Zend_Console_Getopt("abp:", array("-", "file1"));
  515. try {
  516. $opts->parse();
  517. $this->fail();
  518. } catch(Exception $e) {
  519. $this->assertTrue($e instanceof Zend_Console_Getopt_Exception);
  520. }
  521. }
  522. /**
  523. * @group ZF-5624
  524. */
  525. public function testEqualsCharacterInLongOptionsValue()
  526. {
  527. $fooValue = 'some text containing an = sign which breaks';
  528. $opts = new Zend_Console_Getopt(
  529. array('foo=s' => 'Option One (string)'),
  530. array('--foo='.$fooValue)
  531. );
  532. $this->assertEquals($fooValue, $opts->foo);
  533. }
  534. }