-
-
Save rnagle/d1d06cb6717761f28359 to your computer and use it in GitHub Desktop.
"Hello World!" plugin tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class HelloWorldTest extends WP_UnitTestCase { | |
function test_hello_world() { | |
// Test hello_world() | |
$this->assertEquals("Hello World!" == hello_world()); | |
} | |
function test_hello_world_markup() { | |
// Test hello_world_markup() | |
ob_start(); | |
hello_world_markup(); | |
$result = ob_get_contents(); | |
ob_end_clean(); | |
$this->assertTrue(!empty(preg_match("/^<p\s+id='hello-world'>.*<\/p>$/", $result))); | |
} | |
function test_hello_world_css() { | |
// Test hello_world_css() | |
ob_start(); | |
hello_world_css(); | |
$result = ob_get_contents(); | |
ob_end_clean(); | |
// Make sure there are style tags being printed. Duh. | |
$this->assertTrue(!empty(preg_match("/.*?.*<\/style>/s", $result))); | |
// Make sure we're using the right selector | |
$this->assertTrue((bool) strpos('hello-world', $result))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment