-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PhpUnit] Mock clock on @group time-sensitive annotations #16194
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
Conversation
@@ -43,6 +43,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")) { | |||
passthru("$COMPOSER remove --no-update symfony/yaml"); | |||
passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=2.8@dev\""); | |||
passthru("$COMPOSER install --prefer-source --no-progress --ansi"); | |||
symlink(realpath('../../src/Symfony/Bridge/PhpUnit/ClockMockedTestCase.php'), './vendor/symfony/phpunit-bridge/ClockMockedTestCase.php'); |
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 line should be removed when merging
Thinking a bit more about this, I'm going to replace the test case by an annotation. |
e66b70a
to
a997fbc
Compare
…ekas) This PR was merged into the 2.8 branch. Discussion ---------- [PhpUnit] Auto-register SymfonyTestsListener | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This allows removing the copy/pasted `<listeners>` tags in our phpunit.xml.dist files and opens for future enhancements (like #16194) Commits ------- 9e2bb00 [PhpUnit] Auto-register SymfonyTestsListener
a997fbc
to
ecb243e
Compare
ecb243e
to
0ee16cb
Compare
Updated to use |
|
||
/** | ||
* @group clockMock |
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.
Not a big fan of the group name. Also, wouldn't it be better for it to be an annotation instead of a group?
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.
i'm open for suggestions :) using a group annotation makes the implementation a lot easier by reusing a bunch of existing caching logic. It also allows filtering these specific tests when running the test suite...
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.
(clock, time)Related, requiresFixedTime, timeSensitive ?
The mocking of a clock is just a detail, it's more about what it is fixing.
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.
clockMockable?
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.
I think I don't like having mock in there.
I do understand that using a group is much easier (I recently tried to add an annotation for BF :)), but that does not make it better (and not sure it makes sense to filter those tests).
Time sensitive sounds much better.
72ed068
to
3e81e43
Compare
The phpunit-bridge dev requirement in all these packages needs to be upgraded as it relies on the new feature |
3e81e43
to
34a0846
Compare
Updated to use |
👍 |
Thank you @nicolas-grekas. |
…ons (nicolas-grekas) This PR was merged into the 2.8 branch. Discussion ---------- [PhpUnit] Mock clock on @group time-sensitive annotations | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Instead of spreading the same clock mock code everywhere, let's create a test case that helps mocking the time related functions. Commits ------- 34a0846 [PhpUnit] Mock clock on @group time-sensitive annotations
Instead of spreading the same clock mock code everywhere, let's create a test case that helps mocking the time related functions.