Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addendum #284 - warning time is not always present
For stable composer versions, the `COMPOSER_DEV_WARNING_TIME` is not defined, we therefore fall back on the RELEASE_DATE constant, which is always there, this should be "good enough".
- Loading branch information
1 parent
9771642
commit a2754e3
Showing
2 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace ContaoCommunityAlliance\Contao\Composer\Test; | ||
|
||
use ContaoCommunityAlliance\Contao\Composer\Runtime; | ||
|
||
class RuntimeTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function providerReadComposerDevWarningTime() | ||
{ | ||
return array( | ||
array(false, ''), | ||
array(1234567890, 'define(\'COMPOSER_DEV_WARNING_TIME\', 1234567890);'), | ||
array(1234567890, 'const RELEASE_DATE = \'' . date('Y-m-d H:i:s', 1234567890) . '\';'), | ||
); | ||
} | ||
|
||
/** | ||
* Test the readComposerDevWarningTime | ||
* | ||
* @return boolean | ||
* | ||
* @dataProvider providerReadComposerDevWarningTime | ||
*/ | ||
public function testReadComposerDevWarningTime($expected, $testArg) | ||
{ | ||
$tempFile = tmpfile(); | ||
fwrite($tempFile, str_repeat(PHP_EOL, 10) . $testArg . str_repeat(PHP_EOL, 10)); | ||
fseek($tempFile, 0); | ||
$actual = Runtime::readComposerDevWarningTimeFromStream($tempFile); | ||
fclose($tempFile); | ||
|
||
$this->assertEquals($expected, $actual); | ||
} | ||
} |