-
-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests and correct TouchTask behavior #1456
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1456 +/- ##
============================================
+ Coverage 52.68% 52.72% +0.03%
- Complexity 9205 9207 +2
============================================
Files 469 469
Lines 22351 22357 +6
============================================
+ Hits 11776 11787 +11
+ Misses 10575 10570 -5
Continue to review full report at Codecov.
|
* drift to account for a lag between when we noted the time and when | ||
* the file was touched. | ||
*/ | ||
$this->assertThat(filemtime($testFile), new IsEqual($nowTime, 1), 'File timestamp not within 1 second of now'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->assertEqualsWithDelta(filemtime($testFile), $nowTime, 1, 'File timestamp not within 1 second of now')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
<filelist dir="." files="${tmp.dir}/idonotexist" /> | ||
<mapper type="merge" to="${tmp.dir}/touchtest" /> | ||
</touch> | ||
</target> | ||
|
||
<target name="testMillis"> | ||
<touch file="${tmp.dir}/millis-file" millis="946684799864" /> <!-- Friday, December 31, 1999 11:59:59.864 PM --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test against milliseconds not microseconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -1,4 +1,6 @@ | |||
<?php | |||
use PHPUnit\Framework\Constraint\IsEqual; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move after file comment!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
$testFile = $this->getProject()->getProperty('tmp.dir') . '/millis-file'; | ||
$this->assertFileExists($testFile); | ||
|
||
$this->assertEquals('December 31 1999 23:59:59', date("F d Y H:i:s", filemtime($testFile))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean something like this?
$this->assertEquals('December 31 1999 23:59:59.000000', date("F d Y H:i:s.u", filemtime($testFile)));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems unnecessary as filemtime() would always return the milliseconds as .000000.
Change testDefaultToNow() to use assertEqualsWithDelta instead of assertThat with an IsEquals constraint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BlairCooper please check https://github.com/phingofficial/phing/pull/1456/checks?check_run_id=1513668571#step:5:633
[phpunit] Testsuite: TimerTest
[phpunit] Tests run: 1, Risky: 0, Warnings: 0, Failures: 1, Errors: 0, Incomplete: 0, Skipped: 0, Time elapsed: 0.01496 s
[phpunit] testTimer FAILED
[phpunit] Failed asserting that '0.00194' matches expected 0.0.
Hmm seems not related. So I will approve. THX for your PR.
Fixes #1452, #1453, #1454
actually contains. Retain millis attribute for continuity with the ANT
Touch task - [TouchTask] millis attribute leads to invalid dates #1453