-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathunit-test.php
128 lines (114 loc) · 2.5 KB
/
unit-test.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/**
* Class \Test\Shared
*
* @package WPDiscourse
*/
namespace WPDiscourse\Test;
use WPDiscourse\Test\Logging;
use WPDiscourse\Test\RemotePost;
/**
* Base class for WPDiscourse unit tests
*/
class UnitTest extends \WP_UnitTestCase {
use Logging;
use RemotePost;
/**
* Connection options.
*
* @access public
* @var object
*/
public static $connection_options;
/**
* Publish options.
*
* @access public
* @var object
*/
public static $publish_options;
/**
* Log options.
*
* @access public
* @var object
*/
public static $log_options;
/**
* Plugin options.
*
* @access public
* @var object
*/
public static $plugin_options;
/**
* WP_Post attributes.
*
* @access public
* @var object
*/
public static $post_atts;
/**
* Params used in remote posts.
*
* @access public
* @var object
*/
public static $remote_post_params;
/**
* URL of mock discourse instance.
*
* @access public
* @var string
*/
public static $discourse_url;
/**
* Setup test class
*/
public static function setUpBeforeClass(): void {
self::initialize_shared_variables();
}
/**
* Setup each test.
*/
public function setUp(): void {
}
/**
* Teardown each test.
*/
public function tearDown(): void {
$this->clear_logs();
remove_all_filters( 'pre_http_request' );
\Mockery::close();
}
/**
* Initialize shared tests.
*/
public static function initialize_shared_variables() {
self::$discourse_url = 'http://meta.discourse.org';
self::$connection_options = array(
'url' => self::$discourse_url,
'api-key' => '1235567',
'publish-username' => 'angus',
);
self::$publish_options = array(
'allowed_post_types' => array( 'post' ),
'publish-category-update' => 1,
);
self::$log_options = array(
'logs-enabled' => 1,
);
self::$plugin_options = array_merge( self::$connection_options, self::$publish_options, self::$log_options );
self::$post_atts = array(
'post_author' => 0,
'post_content' => 'This is a new post',
'post_title' => 'This is the post title',
'meta_input' => array(
'wpdc_auto_publish_overridden' => 0,
'publish_to_discourse' => 1,
'publish_post_category' => 1,
),
'post_status' => 'publish',
);
}
}