Problem/Motivation
#2866894: Component tests should not use Drupal\Tests\UnitTestCase but PHPUnit\Framework\TestCase Made use of UnitTestCase outside of Core test invalid but didn't explicitly move UnitTestCase into the Core namespace where it effectively lives.
Proposed resolution
While its completely OK for contrib to use UnitTestCase we can help Core along by making its location more explicit and move it into the core namespace. We might even be able to get rid of the listener because the Core namespace will already be invalid.
Provide deprecated shell testcase for contrib BC.
Remaining tasks
Agreement
Decide on where removal happens. 9?
Patch
Review approach
User interface changes
N/A
API changes
Deprecates \Drupal\Tests\UnitTestCase
Data model changes
N/A
Comment | File | Size | Author |
---|---|---|---|
#17 | move_unittestcase_to-2913630-16.patch | 316.01 KB | neclimdul |
Comments
Comment #2
neclimdulComment #3
neclimdulbah, my comment got eaten. Patch for review and discussion.
Comment #4
Mile23+1 on normalizing test base classes to where they really belong. We should have a similar issue for BrowserTestBase.
We should do a deprecation process, though, so that we leave the deprecated stub and add a new class in one issue and then do replacements in another.
Comment #5
neclimdulRight on.
There where a lot of changes in this, more then I expected, so I left BrowserCase for its own issue. It could be rolled in here it will just make rerolls a bit more unweidly until its committed.
Definitely on the stub. Its actually in the patch and it is marked @deprecated. Missing though is the required message pending the remaining task from IS of deciding when it gets removed so that definitely needs to work.
Comment #6
dawehner@neclimdul
I think @Mile23 is talking about
@trigger_error
, see https://www.drupal.org/core/deprecationComment #7
neclimdulMade assumptions we'll deprecate in 8.5.x and remove in 9 and put trigger and deprecated message in. Thoughts?
Comment #8
dawehnerDo you mind creating a change notice and link it inside the code?
Comment #9
borisson_Comment #10
dawehnerThe most recent discussion in #2607260: [meta] Core deprecation message introduction, contrib testing etc. seems to suggest that we should introduce this
@trigger_error
later, or at least add it to the exclusion list.Comment #11
neclimdulNot sure I understand. 1) is it deprecated or not. 2) are we not targeting dev with this?
Comment #13
borisson_#11, it is deprecated but we should add it to the exclusion list. Setting to needs work to do that.
Comment #14
neclimdulI still don't get the hold up. 1) that issue is open/active not accepted. 2) we seem to meet the requirements.
If core is not using deprecated code, it can be removed from that skipped deprecation list as long as the new API is available in a tagged release (at least alpha, stable if it's a widely used API) - this can be checked by consulting the change record for the deprecation.
Core note using code: we're removing usage ✔
Available in tagged release: wonky wording but we're targeting MINOR release not PATCH so there should be no problem. ✔
Comment #15
Mile23After #2949363: Impossible to make trigger_error in some files without test fails we don't need to add the deprecation error to the exclusion list. We might need to update the work from #2973127: Exclude *TestBase.php, *Trait.php and *Interface.php files from test discovery reflection if it's committed first, or update that issue if this one is committed first, so it also excludes *TestCase.php.
Needs an update to 8.6.0.
Also some semi-related stuff, based on the IS here: #2943856: [meta] Reorganize Components so they are testable in isolation and #2943842: Allow component namespaces to be autoloaded independently
Comment #16
neclimdulRebuilt this from scratch so no interdiff. Was easier to start from scratch and use PhpStorms refactor tool to avoid all the merge use conflicts and to get any new tests.
re #15
#2973127: Exclude *TestBase.php, *Trait.php and *Interface.php files from test discovery reflection 1) So many questions... As it doesn't pertain to this issue I'll skip them and follow up in other issues. Don't see anything we need to do for this issue either.
Trigger is 8.6.0 now.
The component issues do seem tangentially related though since we take pains to block components from using this test base the connection is limited. :) Thanks for the heads up though!
Comment #17
neclimdulwoops, rusty at this. Here's the patch.
Comment #18
Mile23Those issues allow you to say @trigger_error() in a file that might be read during test discovery.
Comment #20
borisson_We still need that change record, this patch doesn't apply anymore either.
Comment #21
neclimdulSure