Currently, in ViewsTest::testViewsAdmin() we add a relationship, but then don't use any of its fields. Which wouldn't work anyways, probably, since I think the test entities we create don't have any value for the "User ID" field.
So, we should, in this test method, add user IDs to the test entities (no need to re-index), then add some field from the relationship – e.g., the user roles – and see if those are displayed correctly, too.
Also, it might be interesting to do the same with an indexed field of a related entity – i.e., index the entity:entity_test/user_id:roles field and see if that gets displayed (and linked?) correctly, too. (Again, re-indexing is not necessary, since the data is loaded from entity storage anyways, at least with the DB backend we use for testing.)
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 2657406-10--views_relationship_fields.patch | 13.64 KB | drunken monkey |
Comments
Comment #2
mikemiles86Comment #3
mikemiles86Comment #4
drunken monkeyFinally got round to doing this, and it turned into a bit of a nightmare, but the attached should work fine and pass (at least when combined with #2700323-4: Views relationships not working – should probably merge these issues).
Comment #5
drunken monkeyComment #8
drunken monkeyCombined with #2700323: Views relationships not working.
Comment #9
borisson_I'm glad that the tests agree with these changes and I like the additional coverage. It would be uncharacteristic to not find anything that could use slight improvements. Overall I think this patch is in great shape though, since I don't see any actual code that can be improved. I'm personally not a fan of the
call_user_func_arraycall in the code, as that part doesn't read very well. However this is just moved around so not really something we should discuss/resolve in this particular issue.I think this should be
string|NULL, however I see both used in core everywhere.This feels like a weird statement "The probably easiest way..."
Can we replace that with: "We use the $options array from the parent, but exclude the items that come directly from the parent." or something similar?
Since we're touching this code anyway, let's add a
@todowith a link to a d.o issue or remove the todo-part of the comment.I can see this is something that's also described as "the render API renderer" in other places but this is the first time I've seen that. We can keep this though.
That's a really awesome comment! @drunken monkey++
I think this can benefit from a better description, how about: "To test the entity permissions, attach users with different permission sets to the entities"
Should we resolve this in this issue? We probably should at least figure out if we're doing something wrong and adjust the comment accordingly. At the very least we can open a new issue for that.
See my other comment about this.
Comment #10
drunken monkeyNo, it shouldn't.
You see both in Core because Core's relation to coding standards is that of a deer and Asimov's Laws – it might follow them most of the time, but more by accident than by concious acknowledgement.
That's just there because I spent over an hour tearing my hair out over why this isn't working, before figuring it out.
But nice that it at least lead to a good comment.
That's not what's happening, it's just about setting any users on the test entities. I just use those because they are already there, not because of their respective permissions. (And because using different users, with different names and roles, will probably make the test a bit less prone to false passes.)
A different suggestion for the comment text instead?
I don't know, I have no idea what's going wrong there. You are free to try and debug it, though – I'd happily just ignore it, though. (Or create a follow-up issue, if you insist.)
Also, I remember the exact same thing happening when initially writing those Views field handler tests, there was also one field handler whose form wasn't (automatically) shown. But it seems that was resolved before I posted the first patch about it – I've got no idea how anymore, though.
Comment #12
drunken monkeyCommitted.
Thanks, everyone!
Comment #13
drunken monkeyFollow-up: #2711627: Fix strange workaround in Views field handler admin UI tests.