Test Setup Failed
Pull Request — master (#216)
by Viruthagiri
05:38
created

SearchWithKeyword   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 0
cbo 1
dl 0
loc 36
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testSearchWithKeyword() 0 23 2
A tearDown() 0 4 1
1
<?php
2
class SearchWithKeyword extends WP_UnitTestCase
3
{
4
    public function setUp()
5
    {
6
        parent::setUp();
7
    }
8
9
    public function testSearchWithKeyword()
10
    {
11
        $_REQUEST['geodir_search'] = 1;
12
        $query_args = array(
13
            'post_status' => 'publish',
14
            'post_type' => 'gd_place',
15
            'posts_per_page' => 1,
16
            's' => 'Longwood Gardens'
17
        );
18
19
        $all_posts = new WP_Query( $query_args );
20
21
        $total_posts = $all_posts->found_posts;
22
23
        $this->assertTrue(is_int((int) $total_posts));
24
25
        $title = null;
26
        while ( $all_posts->have_posts() ) : $all_posts->the_post();
27
            $title = get_the_title();
28
        endwhile;
29
30
        $this->assertEquals($title, 'Longwood Gardens');
31
    }
32
33
    public function tearDown()
34
    {
35
        parent::tearDown();
36
    }
37
}
38
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...