@@ -1,69 +1,69 @@ |
||
1 | 1 | <?php |
2 | 2 | class CheckMaps extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + } |
|
8 | 8 | |
9 | - public function testCheckHomeMap() |
|
10 | - { |
|
11 | - $output = do_shortcode('[gd_homepage_map width=100% height=300 scrollwheel=false]'); |
|
12 | - $this->assertContains( 'geodir-map-home-page', $output ); |
|
13 | - } |
|
9 | + public function testCheckHomeMap() |
|
10 | + { |
|
11 | + $output = do_shortcode('[gd_homepage_map width=100% height=300 scrollwheel=false]'); |
|
12 | + $this->assertContains( 'geodir-map-home-page', $output ); |
|
13 | + } |
|
14 | 14 | |
15 | - public function testListingsPageMap() |
|
16 | - { |
|
17 | - $output = do_shortcode('[gd_listing_map width=100% height=300 scrollwheel=false sticky=true]'); |
|
18 | - $this->assertContains( 'geodir-map-listing-page', $output ); |
|
19 | - } |
|
15 | + public function testListingsPageMap() |
|
16 | + { |
|
17 | + $output = do_shortcode('[gd_listing_map width=100% height=300 scrollwheel=false sticky=true]'); |
|
18 | + $this->assertContains( 'geodir-map-listing-page', $output ); |
|
19 | + } |
|
20 | 20 | |
21 | - public function testDetailPageMap() |
|
22 | - { |
|
21 | + public function testDetailPageMap() |
|
22 | + { |
|
23 | 23 | |
24 | - $query_args = array( |
|
25 | - 'post_status' => 'publish', |
|
26 | - 'post_type' => 'gd_place', |
|
27 | - 'posts_per_page' => 1, |
|
28 | - ); |
|
24 | + $query_args = array( |
|
25 | + 'post_status' => 'publish', |
|
26 | + 'post_type' => 'gd_place', |
|
27 | + 'posts_per_page' => 1, |
|
28 | + ); |
|
29 | 29 | |
30 | - $all_posts = new WP_Query( $query_args ); |
|
31 | - $post_id = null; |
|
32 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
33 | - $post_id = get_the_ID(); |
|
34 | - global $post; |
|
35 | - $post = geodir_get_post_info($post_id); |
|
36 | - setup_postdata($post); |
|
30 | + $all_posts = new WP_Query( $query_args ); |
|
31 | + $post_id = null; |
|
32 | + while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
33 | + $post_id = get_the_ID(); |
|
34 | + global $post; |
|
35 | + $post = geodir_get_post_info($post_id); |
|
36 | + setup_postdata($post); |
|
37 | 37 | |
38 | - $map_args = array(); |
|
39 | - $map_args['map_canvas_name'] = 'detail_page_map_canvas'; |
|
40 | - $map_args['width'] = '600'; |
|
41 | - $map_args['height'] = '300'; |
|
42 | - if ($post->post_mapzoom) { |
|
43 | - $map_args['zoom'] = '' . $post->post_mapzoom . ''; |
|
44 | - } |
|
45 | - $map_args['autozoom'] = false; |
|
46 | - $map_args['child_collapse'] = '0'; |
|
47 | - $map_args['enable_cat_filters'] = false; |
|
48 | - $map_args['enable_text_search'] = false; |
|
49 | - $map_args['enable_post_type_filters'] = false; |
|
50 | - $map_args['enable_location_filters'] = false; |
|
51 | - $map_args['enable_jason_on_load'] = true; |
|
52 | - $map_args['enable_map_direction'] = true; |
|
53 | - $map_args['map_class_name'] = 'geodir-map-detail-page'; |
|
54 | - $map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP'; |
|
55 | - ob_start(); |
|
56 | - geodir_draw_map($map_args); |
|
57 | - $output = ob_get_clean(); |
|
58 | - $this->assertContains( 'geodir-map-detail-page', $output ); |
|
59 | - endwhile; |
|
38 | + $map_args = array(); |
|
39 | + $map_args['map_canvas_name'] = 'detail_page_map_canvas'; |
|
40 | + $map_args['width'] = '600'; |
|
41 | + $map_args['height'] = '300'; |
|
42 | + if ($post->post_mapzoom) { |
|
43 | + $map_args['zoom'] = '' . $post->post_mapzoom . ''; |
|
44 | + } |
|
45 | + $map_args['autozoom'] = false; |
|
46 | + $map_args['child_collapse'] = '0'; |
|
47 | + $map_args['enable_cat_filters'] = false; |
|
48 | + $map_args['enable_text_search'] = false; |
|
49 | + $map_args['enable_post_type_filters'] = false; |
|
50 | + $map_args['enable_location_filters'] = false; |
|
51 | + $map_args['enable_jason_on_load'] = true; |
|
52 | + $map_args['enable_map_direction'] = true; |
|
53 | + $map_args['map_class_name'] = 'geodir-map-detail-page'; |
|
54 | + $map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP'; |
|
55 | + ob_start(); |
|
56 | + geodir_draw_map($map_args); |
|
57 | + $output = ob_get_clean(); |
|
58 | + $this->assertContains( 'geodir-map-detail-page', $output ); |
|
59 | + endwhile; |
|
60 | 60 | |
61 | 61 | |
62 | - } |
|
62 | + } |
|
63 | 63 | |
64 | - public function tearDown() |
|
65 | - { |
|
66 | - parent::tearDown(); |
|
67 | - } |
|
64 | + public function tearDown() |
|
65 | + { |
|
66 | + parent::tearDown(); |
|
67 | + } |
|
68 | 68 | } |
69 | 69 | ?> |
70 | 70 | \ No newline at end of file |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | public function testCheckHomeMap() |
10 | 10 | { |
11 | 11 | $output = do_shortcode('[gd_homepage_map width=100% height=300 scrollwheel=false]'); |
12 | - $this->assertContains( 'geodir-map-home-page', $output ); |
|
12 | + $this->assertContains('geodir-map-home-page', $output); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | public function testListingsPageMap() |
16 | 16 | { |
17 | 17 | $output = do_shortcode('[gd_listing_map width=100% height=300 scrollwheel=false sticky=true]'); |
18 | - $this->assertContains( 'geodir-map-listing-page', $output ); |
|
18 | + $this->assertContains('geodir-map-listing-page', $output); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function testDetailPageMap() |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | 'posts_per_page' => 1, |
28 | 28 | ); |
29 | 29 | |
30 | - $all_posts = new WP_Query( $query_args ); |
|
30 | + $all_posts = new WP_Query($query_args); |
|
31 | 31 | $post_id = null; |
32 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
32 | + while ($all_posts->have_posts()) : $all_posts->the_post(); |
|
33 | 33 | $post_id = get_the_ID(); |
34 | 34 | global $post; |
35 | - $post = geodir_get_post_info($post_id); |
|
35 | + $post = geodir_get_post_info($post_id); |
|
36 | 36 | setup_postdata($post); |
37 | 37 | |
38 | 38 | $map_args = array(); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $map_args['width'] = '600'; |
41 | 41 | $map_args['height'] = '300'; |
42 | 42 | if ($post->post_mapzoom) { |
43 | - $map_args['zoom'] = '' . $post->post_mapzoom . ''; |
|
43 | + $map_args['zoom'] = ''.$post->post_mapzoom.''; |
|
44 | 44 | } |
45 | 45 | $map_args['autozoom'] = false; |
46 | 46 | $map_args['child_collapse'] = '0'; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | ob_start(); |
56 | 56 | geodir_draw_map($map_args); |
57 | 57 | $output = ob_get_clean(); |
58 | - $this->assertContains( 'geodir-map-detail-page', $output ); |
|
58 | + $this->assertContains('geodir-map-detail-page', $output); |
|
59 | 59 | endwhile; |
60 | 60 | |
61 | 61 |
@@ -1,19 +1,19 @@ |
||
1 | 1 | <?php |
2 | 2 | class CheckPinpoint extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + } |
|
8 | 8 | |
9 | - public function testCheckPinpoint() |
|
10 | - { |
|
9 | + public function testCheckPinpoint() |
|
10 | + { |
|
11 | 11 | |
12 | - } |
|
12 | + } |
|
13 | 13 | |
14 | - public function tearDown() |
|
15 | - { |
|
16 | - parent::tearDown(); |
|
17 | - } |
|
14 | + public function tearDown() |
|
15 | + { |
|
16 | + parent::tearDown(); |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | ?> |
20 | 20 | \ No newline at end of file |
@@ -1,63 +1,63 @@ |
||
1 | 1 | <?php |
2 | 2 | class AddReview extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - wp_set_current_user(1); |
|
8 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + wp_set_current_user(1); |
|
8 | + } |
|
9 | 9 | |
10 | - public function testAddReview() |
|
11 | - { |
|
12 | - $time = current_time('mysql'); |
|
10 | + public function testAddReview() |
|
11 | + { |
|
12 | + $time = current_time('mysql'); |
|
13 | 13 | |
14 | - $args = array( |
|
15 | - 'listing_type' => 'gd_place', |
|
16 | - 'post_title' => 'Test Listing Title', |
|
17 | - 'post_desc' => 'Test Desc', |
|
18 | - 'post_tags' => 'test1,test2', |
|
19 | - 'post_address' => 'New York City Hall', |
|
20 | - 'post_zip' => '10007', |
|
21 | - 'post_latitude' => '40.7127837', |
|
22 | - 'post_longitude' => '-74.00594130000002', |
|
23 | - 'post_mapview' => 'ROADMAP', |
|
24 | - 'post_mapzoom' => '10', |
|
25 | - 'geodir_timing' => '10.00 am to 6 pm every day', |
|
26 | - 'geodir_contact' => '1234567890', |
|
27 | - 'geodir_email' => '[email protected]', |
|
28 | - 'geodir_website' => 'http://test.com', |
|
29 | - 'geodir_twitter' => 'http://twitter.com/test', |
|
30 | - 'geodir_facebook' => 'http://facebook.com/test', |
|
31 | - 'geodir_special_offers' => 'Test offer' |
|
32 | - ); |
|
33 | - $post_id = geodir_save_listing($args, true); |
|
14 | + $args = array( |
|
15 | + 'listing_type' => 'gd_place', |
|
16 | + 'post_title' => 'Test Listing Title', |
|
17 | + 'post_desc' => 'Test Desc', |
|
18 | + 'post_tags' => 'test1,test2', |
|
19 | + 'post_address' => 'New York City Hall', |
|
20 | + 'post_zip' => '10007', |
|
21 | + 'post_latitude' => '40.7127837', |
|
22 | + 'post_longitude' => '-74.00594130000002', |
|
23 | + 'post_mapview' => 'ROADMAP', |
|
24 | + 'post_mapzoom' => '10', |
|
25 | + 'geodir_timing' => '10.00 am to 6 pm every day', |
|
26 | + 'geodir_contact' => '1234567890', |
|
27 | + 'geodir_email' => '[email protected]', |
|
28 | + 'geodir_website' => 'http://test.com', |
|
29 | + 'geodir_twitter' => 'http://twitter.com/test', |
|
30 | + 'geodir_facebook' => 'http://facebook.com/test', |
|
31 | + 'geodir_special_offers' => 'Test offer' |
|
32 | + ); |
|
33 | + $post_id = geodir_save_listing($args, true); |
|
34 | 34 | |
35 | - $data = array( |
|
36 | - 'comment_post_ID' => $post_id, |
|
37 | - 'comment_author' => 'admin', |
|
38 | - 'comment_author_email' => '[email protected]', |
|
39 | - 'comment_author_url' => 'http://wpgeodirectory.com', |
|
40 | - 'comment_content' => 'content here', |
|
41 | - 'comment_type' => '', |
|
42 | - 'comment_parent' => 0, |
|
43 | - 'user_id' => 1, |
|
44 | - 'comment_author_IP' => '127.0.0.1', |
|
45 | - 'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)', |
|
46 | - 'comment_date' => $time, |
|
47 | - 'comment_approved' => 1, |
|
48 | - ); |
|
35 | + $data = array( |
|
36 | + 'comment_post_ID' => $post_id, |
|
37 | + 'comment_author' => 'admin', |
|
38 | + 'comment_author_email' => '[email protected]', |
|
39 | + 'comment_author_url' => 'http://wpgeodirectory.com', |
|
40 | + 'comment_content' => 'content here', |
|
41 | + 'comment_type' => '', |
|
42 | + 'comment_parent' => 0, |
|
43 | + 'user_id' => 1, |
|
44 | + 'comment_author_IP' => '127.0.0.1', |
|
45 | + 'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)', |
|
46 | + 'comment_date' => $time, |
|
47 | + 'comment_approved' => 1, |
|
48 | + ); |
|
49 | 49 | |
50 | - $comment_id = wp_insert_comment($data); |
|
50 | + $comment_id = wp_insert_comment($data); |
|
51 | 51 | |
52 | - $_REQUEST['geodir_overallrating'] = 5.0; |
|
53 | - geodir_save_rating($comment_id); |
|
52 | + $_REQUEST['geodir_overallrating'] = 5.0; |
|
53 | + geodir_save_rating($comment_id); |
|
54 | 54 | |
55 | - $this->assertTrue(is_int($comment_id)); |
|
56 | - } |
|
55 | + $this->assertTrue(is_int($comment_id)); |
|
56 | + } |
|
57 | 57 | |
58 | - public function tearDown() |
|
59 | - { |
|
60 | - parent::tearDown(); |
|
61 | - } |
|
58 | + public function tearDown() |
|
59 | + { |
|
60 | + parent::tearDown(); |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | ?> |
64 | 64 | \ No newline at end of file |
@@ -1,116 +1,116 @@ |
||
1 | 1 | <?php |
2 | 2 | class SendEnquiry extends WP_UnitTestCase |
3 | 3 | { |
4 | - public function setUp() |
|
5 | - { |
|
6 | - parent::setUp(); |
|
7 | - } |
|
8 | - |
|
9 | - public function testSendEnquiry() |
|
10 | - { |
|
11 | - $query_args = array( |
|
12 | - 'post_status' => 'publish', |
|
13 | - 'post_type' => 'gd_place', |
|
14 | - 'posts_per_page' => 1, |
|
15 | - ); |
|
16 | - |
|
17 | - $all_posts = new WP_Query( $query_args ); |
|
18 | - $post_id = null; |
|
19 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
20 | - $post_id = get_the_ID(); |
|
21 | - endwhile; |
|
22 | - |
|
23 | - $this->assertTrue(is_int($post_id)); |
|
24 | - |
|
25 | - $data = array( |
|
26 | - 'sendact' => 'send_inqury', |
|
27 | - 'pid' => (string) $post_id, |
|
28 | - 'inq_name' => 'Test User', |
|
29 | - 'inq_email' => '[email protected]', |
|
30 | - 'inq_phone' => 'Test', |
|
31 | - 'inq_msg' => 'Hi there, I would like to enquire about this place. I would like to ask more info about...', |
|
32 | - 'Send' => 'Send' |
|
33 | - ); |
|
34 | - |
|
35 | - add_filter('wp_redirect', '__return_false'); |
|
36 | - geodir_send_inquiry($data); |
|
37 | - remove_filter('wp_redirect', '__return_false'); |
|
38 | - } |
|
39 | - |
|
40 | - public function testSendToFriend() |
|
41 | - { |
|
42 | - $query_args = array( |
|
43 | - 'post_status' => 'publish', |
|
44 | - 'post_type' => 'gd_place', |
|
45 | - 'posts_per_page' => 1, |
|
46 | - ); |
|
47 | - |
|
48 | - $all_posts = new WP_Query( $query_args ); |
|
49 | - $post_id = null; |
|
50 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
51 | - $post_id = get_the_ID(); |
|
52 | - endwhile; |
|
53 | - |
|
54 | - $this->assertTrue(is_int($post_id)); |
|
55 | - |
|
56 | - $data = array( |
|
57 | - 'sendact' => 'email_frnd', |
|
58 | - 'pid' => (string) $post_id, |
|
59 | - 'yourname' => 'Test User', |
|
60 | - 'youremail' => '[email protected]', |
|
61 | - 'frnd_subject' => 'Test', |
|
62 | - 'frnd_comments' => 'Hi there, This is a comment', |
|
63 | - 'to_email' => '[email protected]', |
|
64 | - 'to_name' => 'Test User 2', |
|
65 | - 'Send' => 'Send' |
|
66 | - ); |
|
67 | - |
|
68 | - add_filter('wp_redirect', '__return_false'); |
|
69 | - geodir_send_friend($data); |
|
70 | - remove_filter('wp_redirect', '__return_false'); |
|
71 | - } |
|
72 | - |
|
73 | - public function texstSendToFriendFailure() |
|
74 | - { |
|
75 | - $query_args = array( |
|
76 | - 'post_status' => 'publish', |
|
77 | - 'post_type' => 'gd_place', |
|
78 | - 'posts_per_page' => 1, |
|
79 | - ); |
|
80 | - |
|
81 | - $all_posts = new WP_Query( $query_args ); |
|
82 | - $post_id = null; |
|
83 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
84 | - $post_id = get_the_ID(); |
|
85 | - endwhile; |
|
86 | - |
|
87 | - $this->assertTrue(is_int($post_id)); |
|
88 | - |
|
89 | - $data = array( |
|
90 | - 'sendact' => 'email_frnd', |
|
91 | - 'pid' => (string) $post_id, |
|
92 | - 'yourname' => 'Test User', |
|
93 | - 'youremail' => '[email protected]', |
|
94 | - 'frnd_subject' => 'Test', |
|
95 | - 'frnd_comments' => 'Hi there, This is a comment', |
|
96 | - 'to_email' => 'Test User 2', //incorrect email |
|
97 | - 'to_name' => '[email protected]', |
|
98 | - 'Send' => 'Send' |
|
99 | - ); |
|
100 | - |
|
101 | - add_filter('wp_redirect', '__return_false'); |
|
102 | - add_filter('wp_mail', 'print_mail'); |
|
103 | - ob_start(); |
|
104 | - geodir_send_friend($data); |
|
105 | - $output = ob_get_clean(); |
|
106 | - $this->assertContains( 'Email from GeoDirectory failed to send', $output ); |
|
107 | - remove_filter('wp_mail', 'print_mail'); |
|
108 | - remove_filter('wp_redirect', '__return_false'); |
|
109 | - } |
|
110 | - |
|
111 | - public function tearDown() |
|
112 | - { |
|
113 | - parent::tearDown(); |
|
114 | - } |
|
4 | + public function setUp() |
|
5 | + { |
|
6 | + parent::setUp(); |
|
7 | + } |
|
8 | + |
|
9 | + public function testSendEnquiry() |
|
10 | + { |
|
11 | + $query_args = array( |
|
12 | + 'post_status' => 'publish', |
|
13 | + 'post_type' => 'gd_place', |
|
14 | + 'posts_per_page' => 1, |
|
15 | + ); |
|
16 | + |
|
17 | + $all_posts = new WP_Query( $query_args ); |
|
18 | + $post_id = null; |
|
19 | + while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
20 | + $post_id = get_the_ID(); |
|
21 | + endwhile; |
|
22 | + |
|
23 | + $this->assertTrue(is_int($post_id)); |
|
24 | + |
|
25 | + $data = array( |
|
26 | + 'sendact' => 'send_inqury', |
|
27 | + 'pid' => (string) $post_id, |
|
28 | + 'inq_name' => 'Test User', |
|
29 | + 'inq_email' => '[email protected]', |
|
30 | + 'inq_phone' => 'Test', |
|
31 | + 'inq_msg' => 'Hi there, I would like to enquire about this place. I would like to ask more info about...', |
|
32 | + 'Send' => 'Send' |
|
33 | + ); |
|
34 | + |
|
35 | + add_filter('wp_redirect', '__return_false'); |
|
36 | + geodir_send_inquiry($data); |
|
37 | + remove_filter('wp_redirect', '__return_false'); |
|
38 | + } |
|
39 | + |
|
40 | + public function testSendToFriend() |
|
41 | + { |
|
42 | + $query_args = array( |
|
43 | + 'post_status' => 'publish', |
|
44 | + 'post_type' => 'gd_place', |
|
45 | + 'posts_per_page' => 1, |
|
46 | + ); |
|
47 | + |
|
48 | + $all_posts = new WP_Query( $query_args ); |
|
49 | + $post_id = null; |
|
50 | + while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
51 | + $post_id = get_the_ID(); |
|
52 | + endwhile; |
|
53 | + |
|
54 | + $this->assertTrue(is_int($post_id)); |
|
55 | + |
|
56 | + $data = array( |
|
57 | + 'sendact' => 'email_frnd', |
|
58 | + 'pid' => (string) $post_id, |
|
59 | + 'yourname' => 'Test User', |
|
60 | + 'youremail' => '[email protected]', |
|
61 | + 'frnd_subject' => 'Test', |
|
62 | + 'frnd_comments' => 'Hi there, This is a comment', |
|
63 | + 'to_email' => '[email protected]', |
|
64 | + 'to_name' => 'Test User 2', |
|
65 | + 'Send' => 'Send' |
|
66 | + ); |
|
67 | + |
|
68 | + add_filter('wp_redirect', '__return_false'); |
|
69 | + geodir_send_friend($data); |
|
70 | + remove_filter('wp_redirect', '__return_false'); |
|
71 | + } |
|
72 | + |
|
73 | + public function texstSendToFriendFailure() |
|
74 | + { |
|
75 | + $query_args = array( |
|
76 | + 'post_status' => 'publish', |
|
77 | + 'post_type' => 'gd_place', |
|
78 | + 'posts_per_page' => 1, |
|
79 | + ); |
|
80 | + |
|
81 | + $all_posts = new WP_Query( $query_args ); |
|
82 | + $post_id = null; |
|
83 | + while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
84 | + $post_id = get_the_ID(); |
|
85 | + endwhile; |
|
86 | + |
|
87 | + $this->assertTrue(is_int($post_id)); |
|
88 | + |
|
89 | + $data = array( |
|
90 | + 'sendact' => 'email_frnd', |
|
91 | + 'pid' => (string) $post_id, |
|
92 | + 'yourname' => 'Test User', |
|
93 | + 'youremail' => '[email protected]', |
|
94 | + 'frnd_subject' => 'Test', |
|
95 | + 'frnd_comments' => 'Hi there, This is a comment', |
|
96 | + 'to_email' => 'Test User 2', //incorrect email |
|
97 | + 'to_name' => '[email protected]', |
|
98 | + 'Send' => 'Send' |
|
99 | + ); |
|
100 | + |
|
101 | + add_filter('wp_redirect', '__return_false'); |
|
102 | + add_filter('wp_mail', 'print_mail'); |
|
103 | + ob_start(); |
|
104 | + geodir_send_friend($data); |
|
105 | + $output = ob_get_clean(); |
|
106 | + $this->assertContains( 'Email from GeoDirectory failed to send', $output ); |
|
107 | + remove_filter('wp_mail', 'print_mail'); |
|
108 | + remove_filter('wp_redirect', '__return_false'); |
|
109 | + } |
|
110 | + |
|
111 | + public function tearDown() |
|
112 | + { |
|
113 | + parent::tearDown(); |
|
114 | + } |
|
115 | 115 | } |
116 | 116 | ?> |
117 | 117 | \ No newline at end of file |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | 'posts_per_page' => 1, |
15 | 15 | ); |
16 | 16 | |
17 | - $all_posts = new WP_Query( $query_args ); |
|
17 | + $all_posts = new WP_Query($query_args); |
|
18 | 18 | $post_id = null; |
19 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
19 | + while ($all_posts->have_posts()) : $all_posts->the_post(); |
|
20 | 20 | $post_id = get_the_ID(); |
21 | 21 | endwhile; |
22 | 22 | |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | 'posts_per_page' => 1, |
46 | 46 | ); |
47 | 47 | |
48 | - $all_posts = new WP_Query( $query_args ); |
|
48 | + $all_posts = new WP_Query($query_args); |
|
49 | 49 | $post_id = null; |
50 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
50 | + while ($all_posts->have_posts()) : $all_posts->the_post(); |
|
51 | 51 | $post_id = get_the_ID(); |
52 | 52 | endwhile; |
53 | 53 | |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | 'posts_per_page' => 1, |
79 | 79 | ); |
80 | 80 | |
81 | - $all_posts = new WP_Query( $query_args ); |
|
81 | + $all_posts = new WP_Query($query_args); |
|
82 | 82 | $post_id = null; |
83 | - while ( $all_posts->have_posts() ) : $all_posts->the_post(); |
|
83 | + while ($all_posts->have_posts()) : $all_posts->the_post(); |
|
84 | 84 | $post_id = get_the_ID(); |
85 | 85 | endwhile; |
86 | 86 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | ob_start(); |
104 | 104 | geodir_send_friend($data); |
105 | 105 | $output = ob_get_clean(); |
106 | - $this->assertContains( 'Email from GeoDirectory failed to send', $output ); |
|
106 | + $this->assertContains('Email from GeoDirectory failed to send', $output); |
|
107 | 107 | remove_filter('wp_mail', 'print_mail'); |
108 | 108 | remove_filter('wp_redirect', '__return_false'); |
109 | 109 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | // reset the wpdb queries log, storing it on the profile stack if necessary |
41 | 41 | global $wpdb; |
42 | 42 | if ($this->stack) { |
43 | - $this->stack[count($this->stack)-1]['queries'] = $wpdb->queries; |
|
43 | + $this->stack[count($this->stack) - 1]['queries'] = $wpdb->queries; |
|
44 | 44 | } |
45 | 45 | $wpdb->queries = array(); |
46 | 46 | |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | |
75 | 75 | if (isset($this->profile[$name])) { |
76 | 76 | $this->profile[$name]['time'] += $time; |
77 | - $this->profile[$name]['calls'] ++; |
|
77 | + $this->profile[$name]['calls']++; |
|
78 | 78 | $this->profile[$name]['cache_cold_hits'] += ($wp_object_cache->cold_cache_hits - $item['cache_cold_hits']); |
79 | 79 | $this->profile[$name]['cache_warm_hits'] += ($wp_object_cache->warm_cache_hits - $item['cache_warm_hits']); |
80 | 80 | $this->profile[$name]['cache_misses'] += ($wp_object_cache->cache_misses - $item['cache_misses']); |
81 | - $this->profile[$name]['cache_dirty_objects'] = array_add( $this->profile[$name]['cache_dirty_objects'], $cache_dirty_delta) ; |
|
82 | - $this->profile[$name]['actions'] = array_add( $this->profile[$name]['actions'], $item['actions'] ); |
|
83 | - $this->profile[$name]['filters'] = array_add( $this->profile[$name]['filters'], $item['filters'] ); |
|
84 | - $this->profile[$name]['queries'] = array_add( $this->profile[$name]['queries'], $item['queries'] ); |
|
81 | + $this->profile[$name]['cache_dirty_objects'] = array_add($this->profile[$name]['cache_dirty_objects'], $cache_dirty_delta); |
|
82 | + $this->profile[$name]['actions'] = array_add($this->profile[$name]['actions'], $item['actions']); |
|
83 | + $this->profile[$name]['filters'] = array_add($this->profile[$name]['filters'], $item['filters']); |
|
84 | + $this->profile[$name]['queries'] = array_add($this->profile[$name]['queries'], $item['queries']); |
|
85 | 85 | #$this->_query_summary($item['queries'], $this->profile[$name]['queries']); |
86 | 86 | |
87 | 87 | } |
@@ -109,28 +109,28 @@ discard block |
||
109 | 109 | |
110 | 110 | function microtime($since = 0.0) { |
111 | 111 | list($usec, $sec) = explode(' ', microtime()); |
112 | - return (float)$sec + (float)$usec - $since; |
|
112 | + return (float) $sec + (float) $usec - $since; |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | function log_filter($tag) { |
116 | 116 | if ($this->stack) { |
117 | 117 | global $wp_actions; |
118 | 118 | if ($tag == end($wp_actions)) |
119 | - @$this->stack[count($this->stack)-1]['actions'][$tag] ++; |
|
119 | + @$this->stack[count($this->stack) - 1]['actions'][$tag]++; |
|
120 | 120 | else |
121 | - @$this->stack[count($this->stack)-1]['filters'][$tag] ++; |
|
121 | + @$this->stack[count($this->stack) - 1]['filters'][$tag]++; |
|
122 | 122 | } |
123 | 123 | return $arg; |
124 | 124 | } |
125 | 125 | |
126 | 126 | function log_action($tag) { |
127 | 127 | if ($this->stack) |
128 | - @$this->stack[count($this->stack)-1]['actions'][$tag] ++; |
|
128 | + @$this->stack[count($this->stack) - 1]['actions'][$tag]++; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | function _current_action() { |
132 | 132 | global $wp_actions; |
133 | - return $wp_actions[count($wp_actions)-1]; |
|
133 | + return $wp_actions[count($wp_actions) - 1]; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | function results() { |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | $sql = preg_replace('/(WHERE \w+ =) \d+/', '$1 x', $sql); |
144 | 144 | $sql = preg_replace('/(WHERE \w+ =) \'\[-\w]+\'/', '$1 \'xxx\'', $sql); |
145 | 145 | |
146 | - @$out[$sql] ++; |
|
146 | + @$out[$sql]++; |
|
147 | 147 | } |
148 | 148 | asort($out); |
149 | 149 | return; |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | $out = array(); |
155 | 155 | foreach ($queries as $q) { |
156 | 156 | if (empty($q[2])) |
157 | - @$out['unknown'] ++; |
|
157 | + @$out['unknown']++; |
|
158 | 158 | else |
159 | - @$out[$q[2]] ++; |
|
159 | + @$out[$q[2]]++; |
|
160 | 160 | } |
161 | 161 | return $out; |
162 | 162 | } |
@@ -84,8 +84,7 @@ discard block |
||
84 | 84 | $this->profile[$name]['queries'] = array_add( $this->profile[$name]['queries'], $item['queries'] ); |
85 | 85 | #$this->_query_summary($item['queries'], $this->profile[$name]['queries']); |
86 | 86 | |
87 | - } |
|
88 | - else { |
|
87 | + } else { |
|
89 | 88 | $queries = array(); |
90 | 89 | $this->_query_summary($item['queries'], $queries); |
91 | 90 | $this->profile[$name] = array( |
@@ -115,17 +114,19 @@ discard block |
||
115 | 114 | function log_filter($tag) { |
116 | 115 | if ($this->stack) { |
117 | 116 | global $wp_actions; |
118 | - if ($tag == end($wp_actions)) |
|
119 | - @$this->stack[count($this->stack)-1]['actions'][$tag] ++; |
|
120 | - else |
|
121 | - @$this->stack[count($this->stack)-1]['filters'][$tag] ++; |
|
117 | + if ($tag == end($wp_actions)) { |
|
118 | + @$this->stack[count($this->stack)-1]['actions'][$tag] ++; |
|
119 | + } else { |
|
120 | + @$this->stack[count($this->stack)-1]['filters'][$tag] ++; |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | return $arg; |
124 | 124 | } |
125 | 125 | |
126 | 126 | function log_action($tag) { |
127 | - if ($this->stack) |
|
128 | - @$this->stack[count($this->stack)-1]['actions'][$tag] ++; |
|
127 | + if ($this->stack) { |
|
128 | + @$this->stack[count($this->stack)-1]['actions'][$tag] ++; |
|
129 | + } |
|
129 | 130 | } |
130 | 131 | |
131 | 132 | function _current_action() { |
@@ -153,36 +154,41 @@ discard block |
||
153 | 154 | // this requires the savequeries patch at https://core.trac.wordpress.org/ticket/5218 |
154 | 155 | $out = array(); |
155 | 156 | foreach ($queries as $q) { |
156 | - if (empty($q[2])) |
|
157 | - @$out['unknown'] ++; |
|
158 | - else |
|
159 | - @$out[$q[2]] ++; |
|
157 | + if (empty($q[2])) { |
|
158 | + @$out['unknown'] ++; |
|
159 | + } else { |
|
160 | + @$out[$q[2]] ++; |
|
161 | + } |
|
160 | 162 | } |
161 | 163 | return $out; |
162 | 164 | } |
163 | 165 | |
164 | 166 | function _dirty_objects_count($dirty_objects) { |
165 | 167 | $out = array(); |
166 | - foreach (array_keys($dirty_objects) as $group) |
|
167 | - $out[$group] = count($dirty_objects[$group]); |
|
168 | + foreach (array_keys($dirty_objects) as $group) { |
|
169 | + $out[$group] = count($dirty_objects[$group]); |
|
170 | + } |
|
168 | 171 | return $out; |
169 | 172 | } |
170 | 173 | |
171 | 174 | function array_add($a, $b) { |
172 | 175 | $out = $a; |
173 | - foreach (array_keys($b) as $key) |
|
174 | - if (array_key_exists($key, $out)) |
|
176 | + foreach (array_keys($b) as $key) { |
|
177 | + if (array_key_exists($key, $out)) |
|
175 | 178 | $out[$key] += $b[$key]; |
176 | - else |
|
177 | - $out[$key] = $b[$key]; |
|
179 | + } |
|
180 | + else { |
|
181 | + $out[$key] = $b[$key]; |
|
182 | + } |
|
178 | 183 | return $out; |
179 | 184 | } |
180 | 185 | |
181 | 186 | function array_sub($a, $b) { |
182 | 187 | $out = $a; |
183 | - foreach (array_keys($b) as $key) |
|
184 | - if (array_key_exists($key, $b)) |
|
188 | + foreach (array_keys($b) as $key) { |
|
189 | + if (array_key_exists($key, $b)) |
|
185 | 190 | $out[$key] -= $b[$key]; |
191 | + } |
|
186 | 192 | return $out; |
187 | 193 | } |
188 | 194 |
@@ -6,321 +6,321 @@ |
||
6 | 6 | */ |
7 | 7 | class SpeedTrapListener implements PHPUnit_Framework_TestListener |
8 | 8 | { |
9 | - /** |
|
10 | - * Internal tracking for test suites. |
|
11 | - * |
|
12 | - * Increments as more suites are run, then decremented as they finish. All |
|
13 | - * suites have been run when returns to 0. |
|
14 | - * |
|
15 | - * @var integer |
|
16 | - */ |
|
17 | - protected $suites = 0; |
|
18 | - |
|
19 | - /** |
|
20 | - * Time in milliseconds at which a test will be considered "slow" and be |
|
21 | - * reported by this listener. |
|
22 | - * |
|
23 | - * @var int |
|
24 | - */ |
|
25 | - protected $slowThreshold; |
|
26 | - |
|
27 | - /** |
|
28 | - * Number of tests to report on for slowness. |
|
29 | - * |
|
30 | - * @var int |
|
31 | - */ |
|
32 | - protected $reportLength; |
|
33 | - |
|
34 | - /** |
|
35 | - * Collection of slow tests. |
|
36 | - * |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - protected $slow = array(); |
|
40 | - |
|
41 | - /** |
|
42 | - * Construct a new instance. |
|
43 | - * |
|
44 | - * @param array $options |
|
45 | - */ |
|
46 | - public function __construct(array $options = array()) |
|
47 | - { |
|
48 | - $this->loadOptions($options); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * An error occurred. |
|
53 | - * |
|
54 | - * @param PHPUnit_Framework_Test $test |
|
55 | - * @param Exception $e |
|
56 | - * @param float $time |
|
57 | - */ |
|
58 | - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
59 | - { |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * A warning occurred. |
|
64 | - * |
|
65 | - * @param PHPUnit_Framework_Test $test |
|
66 | - * @param PHPUnit_Framework_Warning $e |
|
67 | - * @param float $time |
|
68 | - * @since Method available since Release 5.1.0 |
|
69 | - */ |
|
70 | - public function addWarning(PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, $time) |
|
71 | - { |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * A failure occurred. |
|
76 | - * |
|
77 | - * @param PHPUnit_Framework_Test $test |
|
78 | - * @param PHPUnit_Framework_AssertionFailedError $e |
|
79 | - * @param float $time |
|
80 | - */ |
|
81 | - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) |
|
82 | - { |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Incomplete test. |
|
87 | - * |
|
88 | - * @param PHPUnit_Framework_Test $test |
|
89 | - * @param Exception $e |
|
90 | - * @param float $time |
|
91 | - */ |
|
92 | - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
93 | - { |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Risky test. |
|
98 | - * |
|
99 | - * @param PHPUnit_Framework_Test $test |
|
100 | - * @param Exception $e |
|
101 | - * @param float $time |
|
102 | - * @since Method available since Release 4.0.0 |
|
103 | - */ |
|
104 | - public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
105 | - { |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Skipped test. |
|
110 | - * |
|
111 | - * @param PHPUnit_Framework_Test $test |
|
112 | - * @param Exception $e |
|
113 | - * @param float $time |
|
114 | - */ |
|
115 | - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
116 | - { |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * A test started. |
|
121 | - * |
|
122 | - * @param PHPUnit_Framework_Test $test |
|
123 | - */ |
|
124 | - public function startTest(PHPUnit_Framework_Test $test) |
|
125 | - { |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * A test ended. |
|
130 | - * |
|
131 | - * @param PHPUnit_Framework_Test $test |
|
132 | - * @param float $time |
|
133 | - */ |
|
134 | - public function endTest(PHPUnit_Framework_Test $test, $time) |
|
135 | - { |
|
136 | - if (!$test instanceof PHPUnit_Framework_TestCase) return; |
|
137 | - |
|
138 | - $time = $this->toMilliseconds($time); |
|
139 | - $threshold = $this->getSlowThreshold($test); |
|
140 | - |
|
141 | - if ($this->isSlow($time, $threshold)) { |
|
142 | - $this->addSlowTest($test, $time); |
|
143 | - } |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * A test suite started. |
|
148 | - * |
|
149 | - * @param PHPUnit_Framework_TestSuite $suite |
|
150 | - */ |
|
151 | - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) |
|
152 | - { |
|
153 | - $this->suites++; |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * A test suite ended. |
|
158 | - * |
|
159 | - * @param PHPUnit_Framework_TestSuite $suite |
|
160 | - */ |
|
161 | - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) |
|
162 | - { |
|
163 | - $this->suites--; |
|
164 | - |
|
165 | - if (0 === $this->suites && $this->hasSlowTests()) { |
|
166 | - arsort($this->slow); // Sort longest running tests to the top |
|
167 | - |
|
168 | - $this->renderHeader(); |
|
169 | - $this->renderBody(); |
|
170 | - $this->renderFooter(); |
|
171 | - } |
|
172 | - } |
|
173 | - |
|
174 | - /** |
|
175 | - * Whether the given test execution time is considered slow. |
|
176 | - * |
|
177 | - * @param int $time Test execution time in milliseconds |
|
178 | - * @param int $slowThreshold Test execution time at which a test should be considered slow (milliseconds) |
|
179 | - * @return bool |
|
180 | - */ |
|
181 | - protected function isSlow($time, $slowThreshold) |
|
182 | - { |
|
183 | - return $time >= $slowThreshold; |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Stores a test as slow. |
|
188 | - * |
|
189 | - * @param PHPUnit_Framework_TestCase $test |
|
190 | - * @param int $time Test execution time in milliseconds |
|
191 | - */ |
|
192 | - protected function addSlowTest(PHPUnit_Framework_TestCase $test, $time) |
|
193 | - { |
|
194 | - $label = $this->makeLabel($test); |
|
195 | - |
|
196 | - $this->slow[$label] = $time; |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * Whether at least one test has been considered slow. |
|
201 | - * |
|
202 | - * @return bool |
|
203 | - */ |
|
204 | - protected function hasSlowTests() |
|
205 | - { |
|
206 | - return !empty($this->slow); |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * Convert PHPUnit's reported test time (microseconds) to milliseconds. |
|
211 | - * |
|
212 | - * @param float $time |
|
213 | - * @return int |
|
214 | - */ |
|
215 | - protected function toMilliseconds($time) |
|
216 | - { |
|
217 | - return (int) round($time * 1000); |
|
218 | - } |
|
219 | - |
|
220 | - /** |
|
221 | - * Label for describing a test. |
|
222 | - * |
|
223 | - * @param PHPUnit_Framework_TestCase $test |
|
224 | - * @return string |
|
225 | - */ |
|
226 | - protected function makeLabel(PHPUnit_Framework_TestCase $test) |
|
227 | - { |
|
228 | - return sprintf('%s:%s', get_class($test), $test->getName()); |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Calculate number of slow tests to report about. |
|
233 | - * |
|
234 | - * @return int |
|
235 | - */ |
|
236 | - protected function getReportLength() |
|
237 | - { |
|
238 | - return min(count($this->slow), $this->reportLength); |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * Find how many slow tests occurred that won't be shown due to list length. |
|
243 | - * |
|
244 | - * @return int Number of hidden slow tests |
|
245 | - */ |
|
246 | - protected function getHiddenCount() |
|
247 | - { |
|
248 | - $total = count($this->slow); |
|
249 | - $showing = $this->getReportLength($this->slow); |
|
250 | - |
|
251 | - $hidden = 0; |
|
252 | - if ($total > $showing) { |
|
253 | - $hidden = $total - $showing; |
|
254 | - } |
|
255 | - |
|
256 | - return $hidden; |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Renders slow test report header. |
|
261 | - */ |
|
262 | - protected function renderHeader() |
|
263 | - { |
|
264 | - echo sprintf("\n\nYou should really fix these slow tests (>%sms)...\n", $this->slowThreshold); |
|
265 | - } |
|
266 | - |
|
267 | - /** |
|
268 | - * Renders slow test report body. |
|
269 | - */ |
|
270 | - protected function renderBody() |
|
271 | - { |
|
272 | - $slowTests = $this->slow; |
|
273 | - |
|
274 | - $length = $this->getReportLength($slowTests); |
|
275 | - for ($i = 1; $i <= $length; ++$i) { |
|
276 | - $label = key($slowTests); |
|
277 | - $time = array_shift($slowTests); |
|
278 | - |
|
279 | - echo sprintf(" %s. %sms to run %s\n", $i, $time, $label); |
|
280 | - } |
|
281 | - } |
|
282 | - |
|
283 | - /** |
|
284 | - * Renders slow test report footer. |
|
285 | - */ |
|
286 | - protected function renderFooter() |
|
287 | - { |
|
288 | - if ($hidden = $this->getHiddenCount($this->slow)) { |
|
289 | - echo sprintf("...and there %s %s more above your threshold hidden from view", $hidden == 1 ? 'is' : 'are', $hidden); |
|
290 | - } |
|
291 | - } |
|
292 | - |
|
293 | - /** |
|
294 | - * Populate options into class internals. |
|
295 | - * |
|
296 | - * @param array $options |
|
297 | - */ |
|
298 | - protected function loadOptions(array $options) |
|
299 | - { |
|
300 | - $this->slowThreshold = isset($options['slowThreshold']) ? $options['slowThreshold'] : 500; |
|
301 | - $this->reportLength = isset($options['reportLength']) ? $options['reportLength'] : 10; |
|
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * Get slow test threshold for given test. A TestCase can override the |
|
306 | - * suite-wide slow threshold by using the annotation @slowThreshold with |
|
307 | - * the threshold value in milliseconds. |
|
308 | - * |
|
309 | - * The following test will only be considered slow when its execution time |
|
310 | - * reaches 5000ms (5 seconds): |
|
311 | - * |
|
312 | - * <code> |
|
313 | - * @slowThreshold 5000 |
|
314 | - * public function testLongRunningProcess() {} |
|
315 | - * </code> |
|
316 | - * |
|
317 | - * @param PHPUnit_Framework_TestCase $test |
|
318 | - * @return int |
|
319 | - */ |
|
320 | - protected function getSlowThreshold(PHPUnit_Framework_TestCase $test) |
|
321 | - { |
|
322 | - $ann = $test->getAnnotations(); |
|
323 | - |
|
324 | - return isset($ann['method']['slowThreshold'][0]) ? $ann['method']['slowThreshold'][0] : $this->slowThreshold; |
|
325 | - } |
|
9 | + /** |
|
10 | + * Internal tracking for test suites. |
|
11 | + * |
|
12 | + * Increments as more suites are run, then decremented as they finish. All |
|
13 | + * suites have been run when returns to 0. |
|
14 | + * |
|
15 | + * @var integer |
|
16 | + */ |
|
17 | + protected $suites = 0; |
|
18 | + |
|
19 | + /** |
|
20 | + * Time in milliseconds at which a test will be considered "slow" and be |
|
21 | + * reported by this listener. |
|
22 | + * |
|
23 | + * @var int |
|
24 | + */ |
|
25 | + protected $slowThreshold; |
|
26 | + |
|
27 | + /** |
|
28 | + * Number of tests to report on for slowness. |
|
29 | + * |
|
30 | + * @var int |
|
31 | + */ |
|
32 | + protected $reportLength; |
|
33 | + |
|
34 | + /** |
|
35 | + * Collection of slow tests. |
|
36 | + * |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + protected $slow = array(); |
|
40 | + |
|
41 | + /** |
|
42 | + * Construct a new instance. |
|
43 | + * |
|
44 | + * @param array $options |
|
45 | + */ |
|
46 | + public function __construct(array $options = array()) |
|
47 | + { |
|
48 | + $this->loadOptions($options); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * An error occurred. |
|
53 | + * |
|
54 | + * @param PHPUnit_Framework_Test $test |
|
55 | + * @param Exception $e |
|
56 | + * @param float $time |
|
57 | + */ |
|
58 | + public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
59 | + { |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * A warning occurred. |
|
64 | + * |
|
65 | + * @param PHPUnit_Framework_Test $test |
|
66 | + * @param PHPUnit_Framework_Warning $e |
|
67 | + * @param float $time |
|
68 | + * @since Method available since Release 5.1.0 |
|
69 | + */ |
|
70 | + public function addWarning(PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, $time) |
|
71 | + { |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * A failure occurred. |
|
76 | + * |
|
77 | + * @param PHPUnit_Framework_Test $test |
|
78 | + * @param PHPUnit_Framework_AssertionFailedError $e |
|
79 | + * @param float $time |
|
80 | + */ |
|
81 | + public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) |
|
82 | + { |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Incomplete test. |
|
87 | + * |
|
88 | + * @param PHPUnit_Framework_Test $test |
|
89 | + * @param Exception $e |
|
90 | + * @param float $time |
|
91 | + */ |
|
92 | + public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
93 | + { |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Risky test. |
|
98 | + * |
|
99 | + * @param PHPUnit_Framework_Test $test |
|
100 | + * @param Exception $e |
|
101 | + * @param float $time |
|
102 | + * @since Method available since Release 4.0.0 |
|
103 | + */ |
|
104 | + public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
105 | + { |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Skipped test. |
|
110 | + * |
|
111 | + * @param PHPUnit_Framework_Test $test |
|
112 | + * @param Exception $e |
|
113 | + * @param float $time |
|
114 | + */ |
|
115 | + public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) |
|
116 | + { |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * A test started. |
|
121 | + * |
|
122 | + * @param PHPUnit_Framework_Test $test |
|
123 | + */ |
|
124 | + public function startTest(PHPUnit_Framework_Test $test) |
|
125 | + { |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * A test ended. |
|
130 | + * |
|
131 | + * @param PHPUnit_Framework_Test $test |
|
132 | + * @param float $time |
|
133 | + */ |
|
134 | + public function endTest(PHPUnit_Framework_Test $test, $time) |
|
135 | + { |
|
136 | + if (!$test instanceof PHPUnit_Framework_TestCase) return; |
|
137 | + |
|
138 | + $time = $this->toMilliseconds($time); |
|
139 | + $threshold = $this->getSlowThreshold($test); |
|
140 | + |
|
141 | + if ($this->isSlow($time, $threshold)) { |
|
142 | + $this->addSlowTest($test, $time); |
|
143 | + } |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * A test suite started. |
|
148 | + * |
|
149 | + * @param PHPUnit_Framework_TestSuite $suite |
|
150 | + */ |
|
151 | + public function startTestSuite(PHPUnit_Framework_TestSuite $suite) |
|
152 | + { |
|
153 | + $this->suites++; |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * A test suite ended. |
|
158 | + * |
|
159 | + * @param PHPUnit_Framework_TestSuite $suite |
|
160 | + */ |
|
161 | + public function endTestSuite(PHPUnit_Framework_TestSuite $suite) |
|
162 | + { |
|
163 | + $this->suites--; |
|
164 | + |
|
165 | + if (0 === $this->suites && $this->hasSlowTests()) { |
|
166 | + arsort($this->slow); // Sort longest running tests to the top |
|
167 | + |
|
168 | + $this->renderHeader(); |
|
169 | + $this->renderBody(); |
|
170 | + $this->renderFooter(); |
|
171 | + } |
|
172 | + } |
|
173 | + |
|
174 | + /** |
|
175 | + * Whether the given test execution time is considered slow. |
|
176 | + * |
|
177 | + * @param int $time Test execution time in milliseconds |
|
178 | + * @param int $slowThreshold Test execution time at which a test should be considered slow (milliseconds) |
|
179 | + * @return bool |
|
180 | + */ |
|
181 | + protected function isSlow($time, $slowThreshold) |
|
182 | + { |
|
183 | + return $time >= $slowThreshold; |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Stores a test as slow. |
|
188 | + * |
|
189 | + * @param PHPUnit_Framework_TestCase $test |
|
190 | + * @param int $time Test execution time in milliseconds |
|
191 | + */ |
|
192 | + protected function addSlowTest(PHPUnit_Framework_TestCase $test, $time) |
|
193 | + { |
|
194 | + $label = $this->makeLabel($test); |
|
195 | + |
|
196 | + $this->slow[$label] = $time; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Whether at least one test has been considered slow. |
|
201 | + * |
|
202 | + * @return bool |
|
203 | + */ |
|
204 | + protected function hasSlowTests() |
|
205 | + { |
|
206 | + return !empty($this->slow); |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * Convert PHPUnit's reported test time (microseconds) to milliseconds. |
|
211 | + * |
|
212 | + * @param float $time |
|
213 | + * @return int |
|
214 | + */ |
|
215 | + protected function toMilliseconds($time) |
|
216 | + { |
|
217 | + return (int) round($time * 1000); |
|
218 | + } |
|
219 | + |
|
220 | + /** |
|
221 | + * Label for describing a test. |
|
222 | + * |
|
223 | + * @param PHPUnit_Framework_TestCase $test |
|
224 | + * @return string |
|
225 | + */ |
|
226 | + protected function makeLabel(PHPUnit_Framework_TestCase $test) |
|
227 | + { |
|
228 | + return sprintf('%s:%s', get_class($test), $test->getName()); |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Calculate number of slow tests to report about. |
|
233 | + * |
|
234 | + * @return int |
|
235 | + */ |
|
236 | + protected function getReportLength() |
|
237 | + { |
|
238 | + return min(count($this->slow), $this->reportLength); |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * Find how many slow tests occurred that won't be shown due to list length. |
|
243 | + * |
|
244 | + * @return int Number of hidden slow tests |
|
245 | + */ |
|
246 | + protected function getHiddenCount() |
|
247 | + { |
|
248 | + $total = count($this->slow); |
|
249 | + $showing = $this->getReportLength($this->slow); |
|
250 | + |
|
251 | + $hidden = 0; |
|
252 | + if ($total > $showing) { |
|
253 | + $hidden = $total - $showing; |
|
254 | + } |
|
255 | + |
|
256 | + return $hidden; |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Renders slow test report header. |
|
261 | + */ |
|
262 | + protected function renderHeader() |
|
263 | + { |
|
264 | + echo sprintf("\n\nYou should really fix these slow tests (>%sms)...\n", $this->slowThreshold); |
|
265 | + } |
|
266 | + |
|
267 | + /** |
|
268 | + * Renders slow test report body. |
|
269 | + */ |
|
270 | + protected function renderBody() |
|
271 | + { |
|
272 | + $slowTests = $this->slow; |
|
273 | + |
|
274 | + $length = $this->getReportLength($slowTests); |
|
275 | + for ($i = 1; $i <= $length; ++$i) { |
|
276 | + $label = key($slowTests); |
|
277 | + $time = array_shift($slowTests); |
|
278 | + |
|
279 | + echo sprintf(" %s. %sms to run %s\n", $i, $time, $label); |
|
280 | + } |
|
281 | + } |
|
282 | + |
|
283 | + /** |
|
284 | + * Renders slow test report footer. |
|
285 | + */ |
|
286 | + protected function renderFooter() |
|
287 | + { |
|
288 | + if ($hidden = $this->getHiddenCount($this->slow)) { |
|
289 | + echo sprintf("...and there %s %s more above your threshold hidden from view", $hidden == 1 ? 'is' : 'are', $hidden); |
|
290 | + } |
|
291 | + } |
|
292 | + |
|
293 | + /** |
|
294 | + * Populate options into class internals. |
|
295 | + * |
|
296 | + * @param array $options |
|
297 | + */ |
|
298 | + protected function loadOptions(array $options) |
|
299 | + { |
|
300 | + $this->slowThreshold = isset($options['slowThreshold']) ? $options['slowThreshold'] : 500; |
|
301 | + $this->reportLength = isset($options['reportLength']) ? $options['reportLength'] : 10; |
|
302 | + } |
|
303 | + |
|
304 | + /** |
|
305 | + * Get slow test threshold for given test. A TestCase can override the |
|
306 | + * suite-wide slow threshold by using the annotation @slowThreshold with |
|
307 | + * the threshold value in milliseconds. |
|
308 | + * |
|
309 | + * The following test will only be considered slow when its execution time |
|
310 | + * reaches 5000ms (5 seconds): |
|
311 | + * |
|
312 | + * <code> |
|
313 | + * @slowThreshold 5000 |
|
314 | + * public function testLongRunningProcess() {} |
|
315 | + * </code> |
|
316 | + * |
|
317 | + * @param PHPUnit_Framework_TestCase $test |
|
318 | + * @return int |
|
319 | + */ |
|
320 | + protected function getSlowThreshold(PHPUnit_Framework_TestCase $test) |
|
321 | + { |
|
322 | + $ann = $test->getAnnotations(); |
|
323 | + |
|
324 | + return isset($ann['method']['slowThreshold'][0]) ? $ann['method']['slowThreshold'][0] : $this->slowThreshold; |
|
325 | + } |
|
326 | 326 | } |
@@ -133,7 +133,9 @@ |
||
133 | 133 | */ |
134 | 134 | public function endTest(PHPUnit_Framework_Test $test, $time) |
135 | 135 | { |
136 | - if (!$test instanceof PHPUnit_Framework_TestCase) return; |
|
136 | + if (!$test instanceof PHPUnit_Framework_TestCase) { |
|
137 | + return; |
|
138 | + } |
|
137 | 139 | |
138 | 140 | $time = $this->toMilliseconds($time); |
139 | 141 | $threshold = $this->getSlowThreshold($test); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (class_exists( 'WP_Image_Editor' ) ) : |
|
3 | +if (class_exists('WP_Image_Editor')) : |
|
4 | 4 | |
5 | 5 | class WP_Image_Editor_Mock extends WP_Image_Editor { |
6 | 6 | |
@@ -9,38 +9,38 @@ discard block |
||
9 | 9 | public static $save_return = array(); |
10 | 10 | |
11 | 11 | // Allow testing of jpeg_quality filter. |
12 | - public function set_mime_type( $mime_type = null ) { |
|
12 | + public function set_mime_type($mime_type = null) { |
|
13 | 13 | $this->mime_type = $mime_type; |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function load() { |
17 | 17 | return self::$load_return; |
18 | 18 | } |
19 | - public static function test( $args = array() ) { |
|
19 | + public static function test($args = array()) { |
|
20 | 20 | return self::$test_return; |
21 | 21 | } |
22 | - public static function supports_mime_type( $mime_type ) { |
|
22 | + public static function supports_mime_type($mime_type) { |
|
23 | 23 | return true; |
24 | 24 | } |
25 | - public function resize( $max_w, $max_h, $crop = false ) { |
|
25 | + public function resize($max_w, $max_h, $crop = false) { |
|
26 | 26 | |
27 | 27 | } |
28 | - public function multi_resize( $sizes ) { |
|
28 | + public function multi_resize($sizes) { |
|
29 | 29 | |
30 | 30 | } |
31 | - public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) { |
|
31 | + public function crop($src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false) { |
|
32 | 32 | |
33 | 33 | } |
34 | - public function rotate( $angle ) { |
|
34 | + public function rotate($angle) { |
|
35 | 35 | |
36 | 36 | } |
37 | - public function flip( $horz, $vert ) { |
|
37 | + public function flip($horz, $vert) { |
|
38 | 38 | |
39 | 39 | } |
40 | - public function save( $destfilename = null, $mime_type = null ) { |
|
40 | + public function save($destfilename = null, $mime_type = null) { |
|
41 | 41 | return self::$save_return; |
42 | 42 | } |
43 | - public function stream( $mime_type = null ) { |
|
43 | + public function stream($mime_type = null) { |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | } |
@@ -1,19 +1,19 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | abstract class WP_Test_REST_TestCase extends WP_UnitTestCase { |
4 | - protected function assertErrorResponse( $code, $response, $status = null ) { |
|
4 | + protected function assertErrorResponse($code, $response, $status = null) { |
|
5 | 5 | |
6 | - if ( is_a( $response, 'WP_REST_Response' ) ) { |
|
6 | + if (is_a($response, 'WP_REST_Response')) { |
|
7 | 7 | $response = $response->as_error(); |
8 | 8 | } |
9 | 9 | |
10 | - $this->assertInstanceOf( 'WP_Error', $response ); |
|
11 | - $this->assertEquals( $code, $response->get_error_code() ); |
|
10 | + $this->assertInstanceOf('WP_Error', $response); |
|
11 | + $this->assertEquals($code, $response->get_error_code()); |
|
12 | 12 | |
13 | - if ( null !== $status ) { |
|
13 | + if (null !== $status) { |
|
14 | 14 | $data = $response->get_error_data(); |
15 | - $this->assertArrayHasKey( 'status', $data ); |
|
16 | - $this->assertEquals( $status, $data['status'] ); |
|
15 | + $this->assertArrayHasKey('status', $data); |
|
16 | + $this->assertEquals($status, $data['status']); |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 | } |
@@ -7,9 +7,10 @@ discard block |
||
7 | 7 | $config_file_path = dirname( dirname( __FILE__ ) ); |
8 | 8 | if ( ! file_exists( $config_file_path . '/wp-tests-config.php' ) ) { |
9 | 9 | // Support the config file from the root of the develop repository. |
10 | - if ( basename( $config_file_path ) === 'phpunit' && basename( dirname( $config_file_path ) ) === 'tests' ) |
|
11 | - $config_file_path = dirname( dirname( $config_file_path ) ); |
|
12 | -} |
|
10 | + if ( basename( $config_file_path ) === 'phpunit' && basename( dirname( $config_file_path ) ) === 'tests' ) { |
|
11 | + $config_file_path = dirname( dirname( $config_file_path ) ); |
|
12 | + } |
|
13 | + } |
|
13 | 14 | $config_file_path .= '/wp-tests-config.php'; |
14 | 15 | |
15 | 16 | /* |
@@ -26,8 +27,9 @@ discard block |
||
26 | 27 | define( 'WP_TESTS_TABLE_PREFIX', $table_prefix ); |
27 | 28 | define( 'DIR_TESTDATA', dirname( __FILE__ ) . '/../data' ); |
28 | 29 | |
29 | -if ( ! defined( 'WP_TESTS_FORCE_KNOWN_BUGS' ) ) |
|
30 | +if ( ! defined( 'WP_TESTS_FORCE_KNOWN_BUGS' ) ) { |
|
30 | 31 | define( 'WP_TESTS_FORCE_KNOWN_BUGS', false ); |
32 | +} |
|
31 | 33 | |
32 | 34 | // Cron tries to make an HTTP request to the blog, which always fails, because tests are run in CLI mode only |
33 | 35 | define( 'DISABLE_WP_CRON', true ); |
@@ -126,8 +128,7 @@ discard block |
||
126 | 128 | if ( strlen( $arg ) > 1 && $arg[0] === '-' && $arg[1] === '-' ) { |
127 | 129 | PHPUnit_Util_Getopt::parseLongOption( substr( $arg, 2 ), $this->longOptions, $options, $argv ); |
128 | 130 | } |
129 | - } |
|
130 | - catch ( PHPUnit_Framework_Exception $e ) { |
|
131 | + } catch ( PHPUnit_Framework_Exception $e ) { |
|
131 | 132 | // Enforcing recognized arguments or correctly formed arguments is |
132 | 133 | // not really the concern here. |
133 | 134 | continue; |
@@ -175,6 +175,6 @@ |
||
175 | 175 | echo 'If this changeset includes changes to HTTP, make sure there are no timeouts.' . PHP_EOL; |
176 | 176 | echo PHP_EOL; |
177 | 177 | } |
178 | - } |
|
178 | + } |
|
179 | 179 | } |
180 | 180 | new WP_PHPUnit_Util_Getopt( $_SERVER['argv'] ); |
@@ -4,11 +4,11 @@ discard block |
||
4 | 4 | */ |
5 | 5 | |
6 | 6 | |
7 | -$config_file_path = dirname( dirname( __FILE__ ) ); |
|
8 | -if ( ! file_exists( $config_file_path . '/wp-tests-config.php' ) ) { |
|
7 | +$config_file_path = dirname(dirname(__FILE__)); |
|
8 | +if (!file_exists($config_file_path.'/wp-tests-config.php')) { |
|
9 | 9 | // Support the config file from the root of the develop repository. |
10 | - if ( basename( $config_file_path ) === 'phpunit' && basename( dirname( $config_file_path ) ) === 'tests' ) |
|
11 | - $config_file_path = dirname( dirname( $config_file_path ) ); |
|
10 | + if (basename($config_file_path) === 'phpunit' && basename(dirname($config_file_path)) === 'tests') |
|
11 | + $config_file_path = dirname(dirname($config_file_path)); |
|
12 | 12 | } |
13 | 13 | $config_file_path .= '/wp-tests-config.php'; |
14 | 14 | |
@@ -18,22 +18,22 @@ discard block |
||
18 | 18 | */ |
19 | 19 | global $wpdb, $current_site, $current_blog, $wp_rewrite, $shortcode_tags, $wp, $phpmailer; |
20 | 20 | |
21 | -if ( !is_readable( $config_file_path ) ) { |
|
22 | - die( "ERROR: wp-tests-config.php is missing! Please use wp-tests-config-sample.php to create a config file.\n" ); |
|
21 | +if (!is_readable($config_file_path)) { |
|
22 | + die("ERROR: wp-tests-config.php is missing! Please use wp-tests-config-sample.php to create a config file.\n"); |
|
23 | 23 | } |
24 | 24 | require_once $config_file_path; |
25 | 25 | |
26 | -define( 'WP_TESTS_TABLE_PREFIX', $table_prefix ); |
|
27 | -define( 'DIR_TESTDATA', dirname( __FILE__ ) . '/../data' ); |
|
26 | +define('WP_TESTS_TABLE_PREFIX', $table_prefix); |
|
27 | +define('DIR_TESTDATA', dirname(__FILE__).'/../data'); |
|
28 | 28 | |
29 | -if ( ! defined( 'WP_TESTS_FORCE_KNOWN_BUGS' ) ) |
|
30 | - define( 'WP_TESTS_FORCE_KNOWN_BUGS', false ); |
|
29 | +if (!defined('WP_TESTS_FORCE_KNOWN_BUGS')) |
|
30 | + define('WP_TESTS_FORCE_KNOWN_BUGS', false); |
|
31 | 31 | |
32 | 32 | // Cron tries to make an HTTP request to the blog, which always fails, because tests are run in CLI mode only |
33 | -define( 'DISABLE_WP_CRON', true ); |
|
33 | +define('DISABLE_WP_CRON', true); |
|
34 | 34 | |
35 | -define( 'WP_MEMORY_LIMIT', -1 ); |
|
36 | -define( 'WP_MAX_MEMORY_LIMIT', -1 ); |
|
35 | +define('WP_MEMORY_LIMIT', -1); |
|
36 | +define('WP_MAX_MEMORY_LIMIT', -1); |
|
37 | 37 | |
38 | 38 | $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; |
39 | 39 | $_SERVER['HTTP_HOST'] = WP_TESTS_DOMAIN; |
@@ -43,62 +43,62 @@ discard block |
||
43 | 43 | |
44 | 44 | $PHP_SELF = $GLOBALS['PHP_SELF'] = $_SERVER['PHP_SELF'] = '/index.php'; |
45 | 45 | |
46 | -if ( "1" == getenv( 'WP_MULTISITE' ) || |
|
47 | - ( defined( 'WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE ) ) { |
|
46 | +if ("1" == getenv('WP_MULTISITE') || |
|
47 | + (defined('WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE)) { |
|
48 | 48 | $multisite = true; |
49 | 49 | } else { |
50 | 50 | $multisite = false; |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Override the PHPMailer |
54 | -require_once( dirname( __FILE__ ) . '/mock-mailer.php' ); |
|
54 | +require_once(dirname(__FILE__).'/mock-mailer.php'); |
|
55 | 55 | $phpmailer = new MockPHPMailer(); |
56 | 56 | |
57 | -system( WP_PHP_BINARY . ' ' . escapeshellarg( dirname( __FILE__ ) . '/install.php' ) . ' ' . escapeshellarg( $config_file_path ) . ' ' . $multisite ); |
|
57 | +system(WP_PHP_BINARY.' '.escapeshellarg(dirname(__FILE__).'/install.php').' '.escapeshellarg($config_file_path).' '.$multisite); |
|
58 | 58 | |
59 | -if ( $multisite ) { |
|
60 | - echo "Running as multisite..." . PHP_EOL; |
|
61 | - define( 'MULTISITE', true ); |
|
62 | - define( 'SUBDOMAIN_INSTALL', false ); |
|
59 | +if ($multisite) { |
|
60 | + echo "Running as multisite...".PHP_EOL; |
|
61 | + define('MULTISITE', true); |
|
62 | + define('SUBDOMAIN_INSTALL', false); |
|
63 | 63 | $GLOBALS['base'] = '/'; |
64 | 64 | } else { |
65 | - echo "Running as single site... To run multisite, use -c tests/phpunit/multisite.xml" . PHP_EOL; |
|
65 | + echo "Running as single site... To run multisite, use -c tests/phpunit/multisite.xml".PHP_EOL; |
|
66 | 66 | } |
67 | -unset( $multisite ); |
|
67 | +unset($multisite); |
|
68 | 68 | |
69 | -require_once dirname( __FILE__ ) . '/functions.php'; |
|
69 | +require_once dirname(__FILE__).'/functions.php'; |
|
70 | 70 | |
71 | 71 | $GLOBALS['_wp_die_disabled'] = false; |
72 | 72 | // Allow tests to override wp_die |
73 | -tests_add_filter( 'wp_die_handler', '_wp_die_handler_filter' ); |
|
73 | +tests_add_filter('wp_die_handler', '_wp_die_handler_filter'); |
|
74 | 74 | |
75 | 75 | // Preset WordPress options defined in bootstrap file. |
76 | 76 | // Used to activate themes, plugins, as well as other settings. |
77 | -if(isset($GLOBALS['wp_tests_options'])) { |
|
78 | - function wp_tests_options( $value ) { |
|
79 | - $key = substr( current_filter(), strlen( 'pre_option_' ) ); |
|
77 | +if (isset($GLOBALS['wp_tests_options'])) { |
|
78 | + function wp_tests_options($value) { |
|
79 | + $key = substr(current_filter(), strlen('pre_option_')); |
|
80 | 80 | return $GLOBALS['wp_tests_options'][$key]; |
81 | 81 | } |
82 | 82 | |
83 | - foreach ( array_keys( $GLOBALS['wp_tests_options'] ) as $key ) { |
|
84 | - tests_add_filter( 'pre_option_'.$key, 'wp_tests_options' ); |
|
83 | + foreach (array_keys($GLOBALS['wp_tests_options']) as $key) { |
|
84 | + tests_add_filter('pre_option_'.$key, 'wp_tests_options'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | 88 | // Load WordPress |
89 | -require_once ABSPATH . '/wp-settings.php'; |
|
89 | +require_once ABSPATH.'/wp-settings.php'; |
|
90 | 90 | |
91 | 91 | // Delete any default posts & related data |
92 | 92 | _delete_all_posts(); |
93 | 93 | |
94 | -require dirname( __FILE__ ) . '/testcase.php'; |
|
95 | -require dirname( __FILE__ ) . '/testcase-rest-api.php'; |
|
96 | -require dirname( __FILE__ ) . '/testcase-xmlrpc.php'; |
|
97 | -require dirname( __FILE__ ) . '/testcase-ajax.php'; |
|
98 | -require dirname( __FILE__ ) . '/testcase-canonical.php'; |
|
99 | -require dirname( __FILE__ ) . '/exceptions.php'; |
|
100 | -require dirname( __FILE__ ) . '/utils.php'; |
|
101 | -require dirname( __FILE__ ) . '/spy-rest-server.php'; |
|
94 | +require dirname(__FILE__).'/testcase.php'; |
|
95 | +require dirname(__FILE__).'/testcase-rest-api.php'; |
|
96 | +require dirname(__FILE__).'/testcase-xmlrpc.php'; |
|
97 | +require dirname(__FILE__).'/testcase-ajax.php'; |
|
98 | +require dirname(__FILE__).'/testcase-canonical.php'; |
|
99 | +require dirname(__FILE__).'/exceptions.php'; |
|
100 | +require dirname(__FILE__).'/utils.php'; |
|
101 | +require dirname(__FILE__).'/spy-rest-server.php'; |
|
102 | 102 | |
103 | 103 | /** |
104 | 104 | * A child class of the PHP test runner. |
@@ -118,16 +118,16 @@ discard block |
||
118 | 118 | 'exclude-group=', |
119 | 119 | 'group=', |
120 | 120 | ); |
121 | - function __construct( $argv ) { |
|
122 | - array_shift( $argv ); |
|
121 | + function __construct($argv) { |
|
122 | + array_shift($argv); |
|
123 | 123 | $options = array(); |
124 | - while ( list( $i, $arg ) = each( $argv ) ) { |
|
124 | + while (list($i, $arg) = each($argv)) { |
|
125 | 125 | try { |
126 | - if ( strlen( $arg ) > 1 && $arg[0] === '-' && $arg[1] === '-' ) { |
|
127 | - PHPUnit_Util_Getopt::parseLongOption( substr( $arg, 2 ), $this->longOptions, $options, $argv ); |
|
126 | + if (strlen($arg) > 1 && $arg[0] === '-' && $arg[1] === '-') { |
|
127 | + PHPUnit_Util_Getopt::parseLongOption(substr($arg, 2), $this->longOptions, $options, $argv); |
|
128 | 128 | } |
129 | 129 | } |
130 | - catch ( PHPUnit_Framework_Exception $e ) { |
|
130 | + catch (PHPUnit_Framework_Exception $e) { |
|
131 | 131 | // Enforcing recognized arguments or correctly formed arguments is |
132 | 132 | // not really the concern here. |
133 | 133 | continue; |
@@ -140,41 +140,41 @@ discard block |
||
140 | 140 | 'external-http' => true, |
141 | 141 | ); |
142 | 142 | |
143 | - foreach ( $options as $option ) { |
|
144 | - switch ( $option[0] ) { |
|
143 | + foreach ($options as $option) { |
|
144 | + switch ($option[0]) { |
|
145 | 145 | case '--exclude-group' : |
146 | - foreach ( $skipped_groups as $group_name => $skipped ) { |
|
147 | - $skipped_groups[ $group_name ] = false; |
|
146 | + foreach ($skipped_groups as $group_name => $skipped) { |
|
147 | + $skipped_groups[$group_name] = false; |
|
148 | 148 | } |
149 | 149 | continue 2; |
150 | 150 | case '--group' : |
151 | - $groups = explode( ',', $option[1] ); |
|
152 | - foreach ( $groups as $group ) { |
|
153 | - if ( is_numeric( $group ) || preg_match( '/^(UT|Plugin)\d+$/', $group ) ) { |
|
154 | - WP_UnitTestCase::forceTicket( $group ); |
|
151 | + $groups = explode(',', $option[1]); |
|
152 | + foreach ($groups as $group) { |
|
153 | + if (is_numeric($group) || preg_match('/^(UT|Plugin)\d+$/', $group)) { |
|
154 | + WP_UnitTestCase::forceTicket($group); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | - foreach ( $skipped_groups as $group_name => $skipped ) { |
|
159 | - if ( in_array( $group_name, $groups ) ) { |
|
160 | - $skipped_groups[ $group_name ] = false; |
|
158 | + foreach ($skipped_groups as $group_name => $skipped) { |
|
159 | + if (in_array($group_name, $groups)) { |
|
160 | + $skipped_groups[$group_name] = false; |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | continue 2; |
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | - $skipped_groups = array_filter( $skipped_groups ); |
|
168 | - foreach ( $skipped_groups as $group_name => $skipped ) { |
|
169 | - echo sprintf( 'Not running %1$s tests. To execute these, use --group %1$s.', $group_name ) . PHP_EOL; |
|
167 | + $skipped_groups = array_filter($skipped_groups); |
|
168 | + foreach ($skipped_groups as $group_name => $skipped) { |
|
169 | + echo sprintf('Not running %1$s tests. To execute these, use --group %1$s.', $group_name).PHP_EOL; |
|
170 | 170 | } |
171 | 171 | |
172 | - if ( ! isset( $skipped_groups['external-http'] ) ) { |
|
172 | + if (!isset($skipped_groups['external-http'])) { |
|
173 | 173 | echo PHP_EOL; |
174 | - echo 'External HTTP skipped tests can be caused by timeouts.' . PHP_EOL; |
|
175 | - echo 'If this changeset includes changes to HTTP, make sure there are no timeouts.' . PHP_EOL; |
|
174 | + echo 'External HTTP skipped tests can be caused by timeouts.'.PHP_EOL; |
|
175 | + echo 'If this changeset includes changes to HTTP, make sure there are no timeouts.'.PHP_EOL; |
|
176 | 176 | echo PHP_EOL; |
177 | 177 | } |
178 | 178 | } |
179 | 179 | } |
180 | -new WP_PHPUnit_Util_Getopt( $_SERVER['argv'] ); |
|
180 | +new WP_PHPUnit_Util_Getopt($_SERVER['argv']); |