forked from mschuett/freifunkmeta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-WpIntegrationTests.php
70 lines (55 loc) · 2.59 KB
/
test-WpIntegrationTests.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?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);
}
function test_post_ff_list() {
$post_content = '[ff_list]';
$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('/Hamburg/', $output);
$this->assertRegExp('/Frankfurt/', $output);
}
}