|
1
|
|
|
<?php |
|
2
|
|
|
class AddReview extends WP_UnitTestCase |
|
3
|
|
|
{ |
|
4
|
|
|
public function setUp() |
|
5
|
|
|
{ |
|
6
|
|
|
parent::setUp(); |
|
7
|
|
|
wp_set_current_user(1); |
|
8
|
|
|
} |
|
9
|
|
|
|
|
10
|
|
|
public function testAddReview() |
|
11
|
|
|
{ |
|
12
|
|
|
$time = current_time('mysql'); |
|
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); |
|
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
|
|
|
); |
|
49
|
|
|
|
|
50
|
|
|
$comment_id = wp_insert_comment($data); |
|
51
|
|
|
|
|
52
|
|
|
$_REQUEST['geodir_overallrating'] = 5.0; |
|
53
|
|
|
geodir_save_rating($comment_id); |
|
54
|
|
|
|
|
55
|
|
|
$this->assertTrue(is_int($comment_id)); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public function tearDown() |
|
59
|
|
|
{ |
|
60
|
|
|
parent::tearDown(); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
?> |
|
|
|
|
|
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.