Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit 7110036

Browse files
committed
Fix PHP 5.3 compat and ensure that filter actually runs
1 parent d22d95c commit 7110036

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tests/php/test-class-customize-snapshot.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ function tearDown() {
114114
$this->wp_customize = null;
115115
unset( $GLOBALS['wp_customize'] );
116116
unset( $GLOBALS['wp_scripts'] );
117+
$this->filtered_snapshot = null;
117118
parent::tearDown();
118119
}
119120

@@ -324,24 +325,36 @@ function test_saved() {
324325
) );
325326
}
326327

328+
/**
329+
* Snapshot object passed in customize_snapshot_save filter.
330+
*
331+
* @var Customize_Snapshot
332+
*/
333+
protected $filtered_snapshot;
334+
327335
/**
328336
* Test that the snapshot object is passed as the second filter param.
329337
*
330338
* @see Customize_Snapshot::save()
331339
*/
332340
function test_filter_customize_snapshot_save() {
333341
$manager = new Customize_Snapshot_Manager( $this->plugin );
342+
$manager->ensure_customize_manager();
334343
$manager->init();
335344

336345
$snapshot = new Customize_Snapshot( $manager, self::UUID );
337346

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;
340351
}, 10, 2 );
341352

342353
$snapshot->save( array(
343354
'uuid' => self::UUID,
344355
'data' => array( 'foo' => array( 'value' => 'bar' ) ),
345356
) );
357+
358+
$this->assertEquals( $snapshot, $this->filtered_snapshot );
346359
}
347360
}

0 commit comments

Comments
 (0)