Prevent autoloading of tests/php folder#1940
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1940 +/- ##
=========================================
Coverage 95.04% 95.04%
Complexity 1556 1556
=========================================
Files 48 48
Lines 3672 3672
=========================================
Hits 3490 3490
Misses 182 182Continue to review full report at Codecov.
|
Member
|
Indeed, the things you learn everyday — looks good to me! |
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.
Issue
In the unit tests, we sometimes require other PHP files, e.g. in test-timber-term.php:
timber/tests/test-timber-term.php
Line 172 in 7385f93
When using
classmap, Composer autoloads these classes wheneverclass_exists()is called, not only when we require them:timber/composer.json
Lines 51 to 54 in 7385f93
In #1931, I wrote a test where I needed a particular class to exist only for a particular test. For the other tests, the class shouldn’t exist.
That test failed in Travis, because I didn’t use
composer dump-autoloadlocally before running the tests and so in Travis, the class was found and triggered the error, while locally I didn’t see that error.Solution
I looked for an option to ignore certain classes from autoloading and found that we can use
exclude-from-classmapto prevent certain files to be autoloaded.This pull requests sets the
tests/phpfolder to be excluded from the Composer classmaps, so that all classes in that folder always have to required manually by unit tests.Impact
By not autoloading the
tests/phpfolder, we should have better expectations of what should happen in tests.Usage Changes
None?
Considerations
Can you imagine how much I learn every day about various coding stuff when working on Timber 😎?
Testing
Tested. There should be no changes for the current tests.