Skip to content

Commit

Permalink
updated - test name
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveJonesDev committed Jun 5, 2024
1 parent c9c64ab commit c75f244
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions tests/phpunit/TestPluginTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/**
* Class EDECU_Plugin_Test
*
* @package Enable_Contributor_Uploads
*/

use EqualizeDigital\EnableContributorUploads\Plugin;

/**
* Plugin test case.
*/
class TestPluginTest extends WP_UnitTestCase {

/**
* Plugin instance.
*
* @var Plugin
*/
private $plugin;

/**
* Test setup.
*/
public function setUp(): void {
parent::setUp();
$this->plugin = new Plugin();
}

/**
* Test teardown.
*/
public function tearDown(): void {
parent::tearDown();
unset( $this->plugin );
}

/**
* Test initialization of the plugin.
*/
public function test_init() {
$this->plugin->init();
$this->assertNotNull( $this->plugin, 'Plugin should be initialized.' );
}

/**
* Test plugin activation.
*
* Activating the plugin should add the 'upload_files' capability to the 'contributor' role.
*/
public function test_activate() {
$this->plugin->activate();
$contributor = get_role( 'contributor' );
$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() {
$this->plugin->activate();
$this->plugin->deactivate();
$contributor = get_role( 'contributor' );
$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() {
Plugin::uninstall();
$contributor = get_role( 'contributor' );
$this->assertFalse( $contributor->has_cap( 'upload_files' ), 'Contributor role should not have the upload_files capability after uninstallation' );
}
}

0 comments on commit c75f244

Please sign in to comment.