Skip to content

Commit

Permalink
ISAICP-5988: Extend test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiu-cristea committed Jun 13, 2020
1 parent d3c4bb3 commit 8c3b993
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
27 changes: 17 additions & 10 deletions tests/Tasks/CollectionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function testProcessPhpTask($type, $override, $destinationExists, $source
*/
public function testRunTask()
{
$filePath = $this->getSandboxFilepath('test-file.txt');
$filePath = $this->getSandboxFilepath('test-file-run.txt');

$tasks = [];
$tasks[] = [
Expand All @@ -89,36 +89,43 @@ public function testRunTask()
],
'options' => [
'filepath' => $filePath,
'array-opt' => [
'opt1',
'opt2',
],
],
];
$this->taskCollectionFactory($tasks)->run();
$this->assertSame(__METHOD__, file_get_contents($filePath));
$this->assertSame(__METHOD__.'opt1opt2', file_get_contents($filePath));
}

/**
* Tests the 'exec' task.
*/
public function testExecTask(): void
{
$filePath = $this->getSandboxFilepath('test-file-exec.txt');

$tasks = [
[
'task' => 'exec',
'command' => 'touch',
'command' => __DIR__.'/../../bin/run',
'arguments' => [
'file.txt',
'custom:test',
__METHOD__,
],
'options' => [
// 1980-06-06 23:59:59.
'-t' => '198006062359.59'
'filepath' => $filePath,
'array-opt' => [
'opt1',
'opt2',
],
],
'dir' => $this->getSandboxRoot(),
],
];
$this->taskCollectionFactory($tasks)->run();

$this->assertFileExists($this->getSandboxFilepath('file.txt'));
$mtime = gmdate('Y-m-d H:i:s', filemtime($this->getSandboxFilepath('file.txt')));
$this->assertSame('1980-06-06 23:59:59', $mtime);
$this->assertSame(__METHOD__.'opt1opt2', file_get_contents($filePath));
}

/**
Expand Down
4 changes: 3 additions & 1 deletion tests/custom/src/TaskRunner/Commands/TestCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ class TestCommands extends AbstractCommands
* @param array $options
*
* @option filepath
* @option array-opt
*/
public function customTest(string $content, array $options = [
'filepath' => InputOption::VALUE_REQUIRED,
'array-opt' => [],
]): void
{
file_put_contents($options['filepath'], $content);
file_put_contents($options['filepath'], $content.$options['array-opt'][0].$options['array-opt'][1]);
}
}

0 comments on commit 8c3b993

Please sign in to comment.