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

Commit

Permalink
Add test for enqueue_frontend_scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Aug 7, 2016
1 parent c1ce097 commit 8bf8be2
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions tests/php/test-class-customize-snapshot-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,22 @@ function setUp() {
}
}

/**
* Clean up global scope.
*/
function clean_up_global_scope() {
unset( $GLOBALS['wp_scripts'] );
unset( $GLOBALS['wp_styles'] );
parent::clean_up_global_scope();
}

/**
* Tear down.
*/
function tearDown() {
$this->wp_customize = null;
$this->manager = null;
unset( $GLOBALS['wp_customize'] );
unset( $GLOBALS['wp_scripts'] );
unset( $GLOBALS['screen'] );
$_REQUEST = array();
parent::tearDown();
Expand Down Expand Up @@ -342,18 +350,40 @@ function test_encode_json() {
}

/**
* Test enqueue scripts.
* Test enqueue controls scripts.
*
* @see Customize_Snapshot_Manager::enqueue_controls_scripts()
*/
function test_enqueue_scripts() {
function test_enqueue_controls_scripts() {
$this->plugin->register_scripts( wp_scripts() );
$this->plugin->register_styles( wp_styles() );
$manager = new Customize_Snapshot_Manager( $this->plugin );
$manager->init();
$manager->enqueue_controls_scripts();
$this->assertTrue( wp_script_is( $this->plugin->slug, 'enqueued' ) );
$this->assertTrue( wp_style_is( $this->plugin->slug, 'enqueued' ) );
$this->assertTrue( wp_script_is( 'customize-snapshots', 'enqueued' ) );
$this->assertTrue( wp_style_is( 'customize-snapshots', 'enqueued' ) );
}

/**
* Test enqueue frontend scripts.
*
* @see Customize_Snapshot_Manager::enqueue_frontend_scripts()
*/
function test_enqueue_frontend_scripts() {
$this->plugin->register_scripts( wp_scripts() );
$this->plugin->register_styles( wp_styles() );
$manager = new Customize_Snapshot_Manager( $this->plugin );
$manager->init();
$this->assertFalse( wp_script_is( 'customize-snapshots-frontend', 'enqueued' ) );
$manager->enqueue_frontend_scripts();
$this->assertFalse( wp_script_is( 'customize-snapshots-frontend', 'enqueued' ) );

$_REQUEST['customize_snapshot_uuid'] = self::UUID;
$manager = new Customize_Snapshot_Manager( $this->plugin );
$manager->init();
$this->assertFalse( wp_script_is( 'customize-snapshots-frontend', 'enqueued' ) );
$manager->enqueue_frontend_scripts();
$this->assertTrue( wp_script_is( 'customize-snapshots-frontend', 'enqueued' ) );
}

/**
Expand Down

0 comments on commit 8bf8be2

Please sign in to comment.