/**
  * Test enqueue preview scripts.
  *
  * @see Customize_Snapshot_Manager::enqueue_preview_scripts()
  */
 function test_enqueue_preview_scripts()
 {
     $manager = new Customize_Snapshot_Manager($this->plugin);
     $manager->ensure_customize_manager();
     $manager->init();
     $handle = 'customize-snapshots-preview';
     $this->assertFalse(wp_scripts()->query($handle, 'enqueued'));
     $this->assertFalse(wp_styles()->query($handle, 'enqueued'));
     $manager->enqueue_preview_scripts();
     $this->assertTrue(wp_scripts()->query($handle, 'enqueued'));
     $this->assertTrue(wp_styles()->query($handle, 'enqueued'));
     $after = wp_scripts()->get_data($handle, 'after');
     $this->assertNotEmpty($after);
     $this->assertContains('CustomizeSnapshotsPreview', join('', $after));
 }
コード例 #2
0
 /**
  * Test that the snapshot object is passed as the second filter param.
  *
  * @see Customize_Snapshot::save()
  */
 function test_filter_customize_snapshot_save()
 {
     $manager = new Customize_Snapshot_Manager($this->plugin);
     $manager->ensure_customize_manager();
     $manager->init();
     $snapshot = new Customize_Snapshot($manager, self::UUID);
     $that = $this;
     // For PHP 5.3.
     add_filter('customize_snapshot_save', function ($data, $test_snapshot) use($that) {
         $that->filtered_snapshot = $test_snapshot;
         return $data;
     }, 10, 2);
     $snapshot->save(array('uuid' => self::UUID, 'data' => array('foo' => array('value' => 'bar'))));
     $this->assertEquals($snapshot, $this->filtered_snapshot);
 }