-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes wrong assertions in the controller test class #77
Conversation
Signed-off-by: Joey Smith <jsmith@webinertia.net> Signed-off-by: Joey Smith <jsmith@webinertia.net>
@@ -39,7 +39,7 @@ public function testIndexActionCanBeAccessed(): void | |||
public function testIndexActionViewModelTemplateRenderedWithinLayout(): void | |||
{ | |||
$this->dispatch('/', 'GET'); | |||
$this->assertQuery('.container .jumbotron'); | |||
$this->assertQuery('.col .card'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the test is named "rendered within layout" then this should be tested and this can be done independent from the frontend framework. So my suggestion is to check the title
element which is a part of the layout:
<?= $this->headTitle('Laminas MVC Skeleton')->setSeparator(' - ')->setAutoEscape(false) ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually,
What the test is doing (and I corrected in my last commit).
It is checking that .container (which is a class from the layout) and .card which is a class rendered in the /index/index.phtml file are both rendered.
Your suggested change will only test that the layout is rendered. This test is intended to test that both the layout.phtml file is rendered and that the actions view file is rendered within it. Which is why the assertQuery() needs to be passed a class from each file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the original comment as well to clarify :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is intended to test that both the layout.phtml file is rendered and that the actions view file is rendered within it.
And this can be done independently of the frontend framework:
html h1
html h2
body h1
- …
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely. Its now:
body h1
Signed-off-by: Joey Smith <jsmith@webinertia.net> Signed-off-by: Joey Smith <jsmith@webinertia.net>
@@ -39,7 +39,7 @@ public function testIndexActionCanBeAccessed(): void | |||
public function testIndexActionViewModelTemplateRenderedWithinLayout(): void | |||
{ | |||
$this->dispatch('/', 'GET'); | |||
$this->assertQuery('.container .card'); | |||
$this->assertQuery('body h1'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just commenting here so that you know it has been resolved.
Description
class from layout.phtml
.container
class from index.phtml
.card
For this test to work as intended it must be passed a class from BOTH files.
Please note the entire test methods name is relevant.
"Index Action View Model Template Rendered Within Layout"
fix:
current
changed to: