@@ -142,126 +142,6 @@ public function test_file_import( $file, $content, $series ) {
142
142
$ this ->assertEquals ( $ series_new , $ series );
143
143
}
144
144
145
- /**
146
- * Testing editor feature.
147
- *
148
- * @access public
149
- * @dataProvider editorDataProvider
150
- */
151
- public function test_pro_editor ( $ data , $ content ) {
152
- if ( ! defined ( 'VISUALIZER_PRO_VERSION ' ) ) {
153
- $ this ->markTestSkipped ( 'PRO not installed/available, skipping test ' );
154
- }
155
-
156
- $ this ->create_chart ();
157
- $ this ->_setRole ( 'administrator ' );
158
-
159
- $ _POST = array (
160
- 'chart_data ' => $ data ,
161
- );
162
- $ _GET = array (
163
- 'nonce ' => wp_create_nonce (),
164
- 'chart ' => $ this ->chart ,
165
- );
166
- $ _FILES = array ();
167
-
168
- // swallow the output
169
- ob_start ();
170
- try {
171
- $ this ->_handleAjax ( 'visualizer-upload-data ' );
172
- } catch ( WPAjaxDieContinueException $ e ) {
173
- // We expected this, do nothing.
174
- } catch ( WPAjaxDieStopException $ ee ) {
175
- // We expected this, do nothing.
176
- }
177
- ob_end_clean ();
178
-
179
- $ chart = get_post ( $ this ->chart );
180
- $ content_new = $ chart ->post_content ;
181
-
182
- $ this ->assertEquals ( $ content_new , serialize ( $ content ) );
183
- }
184
-
185
- /**
186
- * Testing fetch from chat feature. We only need to test fetching, because we already have a test case for uploading data
187
- *
188
- * @access public
189
- */
190
- public function test_pro_fetch_from_chart () {
191
- if ( ! defined ( 'VISUALIZER_PRO_VERSION ' ) ) {
192
- $ this ->markTestSkipped ( 'PRO not installed/available, skipping test ' );
193
- }
194
-
195
- $ this ->create_chart ();
196
- $ this ->_setRole ( 'administrator ' );
197
-
198
- $ _GET = array (
199
- 'nonce ' => wp_create_nonce (),
200
- 'chart_id ' => $ this ->chart ,
201
- );
202
-
203
- // swallow the output
204
- ob_start ();
205
- try {
206
- $ this ->_handleAjax ( 'visualizer-fetch-data ' );
207
- } catch ( WPAjaxDieContinueException $ e ) {
208
- // We expected this, do nothing.
209
- } catch ( WPAjaxDieStopException $ ee ) {
210
- // We expected this, do nothing.
211
- }
212
- ob_end_clean ();
213
-
214
- $ response = json_decode ( $ this ->_last_response );
215
- $ this ->assertInternalType ( 'object ' , $ response );
216
- $ this ->assertObjectHasAttribute ( 'success ' , $ response );
217
- $ this ->assertObjectHasAttribute ( 'data ' , $ response );
218
- $ this ->assertTrue ( $ response ->success );
219
- }
220
-
221
- /**
222
- * Provide the "edited" data
223
- *
224
- * @access public
225
- */
226
- public function editorDataProvider () {
227
- $ data = array ();
228
- $ file = VISUALIZER_ABSPATH . DIRECTORY_SEPARATOR . 'samples ' . DIRECTORY_SEPARATOR . 'line.csv ' ;
229
- list ($ content , $ series ) = $ this ->parseFile ( $ file , 10 );
230
-
231
- if ( ($ handle = fopen ( $ file , 'r ' )) !== false ) {
232
- $ row = 0 ;
233
- while ( ($ line = fgetcsv ( $ handle , 0 , VISUALIZER_CSV_DELIMITER , VISUALIZER_CSV_ENCLOSURE )) !== false ) {
234
- if ( $ row ++ <= 1 ) {
235
- $ cols = count ( $ line );
236
- $ datum = array ();
237
- for ( $ col = 0 ; $ col < $ cols ; $ col ++ ) {
238
- $ datum [] = '" ' . $ line [ $ col ] . '" ' ;
239
- }
240
- } else {
241
- $ cols = count ( $ line );
242
- $ datum = array ();
243
- for ( $ col = 0 ; $ col < $ cols ; $ col ++ ) {
244
- if ( is_numeric ( $ line [ $ col ] ) ) {
245
- // multiply all numbers by 10
246
- $ datum [] = $ line [ $ col ] * 10 ;
247
- } else {
248
- $ datum [] = '" ' . $ line [ $ col ] . '" ' ;
249
- }
250
- }
251
- }
252
- $ data [] = $ datum ;
253
- }
254
- }
255
-
256
- $ csv = array ();
257
- foreach ( $ data as $ row ) {
258
- $ csv [] = '[ ' . implode ( ', ' , $ row ) . '] ' ;
259
- }
260
- $ csv = '[ ' . implode ( ', ' , $ csv ) . '] ' ;
261
- return array (
262
- array ( $ csv , $ content ),
263
- );
264
- }
265
145
/**
266
146
* Provide the fileURL for uploading the file
267
147
*
0 commit comments