Follow-up to #2525432: Separate text fields per verbose extra field
Problem/Motivation
Creating sensors for nodes and files needs a better test coverage with every field and check if the output is correct.
Proposed resolution
Add test for all available fields of node and file.
Comments
Comment #1
giancarlosotelo commentedAdded tests for every field for both entity types.
Comment #2
berdirNice.
We should assert some of the values that we are expecting there.
Same here.
Comment #3
giancarlosotelo commentedAdded some values to assert.
Comment #4
LKS90 commentedTake a look at the verbose output for the pages you test, there is no verbose output for the node sensor, but the test passes anyway. All the fields you assert aren't actually displayed, they are only listed as a setting in the
Settingsdetail inset. I attached a screenshot of the verbose table which is empty.Comment #5
giancarlosotelo commentedYeah, I didn't realize that, I added a node and also changed the assert type to assert the verbose output not the settings.
Comment #6
giancarlosotelo commentedI also added more asserts to the output.
Comment #7
LKS90 commentedYou are using the node for the file sensor? I'd expect you create a file, create the sensor and check the sensor output to match what the file has. At the moment the file sensor is just a copy of the node sensor with rather useless output (the output of a node, after all :P). Take a look at this test to see how to create a file in a test and do stuff with it.
Comment #8
giancarlosotelo commentedNow a file is created and the verbose output of the file entity is checked.
Comment #9
giancarlosotelo commentedComment #13
juanse254 commentedi would recommend merging it into one single declaration, ex: array( 'key'=> 'value', 'key2'=> 'value'). Just the way it was before. will have a look about failing tests.
Comment #14
giancarlosotelo commentedCould be but a foreach is needed with the array.
so better to have the same format.
And about the test, are failing because of some recent changes in the Search API module, has nothing todo with this patch ;)
Comment #15
LKS90 commentedThe fails are because of a dependency on SearchAPI which was broken by a core update. The issue to fix SearchAPI: #2545464: Fix database backend after recent core change.
Comment #16
mbovan commentedI see this is from before, but we don't need to assert link before clicking to it.
Looks a bit strange, but okay. :)
What about adding a helper method (e.g.
addFields())?Can we use
$this->assertTrue($file->id())?Maybe to remove
drupalGet()and add the path todrupalPostForm().Same as (1).
Comment #17
giancarlosotelo commented1. Done
2. Changed a bit.
3. Added a method.
4. Done.
5. Done.
6. Done
And also made the recommendation #13.
Comment #18
LKS90 commentedRevert unnecessary change
The path is not necessary, we already are on that page. Replace the path with NULL like it was before.
Missing documentation for both params, and while you are at it, the second parameter could really use a more helpful variable name (it's called $edit most of the time, IIRC)
After that it seems good to go. Adding fields isn't really that elegant, but it works for now.
Comment #19
giancarlosotelo commented1. Reverted.
2. Not possible, its necessary.
3. Added.
Comment #20
LKS90 commentedNice! Looks good now.
Comment #21
miro_dietikerHm, tests failed because testbot lost dependencies for monitoring again...
Comment #22
berdirYeah, but we also still have search api and captcha failing even with those. This is postponed on having passing tests again.
Comment #23
miro_dietikerI have requested a new alpha release from search api. IMHO it would fix the search_api issue: #2552075: New alpha release
Dunno about the others and if we have issues RTBC / committed?
Comment #24
miro_dietikerI don't like this signature with eating a half prepared $edit and doing the PostForm on its own to NULL.
I would prefer to let it populate $edit with all fields. Name it addAllVerboseFields.
Comment #25
giancarlosotelo commentedOk now the function returns the $edit array with every field and then is saved.
Comment #26
miro_dietikerOh sorry, i just realised that addAllVerboseFields still does and always did some posts on its own to add more items...
I think we should decouple it completely from the other $edit thingies and let it post again on its own.
How about providing some PostFormMultiple(t('Add another field'), 5) that then loop on the button 5 times.
Then adding the values to the $edit is a matter of the caller, followed by the regular Post.
Also, mind that you are using an API to fetch data about base fields. That's indirection. We know what base fields are existing. We can name them in code. You also name them when asserting.
Comment #27
giancarlosotelo commentedWell, I decouple it, I added the postFormMultiple function and I also avoid the indirection adding the known fields manually.
I think now is less cryptic :)
Comment #28
miro_dietikerLooks pretty good now!
Comment #30
miro_dietikerMonitoringUITest is passing. Rest is unrelated.
Comment #40
giancarlosotelo commented