@@ -114,6 +114,7 @@ function tearDown() {
114
114
$ this ->wp_customize = null ;
115
115
unset( $ GLOBALS ['wp_customize ' ] );
116
116
unset( $ GLOBALS ['wp_scripts ' ] );
117
+ $ this ->filtered_snapshot = null ;
117
118
parent ::tearDown ();
118
119
}
119
120
@@ -324,24 +325,36 @@ function test_saved() {
324
325
) );
325
326
}
326
327
328
+ /**
329
+ * Snapshot object passed in customize_snapshot_save filter.
330
+ *
331
+ * @var Customize_Snapshot
332
+ */
333
+ protected $ filtered_snapshot ;
334
+
327
335
/**
328
336
* Test that the snapshot object is passed as the second filter param.
329
337
*
330
338
* @see Customize_Snapshot::save()
331
339
*/
332
340
function test_filter_customize_snapshot_save () {
333
341
$ manager = new Customize_Snapshot_Manager ( $ this ->plugin );
342
+ $ manager ->ensure_customize_manager ();
334
343
$ manager ->init ();
335
344
336
345
$ snapshot = new Customize_Snapshot ( $ manager , self ::UUID );
337
346
338
- add_filter ( 'customize_snapshot_save ' , function ( $ data , $ test_snapshot ) use ( $ snapshot ) {
339
- $ this ->assertEquals ( $ test_snapshot , $ snapshot );
347
+ $ that = $ this ; // For PHP 5.3.
348
+ add_filter ( 'customize_snapshot_save ' , function ( $ data , $ test_snapshot ) use ( $ that ) {
349
+ $ that ->filtered_snapshot = $ test_snapshot ;
350
+ return $ data ;
340
351
}, 10 , 2 );
341
352
342
353
$ snapshot ->save ( array (
343
354
'uuid ' => self ::UUID ,
344
355
'data ' => array ( 'foo ' => array ( 'value ' => 'bar ' ) ),
345
356
) );
357
+
358
+ $ this ->assertEquals ( $ snapshot , $ this ->filtered_snapshot );
346
359
}
347
360
}
0 commit comments