Skip to content

Commit 392dac6

Browse files
committed
Coding Standards on Tests
1 parent de20bd8 commit 392dac6

File tree

1 file changed

+53
-15
lines changed

1 file changed

+53
-15
lines changed

tests/ConvertKitMethodsTest.php

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,31 @@ public function testConvertRelativeToAbsoluteUrls()
5757
$url_scheme_host_only = 'https://example.com';
5858

5959
// Convert relative URLs to absolute URLs for elements we want to test.
60-
$this->api->convert_relative_to_absolute_urls($html->getElementsByTagName('a'), 'href', $url_scheme_host_only);
61-
$this->api->convert_relative_to_absolute_urls($html->getElementsByTagName('link'), 'href', $url_scheme_host_only);
62-
$this->api->convert_relative_to_absolute_urls($html->getElementsByTagName('img'), 'src', $url_scheme_host_only);
63-
$this->api->convert_relative_to_absolute_urls($html->getElementsByTagName('script'), 'src', $url_scheme_host_only);
64-
$this->api->convert_relative_to_absolute_urls($html->getElementsByTagName('form'), 'action', $url_scheme_host_only);
60+
$this->api->convert_relative_to_absolute_urls(
61+
$html->getElementsByTagName('a'),
62+
'href',
63+
$url_scheme_host_only
64+
);
65+
$this->api->convert_relative_to_absolute_urls(
66+
$html->getElementsByTagName('link'),
67+
'href',
68+
$url_scheme_host_only
69+
);
70+
$this->api->convert_relative_to_absolute_urls(
71+
$html->getElementsByTagName('img'),
72+
'src',
73+
$url_scheme_host_only
74+
);
75+
$this->api->convert_relative_to_absolute_urls(
76+
$html->getElementsByTagName('script'),
77+
'src',
78+
$url_scheme_host_only
79+
);
80+
$this->api->convert_relative_to_absolute_urls(
81+
$html->getElementsByTagName('form'),
82+
'action',
83+
$url_scheme_host_only
84+
);
6585

6686
// Fetch HTML string.
6787
$output = $html->saveHTML();
@@ -70,25 +90,43 @@ public function testConvertRelativeToAbsoluteUrls()
7090
$this->assertStringContainsString('<link rel="stylesheet" href="//fonts.googleapis.com">', $output);
7191

7292
// Assert string does not contain HTML elements that should be removed.
73-
$this->assertStringNotContainsString('<script type="text/javascript" src="rocket-loader.min.js"></script>', $output);
93+
$this->assertStringNotContainsString(
94+
'<script type="text/javascript" src="rocket-loader.min.js"></script>',
95+
$output
96+
);
7497

7598
// Assert string contains expected HTML elements that should be modified.
76-
$this->assertStringContainsString('<a href="' . $url_scheme_host_only . '/test">Test</a>', $output);
77-
$this->assertStringContainsString('<img src="' . $url_scheme_host_only . '/test.jpg">', $output);
78-
$this->assertStringContainsString('<script type="text/javascript" src="' . $url_scheme_host_only . '/test.js"></script>', $output);
79-
$this->assertStringContainsString('<form action="' . $url_scheme_host_only . '/test">Test</form>', $output);
99+
$this->assertStringContainsString(
100+
'<a href="' . $url_scheme_host_only . '/test">Test</a>',
101+
$output
102+
);
103+
$this->assertStringContainsString(
104+
'<img src="' . $url_scheme_host_only . '/test.jpg">',
105+
$output
106+
);
107+
$this->assertStringContainsString(
108+
'<script type="text/javascript" src="' . $url_scheme_host_only . '/test.js"></script>',
109+
$output
110+
);
111+
$this->assertStringContainsString(
112+
'<form action="' . $url_scheme_host_only . '/test">Test</form>',
113+
$output
114+
);
80115
}
81116

82117
/**
83-
* Test that the get_body_html() method returns the expected HTML.
84-
*
85-
* @since 2.4.1
86-
*/
118+
* Test that the get_body_html() method returns the expected HTML.
119+
*
120+
* @since 2.4.1
121+
*/
87122
public function testGetBodyHtml()
88123
{
89124
$content = '<h1>Vantar þinn ungling sjálfstraust í stærðfræði?</h1><p>This is a test</p>';
90125
$html = new \DOMDocument();
91-
$html->loadHTML('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>'.$content.'</body></html>');
126+
$html->loadHTML('
127+
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
128+
<body>' . $content . '</body>
129+
</html>');
92130
$this->assertEquals($content, $this->api->get_body_html($html));
93131
}
94132
}

0 commit comments

Comments
 (0)