Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8c3b993

Browse files
committedJun 13, 2020
ISAICP-5988: Extend test coverage.
1 parent d3c4bb3 commit 8c3b993

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed
 

‎tests/Tasks/CollectionFactoryTest.php

+17-10
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function testProcessPhpTask($type, $override, $destinationExists, $source
7878
*/
7979
public function testRunTask()
8080
{
81-
$filePath = $this->getSandboxFilepath('test-file.txt');
81+
$filePath = $this->getSandboxFilepath('test-file-run.txt');
8282

8383
$tasks = [];
8484
$tasks[] = [
@@ -89,36 +89,43 @@ public function testRunTask()
8989
],
9090
'options' => [
9191
'filepath' => $filePath,
92+
'array-opt' => [
93+
'opt1',
94+
'opt2',
95+
],
9296
],
9397
];
9498
$this->taskCollectionFactory($tasks)->run();
95-
$this->assertSame(__METHOD__, file_get_contents($filePath));
99+
$this->assertSame(__METHOD__.'opt1opt2', file_get_contents($filePath));
96100
}
97101

98102
/**
99103
* Tests the 'exec' task.
100104
*/
101105
public function testExecTask(): void
102106
{
107+
$filePath = $this->getSandboxFilepath('test-file-exec.txt');
108+
103109
$tasks = [
104110
[
105111
'task' => 'exec',
106-
'command' => 'touch',
112+
'command' => __DIR__.'/../../bin/run',
107113
'arguments' => [
108-
'file.txt',
114+
'custom:test',
115+
__METHOD__,
109116
],
110117
'options' => [
111-
// 1980-06-06 23:59:59.
112-
'-t' => '198006062359.59'
118+
'filepath' => $filePath,
119+
'array-opt' => [
120+
'opt1',
121+
'opt2',
122+
],
113123
],
114124
'dir' => $this->getSandboxRoot(),
115125
],
116126
];
117127
$this->taskCollectionFactory($tasks)->run();
118-
119-
$this->assertFileExists($this->getSandboxFilepath('file.txt'));
120-
$mtime = gmdate('Y-m-d H:i:s', filemtime($this->getSandboxFilepath('file.txt')));
121-
$this->assertSame('1980-06-06 23:59:59', $mtime);
128+
$this->assertSame(__METHOD__.'opt1opt2', file_get_contents($filePath));
122129
}
123130

124131
/**

‎tests/custom/src/TaskRunner/Commands/TestCommands.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ class TestCommands extends AbstractCommands
1919
* @param array $options
2020
*
2121
* @option filepath
22+
* @option array-opt
2223
*/
2324
public function customTest(string $content, array $options = [
2425
'filepath' => InputOption::VALUE_REQUIRED,
26+
'array-opt' => [],
2527
]): void
2628
{
27-
file_put_contents($options['filepath'], $content);
29+
file_put_contents($options['filepath'], $content.$options['array-opt'][0].$options['array-opt'][1]);
2830
}
2931
}

0 commit comments

Comments
 (0)
Please sign in to comment.