Closed (fixed)
Project:
Gender field
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
13 Apr 2018 at 17:21 UTC
Updated:
15 May 2018 at 15:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
alexdmccabeComment #3
alexdmccabeComment #4
alexdmccabeComment #5
alexdmccabeNot actually done yet, just got the first test written and I wanted to see what the testbot thinks of it.
Comment #7
alexdmccabeTrying again...
Comment #8
alexdmccabeCool, it passed, but I'm setting this back to Needs Work since it's not actually done yet.
Comment #9
alexdmccabeUploading again for safekeeping and to see what testbot thinks again.
Comment #10
alexdmccabeOkay, I think it's done! Testing...
Comment #11
agentrickardSome review notes:
* I think it's now best practice to create test Traits rather than base test classes. That lets some setup methods be used by Functional/Kernel/Unit tests. That would move GenderTestBase to Traits/GenderTestTrait.
* Might be useful to move $user to $this->user in case we need to run any tests on that element. Might also be good to add a second user and save some gender data about that user.
* Why does the test work on a Node and not a User account? I would think User testing (including display) would be more relevant. From a functional perspective, however, this is irrelevant to the field's behavior.
* In testSelectListWidget() do we need to check the value of the saved option, and not just that the options exist? I _think_ this is covered in assertWidgetOptions.
* We should add a negative assertion -- e.g. that the value 'notarealvalue' does not appear in the options list.
* I think we need a test for field display.
Comment #12
alexdmccabeHm... I tried to get this going, but most of the code in the base class is in the
setUpmethod. Traits can't extend classes, so if I made a trait for that code, how is the trait supposed to call things likeBrowserTestBase::createUser()orBrowserTestBase::drupalLogin()?I haven't really worked with traits much or really at all even, so I'm open to new ideas, here. I found a few examples of traits in core tests, but I didn't see any that implement the
setUpmethod. Other than the set up work, it's basically just a couple of properties.That's easy, done.
Mostly just because I was testing with a node. You're right though, it shouldn't really matter.
Yes, this is covered. After the form is saved it goes back to the edit form and checks that the three original options and the new fourth option are all selected.
Honestly, I thought I had - I must have deleted it for some reason. Added it back.
Comment #13
alexdmccabeOh, I missed one.
That's what
GenderFormatterTestdoes, it checks that the expected labels display on the node.Comment #14
agentrickardNicely done. And I think you're right about the Traits here. THey could import some BrowserTestBase methods, but there i little point.
If you find yourself writing methods other than setup() in the test base, then I would add a Trait.
Comment #16
alexdmccabeWill do. Thanks for all the help!