-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathPluginTest.php
More file actions
214 lines (141 loc) · 4.37 KB
/
PluginTest.php
File metadata and controls
214 lines (141 loc) · 4.37 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?php
/**
* Tests for the base plugin class.
*
* @see \SkyVerge\WooCommerce\PluginFramework\v6_0_2\SV_WC_Plugin
*/
class PluginTest extends \Codeception\TestCase\WPTestCase {
/** @var \IntegrationTester */
protected $tester;
/** @var \SkyVerge\WooCommerce\TestPlugin\Plugin instance */
protected $plugin;
protected function _before() {
}
protected function _after() {
}
/** Tests *********************************************************************************************************/
/**
* Tests get_id.
*/
public function test_get_id() {
$this->assertEquals( 'test_plugin', $this->get_plugin()->get_id() );
}
/**
* Tests get_id_dasherized.
*/
public function test_get_id_dasherized() {
$this->assertEquals( 'test-plugin', $this->get_plugin()->get_id_dasherized() );
}
/**
* Tests get_version.
*/
public function test_get_version() {
$this->assertEquals( '1.0.0', $this->get_plugin()->get_version() );
}
/**
* Tests get_plugin_file.
*/
public function test_get_plugin_file() {
$this->assertEquals( 'test-plugin/test-plugin.php', $this->get_plugin()->get_plugin_file() );
}
/**
* Tests get_plugin_path.
*/
public function test_get_plugin_path() {
$path = $this->get_plugin()->get_plugin_path();
$this->assertStringEndsWith( 'wp-content/plugins/test-plugin', $path );
$this->assertStringStartsNotWith( 'http', $path );
}
/**
* Tests get_plugin_url.
*/
public function test_get_plugin_url() {
$url = $this->get_plugin()->get_plugin_url();
$this->assertStringEndsWith( 'wp-content/plugins/test-plugin', $url );
$this->assertStringStartsWith( 'http', $url );
}
/**
* Tests get_woocommerce_uploads_path.
*/
public function test_get_woocommerce_uploads_path() {
$path = $this->get_plugin()->get_woocommerce_uploads_path();
$this->assertStringEndsWith( 'wp-content/uploads/woocommerce_uploads', $path );
$this->assertStringStartsNotWith( 'http', $path );
}
/**
* Tests get_framework_file.
*/
public function test_get_framework_file() {
$this->assertStringEndsWith( 'class-sv-wc-plugin.php', $this->get_plugin()->get_framework_file() );
}
/**
* Tests get_framework_path.
*/
public function test_get_framework_path() {
$path = $this->get_plugin()->get_framework_path();
$this->assertStringEndsWith( 'vendor/skyverge/wc-plugin-framework/woocommerce', $path );
$this->assertStringStartsNotWith( 'http', $path );
}
/**
* Tests get_framework_assets_url.
*/
public function test_get_framework_assets_url() {
$url = $this->get_plugin()->get_framework_assets_url();
$this->assertStringEndsWith( 'vendor/skyverge/wc-plugin-framework/woocommerce/assets', $url );
$this->assertStringStartsWith( 'http', $url );
}
/**
* Tests get_framework_assets_path.
*/
public function test_get_framework_assets_path() {
$path = $this->get_plugin()->get_framework_assets_path();
$this->assertStringEndsWith( 'vendor/skyverge/wc-plugin-framework/woocommerce/assets', $path );
$this->assertStringStartsNotWith( 'http', $path );
}
/**
* Tests get_dependency_handler.
*/
public function test_get_dependency_handler() {
$this->assertInstanceOf( '\SkyVerge\WooCommerce\PluginFramework\v6_0_2\SV_WC_Plugin_Dependencies', $this->get_plugin()->get_dependency_handler() );
}
/**
* Tests get_lifecycle_handler.
*/
public function test_get_lifecycle_handler() {
$this->assertInstanceOf( '\SkyVerge\WooCommerce\PluginFramework\v6_0_2\Plugin\Lifecycle', $this->get_plugin()->get_lifecycle_handler() );
}
/**
* Tests is_plugin_active()
*
* @param mixed $plugin plugin name
* @param bool $expected the expected return value
*
* @dataProvider provider_is_plugin_active
*/
public function test_is_plugin_active( $plugin, $expected ) {
$this->assertEquals( $expected, $this->get_plugin()->is_plugin_active( $plugin ) );
}
/**
* Provider for test_is_plugin_active()
*
* @return array
*/
public function provider_is_plugin_active() {
return [
[ 'woocommerce', false ],
[ 'woocommerce.php', true ],
];
}
/** Helper methods ************************************************************************************************/
/**
* Gets the plugin instance.
*
* @return \SkyVerge\WooCommerce\TestPlugin\Plugin
*/
protected function get_plugin() {
if ( null === $this->plugin ) {
$this->plugin = sv_wc_test_plugin();
}
return $this->plugin;
}
}