WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/02/2014 03:55:51 PM (5 years ago)
Author:
wonderboymusic
Message:

In activate_plugin(), do not re-run the activation routine for already-active network-wide plugins.

Adds unit test.

Props jbrinley.
Fixes #28651.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ms.php

    r29747 r29818  
    302302    }
    303303
     304    /**
     305     * @ticket 28651
     306     */
     307    function test_duplicate_network_active_plugin() {
     308        $path = "hello.php";
     309        $mock = new MockAction();
     310        add_action( 'activate_' . $path, array ( $mock, 'action' ) );
     311
     312        // should activate on the first try
     313        activate_plugin( $path, '', true );
     314        $active_plugins = wp_get_active_network_plugins();
     315        $this->assertCount( 1, $active_plugins );
     316        $this->assertEquals( 1, $mock->get_call_count() );
     317
     318        // should do nothing on the second try
     319        activate_plugin( $path, '', true );
     320        $active_plugins = wp_get_active_network_plugins();
     321        $this->assertCount( 1, $active_plugins );
     322        $this->assertEquals( 1, $mock->get_call_count() );
     323
     324        remove_action( 'activate_' . $path, array ( $mock, 'action' ) );
     325    }
     326
    304327    function _helper_deactivate_hook() {
    305328        $this->plugin_hook_count++;
Note: See TracChangeset for help on using the changeset viewer.