Skip to content
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

[4.0] Fixing Travis #16796

Merged
merged 4 commits into from
Jun 21, 2017
Merged

[4.0] Fixing Travis #16796

merged 4 commits into from
Jun 21, 2017

Conversation

Bakual
Copy link
Contributor

@Bakual Bakual commented Jun 21, 2017

Fixing Travis error introduced by #16779

Some tests did also have "expected" and "actual" inverted. I've switched those.

I don't understand why JToolbarButtonConfirmTest::testFetchButton has the id id="toolbar-", looks like it is missing a part there. But Travis should (hopefully) pass again.

@Bakual Bakual changed the title Fixing Travis [4.0] Fixing Travis Jun 21, 2017
@@ -92,14 +92,14 @@ protected function tearDown()
*/
public function testFetchButton()
{
$html = "<button onclick=\"if (document.adminForm.boxchecked.value == 0) { Joomla.renderMessages({'error': [Joomla.JText._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST')]}) } else { if (confirm('Confirm action?')) { Joomla.submitbutton('article.save'); } }\" class=\"btn btn-sm btn-outline-danger\">\n"
$html = "<button id=\"toolbar-\" onclick=\"if (document.adminForm.boxchecked.value == 0) { Joomla.renderMessages({'error': [Joomla.JText._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST')]}) } else { if (confirm('Confirm action?')) { Joomla.submitbutton('article.save'); } }\" class=\"btn btn-sm btn-outline-danger\">\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ID seems very sad. Is that some weird unit test setup - or is there something weird with the code?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetch button appends normally the given name, as there is none in the setup we just append ''; ...

On a site note can we please stop testing exact HTML output our unit tests? This is breaking every simple intended change.. Let's test functionality :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well when a method has no job but to generate HTML, what else is there to test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it shows now an error in the original PR, there is a doubled space generated 😄

Copy link
Member

@yvesh yvesh Jun 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well when a method has no job but to generate HTML, what else is there to test?

@mbabker To be blunt: Nothing, as it's not functionality.. We test string concat :) If it has functionality / logic we could test the parts that are changed with it..

If we really want to go this way we can use DOMDocument in PHPUnit, to just test if attributes are right..

Sample:

$document = new \DOMDocument($actual);
$element = $document->getElementById('toolbar-');
$this->assertNotNull..
$this->assertRegexp('/btn-outline-danger/', $element->getAttribute('class')); // Can't use assertContains .. in PHPUnit 4.8....

What do you think?

This would make the tests way more rubust and you see where the change actually happend if it was by error..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a unit test perspective, I don't think we just blow off testing methods whose functionality is to generate an HTML string (also remember that string can be dependent on parameters, so validating parameters get applied correctly can be helpful).

We can do better. We need to do better. I said we need to do better almost a year ago. This doesn't mean that we have to do a character-for-character validation of the generated markup, but the test definitely shouldn't boil down to "did it actually return something" because at that point it's just wasting CPU cycles.

@Bakual
Copy link
Contributor Author

Bakual commented Jun 21, 2017

Removing the doubled space from the JLayout. Waiting for Travis to see if that fixes all of the issues 😄

@Bakual
Copy link
Contributor Author

Bakual commented Jun 21, 2017

@wilsonge Travis passes now. But it became a bit more than just unit tests. The layouts generated a doubled space since $id already contains the space (" id=foo")

@wilsonge wilsonge merged commit e83f019 into joomla:4.0-dev Jun 21, 2017
@wilsonge wilsonge added this to the Joomla 4.0 milestone Jun 21, 2017
@Bakual Bakual deleted the FixTravis branch June 21, 2017 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants