Problem/Motivation
The test entity_reference_test module, found in the core system module is where one would typically add custom Entity Reference Selection plugins used in testing. The test views_test_entity_reference module, found in the core views module is needed to implement the views_data_alter hook which enables the EntityReference views filter plugin for EntityReference fields.
The issue is both of these modules cannot be enabled in the same test class as they both install a view with the same machine name test_entity_reference. As a result I am unable to add a custom EntityReferenceSelection plugin that I can use when testing the EntityReference filter.
Issue #3542714: Unable to get/set form_state values in SelectionPluginBase::validateConfigurationForm when called from EntityReference::validateExtraOptionsForm is an example of where this type of testing is needed.
Steps to reproduce
- Set up a fresh Drupal 11 dev site
- Edit the existing
\Drupal\Tests\views_ui\Functional\FilterEntityReferenceWebTestclass and add theentity_reference_testmodule to the existing$modulesproperty - Run any test within the
FilterEntityReferenceWebTestclass - The test fails with the following error
Drupal\Core\Config\PreExistingConfigException: Configuration objects (views.view.test_entity_reference) provided by views_test_entity_reference already exist in active configuration
Proposed resolution
- Rename the existing test_entity_reference view in the views_test_entity_reference test module to test_entity_reference_view
- Update existing tests that reference this view to the new machine name
Remaining tasks
- MR review
User interface changes
None
Introduced terminology
None
API changes
None
Data model changes
None
Release notes snippet
None
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 3543036_error.png | 109.47 KB | solimanharkas |
Issue fork drupal-3543036
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
tame4tex commentedPushed fix. Ready for review!
Comment #4
nicxvan commentedSeems pretty straightforward, but should the view machine name start with the whole test module name to prevent future conflicts?
Comment #7
solimanharkas commentedI can confirm this issue exists.
Steps to reproduce:
Please see the screenshot
#2 Fix the Problem. Following the suggestion in #4, I created a new merge request that renames the view to use the full test module name as a prefix.
The view is now named views_test_entity_reference_view instead of test_entity_reference_view for better namespace isolation.
Comment #8
smustgrave commented@solimanharkas there was already an MR though doing something very similar why a new one?
Comment #9
solimanharkas commented@smustgrave I wasn’t sure which ID / file name would be better, so I didn’t want to overwrite the existing solution in case it’s already correct and sufficient.
Comment #10
tame4tex commented@solimanharkas while I appreciate the code review, given it has been less than 24 hours since I posted the MR and I hadn't yet had a chance to respond to @nicxvan comments, I am wondering if adding MR code comments with code suggestions or simply adding your suggested machine name in a comment might have been less confusing than adding another MR. If I hadn't replied in a few days, than I think jumping in and changing the existing MR would have also been ok.
@nicxvan thanks for the review and good point!
I have modified the machine name to include the module name but also tried to make it descriptive of what it is. I also changed the label and added a description to provide more information. I feel like this could help when writing new tests and seeing if there is an existing view that can be used instead of creating another one. Back to NR.
@solimanharkas given I have used a different machine name and made additional changes, I have hidden your MR to prevent confusion.
Comment #12
nicxvan commented@solimanharkas I just wanted to make sure it is clear we appreciate your help! Please don't be discouraged from contributing by the feedback here!
But to highlight there are a couple of general Drupal etiquette items as I see for core.
Generally for any issue it's customary to give the original author a couple of days to respond to feedback, especially if they have contributed recently. As mentioned if you still want to help in that situation opening MR suggestions can be a good way to do that. An important note, that creating suggestions based on another user's feedback may not always reach the bar of getting credit on a core issue.
Second, creating a new MR is usually reserved for a completely new approach or if an MR gets too far out of date so rebasing is not possible.
To summarize the preference is to give the contributor some time to reply and provide MR suggestions if you are trying to help out.
If it goes stale you can leave a comment mentioning you are going to pick it up, then you can push up the changes directly or create a new MR depending on what makes sense for the change your making.
Comment #13
nicxvan commentedI think this is good now!
Less likely to conflict and much more semantic for the name.
Comment #14
smustgrave commentedThanks everyone!
Comment #15
smustgrave commentedSaving credit
Comment #16
tame4tex commentedThanks @nicxvan & @smustgrave for the quick response!
@solimanharkas I want to echo @nicxvan’s comment, I definitely don’t want to discourage you from helping. We need all the help we can get! If my earlier comment came across otherwise, apologies. I really appreciate your review.
Comment #17
solimanharkas commentedThank you all a lot for your kind replies and respect . I really appreciate it.
And please @tame4tex , you don’t need to apologize at all. I truly value the feedback and support.
Honestly, the only reason I opened a new MR was because I wasn’t sure if adding commits to the existing one might break something that already works. I just wanted to be careful.
I don’t have much experience with Drupal core issues yet, but your comments really helped me understand the process better. I’ll know how to handle it next time.
Thanks again, it really means a lot.
Comment #18
quietone commentedTriaging the RTBC queue.
This is straightforwards as was said in #4. I applied the diff and searched for 'test_entity_reference' and confirmed that the correct instances are changed. I didn't find any that should be changed that are not. Well done.
I checked credit. Everything is in order here.
And thanks to @nicxvan for helping with how we work in the Drupal core issue queue.
Comment #19
astonvictor commented+1 RTBC
Comment #20
catchCommitted/pushed to 11.x and cherry-picked to 11.3.x and 11.2.x, thanks!
Comment #26
herved commentedIt seems this is causing failures, https://git.drupalcode.org/issue/drupal-3559030/-/jobs/7370601
Comment #28
catchReverted, let's try again.