Repository navigation
[PHPUnit60] Never parse PHPUnit and Symfony base test case methods in AssertCallAnalyzer - #833
Merged
Merged
Conversation
… AssertCallAnalyzer
…on calls into PHPUnit classes
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.
Part of rectorphp/rector#9965.
AssertCallAnalyzerfollows calls likeparent::setUp()or$this->helper()throughAstResolver, which parses and decorates the file that declares the method. Only a directparent::call toTestCasewas skipped so far. So the file was still parsed in these cases:KernelTestCase/WebTestCaseand callsparent::setUp()setUp(), so the call lands inTestCaseor Symfony$this->markTestSkipped()and similar, declared inAssertChange
Before resolving the method, look up its declaring class. When it is one of
PHPUnitClassName::FRAMEWORK_TEST_CASES(PHPUnitTestCase,Assert, SymfonyKernelTestCase,WebTestCase,TypeTestCase), the method is not parsed. Their methods do not count as test assertions, andassert*()calls are already matched by name before this step.This replaces the direct-parent
TestCasecheck.Tests
New
KernelTestCase/WebTestCasestubs. TheKernelTestCase::setUp()stub asserts on purpose: the new fixture fails if the file is parsed, and passes with this change.Bench
New
bench/does_not_perform_assertion_framework_test_case_bench.php: 300 test classes extending a base class withoutsetUp(), each withsetUp()callingparent::setUp()(lands in PHPUnit'sTestCase) and 6 tests calling$this->markTestSkipped()(declared inAssert). CPU, 3 runs, local:mainOn
mainmost of the time goes to parsing and decorating PHPUnit'sTestCase.phpandAssert.php. The existing benches extendTestCasedirectly, so they stay the same.