Mark test traits as @internal

Created on 23 March 2019, about 5 years ago
Updated 29 January 2023, over 1 year ago

TaxonomyTestTrait has two methods that are directly related to generating entities. They are inconsistent from the perspective of "I want to create an entity, potentially with some values".

function createVocabulary() {
function createTerm(Vocabulary $vocabulary, $values = []) {

The question came up on ✨ Allow raw vid to be sorted in views Fixed about whether I was breaking BC by adding a $values to createVocabulary(). At the moment it is true that someone in a project could extend TaxonomyTestTrait, they could override createVocabulary() with createVocabulary($some_string); and thus if I added $values to the core method I might break their tests.

First, I want to suggest that ENTITYTestTraits should be marked @internal (see below). But if we want to improve re-usability of such traits, and avoid BC issues, we should define some standards right now. So i"m just throwing this out there to see what sticks...

  1. All core entities should have a consistent `ENTITYTestTrait` trait.
  2. Each test trait should have a consistent `createENTITY()` method (and perhaps other CRUD?)
  3. A general $values array should always be the FIRST argument to `createENTITY($value)` method.
  4. A test should ensure these interfaces are consistent (or perhaps the existence of tests using these interfaces is enough)

Wait, what? They're just test helpers, and test classes/methods are not in scope for BC... (I'm assuming, but hey we don't actually *test* them.)

So maybe these traits should be marked as @internal? Since they are explicitly only for testing - only for re-usability of code in testing - should they be excluded from the API? Let's say I subclassed a core test and started using it's methods, does that mean the core tests need to maintain their own internal method interfaces?

πŸ“Œ Task
Status

Needs work

Version

10.1 ✨

Component
TaxonomyΒ  β†’

Last updated about 19 hours ago

  • Maintained by
  • πŸ‡ΊπŸ‡ΈUnited States @xjm
  • πŸ‡¬πŸ‡§United Kingdom @catch
Created by

πŸ‡¦πŸ‡ΊAustralia sime Canberra

Live updates comments and jobs are added and updated live.
  • Needs release manager review

    It is used to alert the release manager core committer(s) that an issue significantly affects the overall technical debt or release timeline of Drupal, and their signoff is needed. See the governance policy draft for more information.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024