-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/better-handling-of-untrusted-triggered-errors'
- Loading branch information
Showing
10 changed files
with
647 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
final class FakeGetoptTest extends TestCase | ||
{ | ||
public function test_fake_getopt_no_args() | ||
{ | ||
$this->assertEquals( | ||
fake_getopt(array('php', '--halp'), '', array()), | ||
array() | ||
); | ||
$this->assertEquals( | ||
fake_getopt(array('php'), '', array()), | ||
array() | ||
); | ||
} | ||
public function test_fake_getopt_no_match() | ||
{ | ||
$this->assertEquals( | ||
fake_getopt(array('php', '--halp'), '', array('help')), | ||
array() | ||
); | ||
$this->assertEquals( | ||
fake_getopt(array('php'), '', array('help')), | ||
array() | ||
); | ||
} | ||
|
||
public function test_fake_getopt_bool_arg() | ||
{ | ||
$this->assertEquals( | ||
fake_getopt(array('php', '--help'), '', array('help')), | ||
array('help' => false) | ||
); | ||
} | ||
public function test_fake_getopt_string_arg() | ||
{ | ||
$this->assertEquals( | ||
fake_getopt(array('php', '--media-dir'), '', array('media-dir::')), | ||
array('media-dir' => '') | ||
); | ||
$this->assertEquals( | ||
fake_getopt(array('php', '--media-dir='), '', array('media-dir::')), | ||
array() // XXX: seems to be a bug in getopt | ||
); | ||
$this->assertEquals( | ||
fake_getopt(array('php', '--media-dir=test'), '', array('media-dir::')), | ||
array('media-dir' => 'test') | ||
); | ||
} | ||
public function test_fake_getopt_escaping() | ||
{ | ||
$this->assertEquals( | ||
fake_getopt(array('php', "--media-dir= "), '', array('media-dir::')), | ||
array('media-dir' => ' ') | ||
); | ||
$this->assertEquals( | ||
fake_getopt(array('php', '--media-dir=""'), '', array('media-dir::')), | ||
array('media-dir' => '""') | ||
); | ||
$this->assertEquals( | ||
fake_getopt(array('php', "--media-dir=''"), '', array('media-dir::')), | ||
array('media-dir' => "''") | ||
); | ||
} | ||
public function test_fake_getopt_both_arg_types() | ||
{ | ||
$this->assertEquals( | ||
fake_getopt(array('php', '--help', '--media-dir'), '', array('help', 'media-dir::')), | ||
array('help' => false, 'media-dir' => '') | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php declare(strict_types=1); | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
final class FourOhFourTest extends TestCase | ||
{ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
prepare_testing_dir(); | ||
} | ||
|
||
public function test_non_existent_dir_prints_bare_error_CLI_case(): void | ||
{ | ||
exec('php dir2cast.php --media-dir=dir2cast.ini', $output, $returncode); | ||
$this->assertEquals("Not Found: dir2cast.ini", implode("\n", $output)); | ||
$this->assertEquals(254, $returncode); // 254 is -2 | ||
} | ||
|
||
public static function tearDownAfterClass(): void | ||
{ | ||
chdir('..'); | ||
} | ||
} |
Oops, something went wrong.