rewrite unit tests (for wordcamp)
This commit is contained in:
parent
87270d8096
commit
d9926d1fbd
7 changed files with 264 additions and 51 deletions
56
tests/test-WpIntegrationTests.php
Normal file
56
tests/test-WpIntegrationTests.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
# tests with WP integration, using the loaded plugin
|
||||
class WpIntegrationTests extends WP_UnitTestCase {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// access to plugin instance
|
||||
$this->plugin = $GLOBALS['wp-plugin-ffmeta'];
|
||||
$this->plugin->reinit_external_data_service(new MockDataService());
|
||||
}
|
||||
|
||||
function test_post_ff_state() {
|
||||
$post_content = '[ff_state]';
|
||||
$post_attribs = array( 'post_title' => 'Test', 'post_content' => $post_content );
|
||||
$post = $this->factory->post->create_and_get( $post_attribs );
|
||||
|
||||
// w/o filter:
|
||||
$this->assertEquals($post_content, $post->post_content);
|
||||
|
||||
// with filter:
|
||||
$output = apply_filters( 'the_content', $post->post_content );
|
||||
$this->assertEquals("<div class=\"ff ff_state\">429</div>\n", $output);
|
||||
}
|
||||
|
||||
function test_post_ff_state_othercity() {
|
||||
$post_content = '[ff_state ffm]';
|
||||
$post_attribs = array( 'post_title' => 'Test', 'post_content' => $post_content );
|
||||
$post = $this->factory->post->create_and_get( $post_attribs );
|
||||
$output = apply_filters( 'the_content', $post->post_content );
|
||||
|
||||
$this->assertEquals("<div class=\"ff ff_state\"></div>\n", $output);
|
||||
}
|
||||
|
||||
function test_post_ff_state_inv_city() {
|
||||
$post_content = '[ff_state jena]';
|
||||
$post_attribs = array( 'post_title' => 'Test', 'post_content' => $post_content );
|
||||
$post = $this->factory->post->create_and_get( $post_attribs );
|
||||
$output = apply_filters( 'the_content', $post->post_content );
|
||||
|
||||
$this->assertRegExp('/<!-- FF Meta Error:/', $output);
|
||||
}
|
||||
|
||||
function test_post_ff_services() {
|
||||
$post_content = '[ff_services]';
|
||||
$post_attribs = array( 'post_title' => 'Test', 'post_content' => $post_content );
|
||||
$post = $this->factory->post->create_and_get( $post_attribs );
|
||||
|
||||
// w/o filter:
|
||||
$this->assertEquals($post_content, $post->post_content);
|
||||
|
||||
// with filter:
|
||||
$output = apply_filters( 'the_content', $post->post_content );
|
||||
$this->assertRegExp('/radio\.ffhh/', $output);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue