"Hello World!" plugin tests
<?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