From 24817956758f6d239be1730b7b75949c68f5b624 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Fri, 15 May 2020 14:12:42 +0300 Subject: [PATCH] ISAICP-5825: Add test coverage. --- composer.json | 3 ++- phpunit.xml.dist | 6 +++++ tests/Tasks/CollectionFactoryTest.php | 37 ++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 12483f33..3c7527d8 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,8 @@ }, "require-dev": { "openeuropa/code-review": "~1.0.0-beta3", - "phpunit/phpunit": "~6.0||~7.0" + "phpunit/phpunit": "~6.0||~7.0", + "symfony/phpunit-bridge": "~3.4.21|^4|^5" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 534178b5..7daf97d9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -15,4 +15,10 @@ tests/ + + + + + + diff --git a/tests/Tasks/CollectionFactoryTest.php b/tests/Tasks/CollectionFactoryTest.php index 1ede1272..27fc307b 100644 --- a/tests/Tasks/CollectionFactoryTest.php +++ b/tests/Tasks/CollectionFactoryTest.php @@ -4,7 +4,6 @@ use OpenEuropa\TaskRunner\Tasks\CollectionFactory\loadTasks; use OpenEuropa\TaskRunner\Tests\AbstractTaskTest; -use Robo\Config\Config; /** * Class CollectionFactoryTest @@ -74,6 +73,42 @@ public function testProcessPhpTask($type, $override, $destinationExists, $source $this->assertEquals(trim($expected), trim(file_get_contents($destinationFile))); } + /** + * Tests the exec task and old style exec task deprecation. + * + * @expectedDeprecation Defining a task as a plain text is deprecated. Use the "exec" task and pass arguments and options. + * @group legacy + */ + public function testExecTask(): void + { + $tasks = [ + // This form is deprecated. + 'touch -t 198006062359.59 '.$this->getSandboxFilepath('deprecated.txt'), + // Valid usage. + [ + 'task' => 'exec', + 'command' => 'touch', + 'arguments' => [ + 'current.txt', + ], + 'options' => [ + // 1980-06-06 23:59:59. + '-t' => '198006062359.59' + ], + 'dir' => $this->getSandboxRoot(), + ], + ]; + $this->taskCollectionFactory($tasks)->run(); + + $this->assertFileExists($this->getSandboxFilepath('deprecated.txt')); + $mtime = gmdate('Y-m-d H:i:s', filemtime($this->getSandboxFilepath('deprecated.txt'))); + $this->assertSame('1980-06-06 23:59:59', $mtime); + + $this->assertFileExists($this->getSandboxFilepath('current.txt')); + $mtime = gmdate('Y-m-d H:i:s', filemtime($this->getSandboxFilepath('current.txt'))); + $this->assertSame('1980-06-06 23:59:59', $mtime); + } + /** * @return array */