Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The CRUD tests in Drupal\views\Tests\ViewStorageTest are mostly using the default views. So we have a dependency on node, comment, etc..
Comment | File | Size | Author |
---|---|---|---|
#24 | vdc-1821524-24.patch | 8.16 KB | damiankloip |
#18 | vdc-1821524-18.patch | 8.24 KB | damiankloip |
#18 | interdiff.txt | 2.34 KB | damiankloip |
#16 | vdc-1821524-16.patch | 7.91 KB | damiankloip |
#16 | interdiff.txt | 1.34 KB | damiankloip |
Comments
Comment #1
dawehnerLet's add a novice tag. (i thought that i created an issue for that yesterday as well).
Comment #2
rlnorthcuttAttached is a patch that does this, and my testing passes... hope this does the job, but please check it out and let me know.
ron
Comment #3
patrickd CreditAttribution: patrickd commentedlooks good but I think we should add a "block" display to the test view and keep the assertion for it
Comment #4
damiankloip CreditAttribution: damiankloip commentedNice work! This generally looks pretty good. Just a few things;
We need a docblock for this , just quickly documenting the property and it's data type.
You can add a block display back if you like, I don't see this as a deal breaker though. It's just checking hte keys of what was loaded, so at this point you could literally add anything in there.
We don't create a new config entity here now, I think we need to change the id (name) before we save, just to keep things how they were before. So we can maybe just switch this out for creating a new view in displayTests.
Comment #5
damiankloip CreditAttribution: damiankloip commentedComment #6
dawehnerWhat about just using 'test_view_storage' instead of $this->viewName, it seems to be a bit easier to understand.
Comment #7
rlnorthcuttI originally started with using 'test_view_storage', but we are also overwriting it in one of the tests. So, we decided that setting the variable would be a clean way to deal with this change. Also, this makes it easier to test a specific view by changing a single line, or to copy the file to do testing on another view entirely.
I'm not tied to either approach. If you think that readability is more important than possibly reusability, then I can easily change it back.
Comment #8
rlnorthcuttOk guys, a few of the changes made from above:
I tried removing the other 3 modules (search, comment, taxonomy), but it continued to give me an error on lines 148 and 151. I don't see that they should be required in this test, but I haven't dug down to see where this may be happening.
Assuming the rest of the patch is ok, should I continue to try and figure out how to decouple these modules on this issue, or should we create a new one for that? My preference is for the later case - I think that this issue is clear, and that removing the other modules makes sense as another issue.
Ron
Comment #9
rlnorthcuttOk - Daniel helped me figure out the issue with the required modules. This section of the test is really for testing the configuration entities - which we don't need here anymore. After removing the module list and the lines of code doing this extra testing, everything else works fine.
I re-rolled the above patch to include these changes, and that should do it!
Comment #10
ACF CreditAttribution: ACF commented#9: views-1821524-9.patch queued for re-testing.
Comment #11
tim.plunkettUpdated for the $testViews approach.
Also, on second thought, the $this->viewName was actually MORE confusing.
Comment #13
tim.plunkett#11: vdc-1821524-11.patch queued for re-testing.
Comment #15
damiankloip CreditAttribution: damiankloip commentedYeah, that change seems fine, dawehner never liked using the property to store the view name anyway :)
Looks like the load tests have also been removed, I would be inclined to keep the load() controller tests in there in some flavour, as we are overriding the load() method on our ViewStorageController.
Comment #16
damiankloip CreditAttribution: damiankloip commentedThis issue somehow got lost from our radar, sorry @rlnorthcutt! Your work is appreciated.
I've re rolled this patch to convert the last test (testCreateDuplicate) to use our new views_test_data view. So then we can also convert this to a unit test (Nice!). Just had to unit enable the system module so we can use the l() for the existing display tests. This also cuts the test time from ~10 seconds to 1 second :)
Comment #17
dawehnerIt's so a better name now!
Just wondering why we can't use entity_load('view', 'test_view_storage_new') instead? I would suggest to not add a helper function to views.module if not needed, because people might conflict with views_get_view() which is what they actually want most of the time.
Comment #18
damiankloip CreditAttribution: damiankloip commentedYeah that is a better name :) and sure, that is a better idea just using entity_load, then we can get rid of that loadView helper, win!
Still loving the fact that these tests run in 1 second!
Comment #19
tim.plunkettThis is great! Thanks rlnorthcutt and damiankloip.
Comment #20
Dries CreditAttribution: Dries commented#18: vdc-1821524-18.patch queued for re-testing.
Comment #21
Dries CreditAttribution: Dries commentedAsked for a re-test. I don't think the patch still applies.
Comment #23
damiankloip CreditAttribution: damiankloip commentedI'll re roll this shortly whilst I'm on the train.
Comment #24
damiankloip CreditAttribution: damiankloip commentedYeah, we had a few changes to that file in the last few commits. This should be good now.
Comment #25
tim.plunkettYep, just a patch-context conflict, nothing actually changed.
Comment #26
webchickCommitted and pushed to 8.x. Thanks!