Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sadovnik committed May 30, 2016
1 parent 76d1597 commit ddff78e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/ConvertAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ function validateArgs($args)
return Result\success();
}

if ($argsCount == 1) {
$errorMessage = '';
if ($argsCount < 2) {
$errorMessage = 'Not enouth arguments.';
} elseif ($argsCount > 2) {
$errorMessage = 'Too many arguments.';
Expand Down
3 changes: 2 additions & 1 deletion tests/BaseIsomorphicCoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ function ($fixture) {
array_filter(
scandir(self::$baseFixturePath),
function ($path) {
return pathinfo($path, PATHINFO_EXTENSION) === $this->format;
return pathinfo($path, PATHINFO_EXTENSION) === $this->format
&& strpos(pathinfo($path, PATHINFO_FILENAME), 'bad') === false;
}
)
);
Expand Down
7 changes: 4 additions & 3 deletions tests/ConvertActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public function testRun()
// error
[ [ $fp . 'nonexisting.json', $vp . 'test.yml' ], false, 'File not found', false ],
[ [ $fp . '', $vp . 'test.yml' ], false, 'is not a file', false ],
[ [ $fp . 'bad.json', $vp . 'test.yml' ], false, 'Couldn\'t decode json', false ],
[ [ ], false, 'Not enouth arguments', false ],
[ [ 'foo' ], false, 'Not enouth arguments', false ],
[ [ 'foo', 'bar', 'baz'], false, 'Too many arguments', false ],
// [ [ $file->path(), $vp . 'test.yml' ], false, 'Permission denied', false ],
];

Expand All @@ -58,9 +62,6 @@ public function testRun()
$result = runConvertAction($args);
$this->assertEquals($isSuccess, Result\isSuccess($result));
if (Result\isError($result)) {
if ($args[0] === $vp . 'test.json') {
die(var_dump(Result\getMessage($result)));
}
$this->assertTrue(strpos(Result\getMessage($result), $countainsOutput) !== false);
} elseif (count($args) === 2) {
$fileName = pathinfo($args[1])['basename'];
Expand Down

0 comments on commit ddff78e

Please sign in to comment.