Open
Conversation
|
Thanks for adding this. Please add tests. My two cents with a skeleton of tests for the change: public function test_touch(){
$author = new Author();
$author->save();
$updated_at = $author->updated_at;
sleep(1);
$author->touch();
$this->assert_not_null($author->updated_at);
$this->assert_not_equals($updated_at, $author->updated_at);
$this->assert_greater_than($updated_at, $author->updated_at);
} |
Collaborator
Author
|
It's not for nothing I labeled this PR "work in progress" ;) |
Collaborator
Author
|
And I'm not a fan of using It's probably faster to set the date explicitly (untested): $author = new Author();
$updated_at = $author->updated_at = new DateTime('yesterday');
// NB. not sure if updated_at is also updated when it has been modified manually.
$author->save();
$author->touch();
$this->assertGreaterThan($updated_at, $author->updated_at);But like I said, there still is some work to do. |
|
Cool, just wanted to collaborate. I'm also not a fan of using Sleep, I agree with that. Just wanted to piggy back to existing tests. But definitely my vote is also to the Datetime set. Thanks. |
494d55e to
352e1b6
Compare
307db60 to
68cf006
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work to implement suggested feature: #486