Skip to content

Commit

Permalink
ISAICP-5825: Add test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiu-cristea committed May 15, 2020
1 parent 4bd2b40 commit 2481795
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 6 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@
<directory>tests/</directory>
</testsuite>
</testsuites>
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="verbose=0"/>
</php>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
</phpunit>
37 changes: 36 additions & 1 deletion tests/Tasks/CollectionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use OpenEuropa\TaskRunner\Tasks\CollectionFactory\loadTasks;
use OpenEuropa\TaskRunner\Tests\AbstractTaskTest;
use Robo\Config\Config;

/**
* Class CollectionFactoryTest
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit 2481795

Please sign in to comment.