From 8c3b9939088102e57b377354b5fa7e5c154fd337 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Sat, 13 Jun 2020 18:03:15 +0300 Subject: [PATCH] ISAICP-5988: Extend test coverage. --- tests/Tasks/CollectionFactoryTest.php | 27 ++++++++++++------- .../src/TaskRunner/Commands/TestCommands.php | 4 ++- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/tests/Tasks/CollectionFactoryTest.php b/tests/Tasks/CollectionFactoryTest.php index 88989752..47bedc01 100644 --- a/tests/Tasks/CollectionFactoryTest.php +++ b/tests/Tasks/CollectionFactoryTest.php @@ -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[] = [ @@ -89,10 +89,14 @@ 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)); } /** @@ -100,25 +104,28 @@ public function testRunTask() */ 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)); } /** diff --git a/tests/custom/src/TaskRunner/Commands/TestCommands.php b/tests/custom/src/TaskRunner/Commands/TestCommands.php index 334931bd..2d907206 100644 --- a/tests/custom/src/TaskRunner/Commands/TestCommands.php +++ b/tests/custom/src/TaskRunner/Commands/TestCommands.php @@ -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]); } }