Problem/Motivation
follow up to #2313917: Core version key in module's .info.yml doesn't respect core semantic versioning
in that issue we made sure the parse threw the expected exception in even it was called twice to make sure \Drupal\Core\Extension\InfoParserDynamic::isConstraintSatisfiedByPreviousVersion()
wasn't incorrectly caching result(as a previous version of the patch ones.
This involved surrounding the first call to parse()
in a try
and checking the expected exception manually. then calling the parse()
the second time from within the catch
.
For this to work
// Set the expected exception for the 2nd call to parse().
$this->expectException('\Drupal\Core\Extension\InfoParserException');
$this->expectExceptionMessage('Missing required keys (type) in vfs://modules/fixtures/missing_key-duplicate.info.txt');
Needs to be before the try
block for the first call to parse
This was done correctly for all test methods except testInfoParserMissingKey()
(my bad 😅)
Proposed resolution
Fix testInfoParserMissingKey()
Remaining tasks
patch, review
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
None
Comment | File | Size | Author |
---|---|---|---|
#9 | 3078781-9.patch | 1.19 KB | tedbow |
#4 | 3078781-4.patch | 1.27 KB | tedbow |
#4 | interdiff-2-4.txt | 817 bytes | tedbow |
#2 | 3078781-2.patch | 1.29 KB | tedbow |
Comments
Comment #2
tedbowComment #3
Wim LeersLet's use
FQCN::class
if we're changing this anyway.How can an exception be thrown for a file that is not being parsed? :O
Comment #4
tedbow@Wim Leers thanks for review!
The expected exception is for the 2nd call to parse. This has to be set before the first call or if the first call has no exception the test will pass.
This works because
\PHPUnit\Framework\TestCase::expectException()
and\PHPUnit\Framework\TestCase::expectExceptionMessage()
are not for the next call but are checked for any uncaught exception.Comment #5
Wim LeersD'oh, of course!
Comment #6
alexpottCommitted 42962f7 and pushed to 8.8.x. Thanks!
Comment #8
alexpottThis no longer applies to 8.7.x since #3079805: expectedException() usage in two pre-8.7.7 commits has broken PHP 5 testing for 8.7.x - so closing as fixed because at least this is in 8.8.x. If someone feels it is important that this is in 8.7.x then we can backport but I think we can expend effort elsewhere.
Comment #9
tedbow@alexpott thanks for committing to 8.8.x.
Here is the 8.7.x patch.
Comment #12
quietone CreditAttribution: quietone as a volunteer commentedClosing now as 8.7 is not supported.