Closed (fixed)
Project:
Modal
Version:
4.1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
22 Aug 2022 at 13:31 UTC
Updated:
20 Sep 2022 at 18:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
lucasscComment #3
lucasscHi!
I started to write something. I'm still working on this but any tips/contributions are welcome as it's my first unit test.
I got help from @diegors and @gquisini, if you can please give credits.
Comment #4
lucasscComment #5
gquisini commentedWhat we did:
Comment #6
gquisini commentedHello, so...
I created some new tests to:
- loadModalsToShow()
- getModalToShowByPage()
- prepareClass()
Comment #7
lucasscHi!
We couldn't set up a modal by parameters so we don't write tests for this now. Here's what we did:
/?modal=welcomeas suggested in the field's description.See modal-by-parameter-settings.png attached.
Maybe a bug here?
I checkout the Modal Settings documentation and didn't find any references to "parameter". Maybe can we create an issue to add this later?
With that, the methods left to test/discuss if it's worth testing are:
Comment #8
renatog commentedAwesome job! Thanks a lot for your contribution on this
Actually I'm thinking about to deprecate this option to "Modal by parameter". We can think in a way to remove this functionality in the future
I kept this only because I don't know if we have sites in production using this. But I think we don't need to create tests for this functionality
Comment #9
lucasscOk, @RenatoG!
Thanks for the quick response!
submitting new patch:
Comment #10
lucasscChanging status to "needs review" because we're starting to feel stuck.
This is our first unit test, so we may have made some mistakes. Feel free to suggest modifications and improvements, we'll be willing to fix them out.
Kindly review.
Comment #11
gquisini commentedThere is nothing new in this patch, I just put the tests in order.
Comment #12
paulocsFound some CS erros:
Comment #13
lucasscFixed! Thanks.
Comment #14
sophiavs commentedI'll do the review
Comment #15
sophiavs commentedWhile reviewing i didn't found any coding standard error and the tests seems to be fine.
I think we could add a new test for the loadModalsToShow(), testing multiple modals with different attributes to check the quantity of modals to show.
ex: 4 modals with null type, 2 modals with page type, 1 modal unpublished...
And maybe the getModalToShowByPage() in a modal with multiple pages to test
ex: front and /node/1 added on the same modal
Comment #16
lucasscHi!
Thanks for the review, @sophiavs! I'll work on this.
Comment #17
lucasscAdded method to test loadModalsToShow() with multiple modals having different attributes.
Comment #18
lucasscI found out a bug in testGetModalsToShowWithoutModals(). The mock was not made correctly, so the modals used to build the object came actually from setUp() - which had created 1 modal. As it was not defined in setUp() if the modal was published, getModalsToShow() returned FALSE anyway.
Fixed!
I took the opportunity to add a forgotten
$this->in the previous method.After I finish @sophiavs suggestions, I'll debug all tests and double check if they're really working as they should.
Comment #19
lucasscAdded method to test getModalToShowByPage() with multiple pages.
Comment #20
lucasscIn this patch I:
- replaced
assertTruewithassertEqualswhere it's more suitable;- broke lines to be no longer than 80 characters, whenever possible, to follow the coding standards.
Comment #21
lucasscAddressed #18:
I debugged the real behavior of
getModalToShowByPagemethod setting the modal with multiple pages from site. With this, I verified thattestShowByPageWithMultiplePageswas not correct. It's a void function in this case, we have to assert this.I also checked that
testIfUserHasPermissionOnModalis returning FALSE beforegetRolesis called. Futhermore it's duplicated withtestIfUserHasPermissionOnModalWithPermissions. Must be deleted.I'm working on it.
Comment #22
lucasscPatch addressed #21.
Comment #23
lucasscComment #24
lucasscComment #25
sophiavs commentedI'll do the review :)
Comment #26
lucassc@sophiavs warned me about another bug, since
testShowByPageSetToNodeis checking if the modal is displayed for/node/1, its current path must also benode/1.Thank you, @sophiavs! Attaching new patch to fix this.
Comment #27
sophiavs commentedEverything seems to be right know, passing to RTBC :)
Comment #29
paulocsThanks!
Comment #30
paulocs