|
3 | 3 | * This file is part of CliArgs.
|
4 | 4 | * git: https://github.com/cheprasov/php-cli-args
|
5 | 5 | *
|
6 |
| - * (C) Alexander Cheprasov <cheprasov.84@ya.ru> |
| 6 | + * (C) Alexander Cheprasov <acheprasov84@gmail.com> |
7 | 7 | *
|
8 | 8 | * For the full copyright and license information, please view the LICENSE
|
9 | 9 | * file that was distributed with this source code.
|
@@ -618,4 +618,73 @@ public function testIsFlagExists($argv, $arg, $alias, $expect)
|
618 | 618 | $CliArgs = new CliArgs();
|
619 | 619 | $this->assertEquals($expect, $CliArgs->isFlagExists($arg, $alias));
|
620 | 620 | }
|
| 621 | + |
| 622 | + public function providerTestIsFlagOrAliasExists() |
| 623 | + { |
| 624 | + return [ |
| 625 | + __LINE__ => [ |
| 626 | + [__FILE__], |
| 627 | + 'foo', |
| 628 | + false |
| 629 | + ], |
| 630 | + __LINE__ => [ |
| 631 | + [__FILE__, '--bar'], |
| 632 | + 'foo', |
| 633 | + false |
| 634 | + ], |
| 635 | + __LINE__ => [ |
| 636 | + [__FILE__, 'foo'], |
| 637 | + 'foo', |
| 638 | + false |
| 639 | + ], |
| 640 | + __LINE__ => [ |
| 641 | + [__FILE__, '--foo', 'bar'], |
| 642 | + 'foo', |
| 643 | + true |
| 644 | + ], |
| 645 | + __LINE__ => [ |
| 646 | + [__FILE__, '--foo', 'bar'], |
| 647 | + 'foo', |
| 648 | + true |
| 649 | + ], |
| 650 | + __LINE__ => [ |
| 651 | + [__FILE__, '-f'], |
| 652 | + 'foo', |
| 653 | + true |
| 654 | + ], |
| 655 | + __LINE__ => [ |
| 656 | + [__FILE__, '-f', 'bar'], |
| 657 | + 'f', |
| 658 | + true |
| 659 | + ], |
| 660 | + __LINE__ => [ |
| 661 | + [__FILE__, '-age', '12'], |
| 662 | + 'a', |
| 663 | + true |
| 664 | + ], |
| 665 | + __LINE__ => [ |
| 666 | + [__FILE__, '-a'], |
| 667 | + 'age', |
| 668 | + true |
| 669 | + ], |
| 670 | + ]; |
| 671 | + } |
| 672 | + |
| 673 | + /** |
| 674 | + * @see \CliArgs\CliArgs::isFlagOrAliasExists |
| 675 | + * @dataProvider providerTestIsFlagOrAliasExists |
| 676 | + * @param array $argv |
| 677 | + * @param string $arg |
| 678 | + * @param bool $expect |
| 679 | + */ |
| 680 | + public function testIsFlagOrAliasExists($argv, $arg, $expect) |
| 681 | + { |
| 682 | + $GLOBALS['argv'] = $argv; |
| 683 | + $CliArgs = new CliArgs([ |
| 684 | + 'f' => 'foo', |
| 685 | + 'b' => 'bar', |
| 686 | + 'a' => 'age', |
| 687 | + ]); |
| 688 | + $this->assertEquals($expect, $CliArgs->isFlagOrAliasExists($arg)); |
| 689 | + } |
621 | 690 | }
|
0 commit comments