Skip to content

Commit

Permalink
removed - load_plugin_textdomain method and test
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveJonesDev committed Mar 4, 2024
1 parent b0e1512 commit e4500e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
8 changes: 0 additions & 8 deletions inc/class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function __construct() {
public function init() {
register_activation_hook( __FILE__, array( $this, 'activate' ) );
register_deactivation_hook( __FILE__, array( $this, 'deactivate' ) );
add_action( 'init', array( $this, 'load_textdomain' ) );
}

/**
Expand All @@ -56,13 +55,6 @@ public function deactivate() {
}
}

/**
* Load the plugin text domain for translation.
*/
public function load_textdomain() {
load_plugin_textdomain( 'enable-contributor-uploads', false, basename( __DIR__ ) . '/languages' );
}

/**
* Handles tasks to perform upon plugin uninstallation.
*
Expand Down
27 changes: 6 additions & 21 deletions tests/phpunit/test-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,55 +39,40 @@ public function tearDown(): void {
* Test initialization of the plugin.
*/
public function test_init() {
// Simulate the plugin initialization.
$this->plugin->init();

// Assert that the textdomain is loaded.
$this->assertTrue( is_textdomain_loaded( 'enable-contributor-uploads' ), 'Text domain should be loaded' );
}

/**
* Test plugin activation.
*
* Activating the plugin should add the 'upload_files' capability to the 'contributor' role.
*/
public function test_activate() {
// Activate the plugin.
$this->plugin->activate();

// Retrieve the 'contributor' role.
$contributor = get_role( 'contributor' );

// Assert that 'upload_files' capability is added to 'contributor' role.
$this->assertTrue( $contributor->has_cap( 'upload_files' ), 'Contributor role should have the upload_files capability after activation' );
}

/**
* Test plugin deactivation.
*
* Deactivating the plugin should remove the 'upload_files' capability from the 'contributor' role.
*/
public function test_deactivate() {
// First, activate the plugin to ensure 'contributor' has the 'upload_files' capability.
$this->plugin->activate();

// Then, deactivate the plugin.
$this->plugin->deactivate();

// Retrieve the 'contributor' role again.
$contributor = get_role( 'contributor' );

// Assert that 'upload_files' capability is removed from 'contributor' role.
$this->assertFalse( $contributor->has_cap( 'upload_files' ), 'Contributor role should not have the upload_files capability after deactivation' );
}

/**
* Test plugin uninstallation.
*
* Uninstalling the plugin should remove the 'upload_files' capability from the 'contributor' role.
*/
public function test_uninstall() {
// Simulate plugin uninstallation.
Plugin::uninstall();

// Retrieve the 'contributor' role.
$contributor = get_role( 'contributor' );

// Assert that 'upload_files' capability is removed from 'contributor' role.
$this->assertFalse( $contributor->has_cap( 'upload_files' ), 'Contributor role should not have the upload_files capability after uninstallation' );
}
}

0 comments on commit e4500e6

Please sign in to comment.