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

Add unit testing capabilities for templates #23708

Merged
merged 2 commits into from
Apr 12, 2016
Merged

Conversation

DeepDiver1975
Copy link
Member

With these changes unit testing templates can be done as easy as

    public function test403() {
        $template = \OC::$SERVERROOT . '/core/templates/403.php';
        $expectedHtml = "<ul><li class='error'>\n\t\tAccess forbidden<br><p class='hint'></p></li></ul>";
        $this->assertTemplate($expectedHtml, $template);
    }

@DeepDiver1975 DeepDiver1975 added this to the 9.1-current milestone Mar 31, 2016
@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @bartv2, @butonic and @schiesbn to be potential reviewers

* @param string $file
* @param null $additionalParams
Copy link
Member

Choose a reason for hiding this comment

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

Only null? 😉

$this->removeWhitespaces($actual);

// $expectedHtml1 = preg_replace('~\s+~i', '', $expected->saveHTML());
// $actualHtml1 = preg_replace('~\s+~i', '', $actual->saveHTML());
Copy link
Contributor

Choose a reason for hiding this comment

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

could be removed ;)

@MorrisJobke
Copy link
Contributor

Code looks good and works 👍

* @param string $template
* @param array $vars
*/
protected function assertTemplate($expectedHtml, $template, $vars = []) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't those methods live in tests/core/templates/templates.php

Copy link
Member Author

Choose a reason for hiding this comment

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

I want to use this function in very app and all templates here in core - moving them into the base class made most sense to me - objections?

Copy link
Contributor

Choose a reason for hiding this comment

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

Well my "objection" was that it is now available in all apps and tests. but I guess that is intended then, so fine

Copy link
Member Author

Choose a reason for hiding this comment

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

so fine

is that a 👍 ❓

@LukasReschke
Copy link
Member

👍

@DeepDiver1975 DeepDiver1975 merged commit fdee771 into master Apr 12, 2016
@DeepDiver1975 DeepDiver1975 deleted the unit-test-templates branch April 12, 2016 10:49
@lock
Copy link

lock bot commented Aug 6, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants