You are here

class PackageManagementTest in MongoDB 7

Same name in this branch
  1. 7 src/Tests/PackageManagementTest.php \Drupal\mongodb\Tests\PackageManagementTest
  2. 7 mongodb_watchdog/src/Tests/PackageManagementTest.php \Drupal\mongodb_watchdog\Tests\PackageManagementTest

Test package management hooks.

This test is about install/enable/disable/uninstall operations.

@group MongoDB

Hierarchy

  • class \Drupal\mongodb_watchdog\Tests\PackageManagementTest extends \Drupal\mongodb_watchdog\Tests\DrupalWebTestCase

Expanded class hierarchy of PackageManagementTest

File

mongodb_watchdog/src/Tests/PackageManagementTest.php, line 12

Namespace

Drupal\mongodb_watchdog\Tests
View source
class PackageManagementTest extends \DrupalWebTestCase {
  const MODULE = 'mongodb_watchdog';
  const DRIVER = 'mongodb';

  /**
   * Override the default "standard" profile for this test, to cut testing time.
   *
   * @var string
   */
  protected $profile = 'testing';

  /**
   * {@inheritdoc}
   */
  public static function getInfo() {
    return array(
      'name' => 'MongoDB watchdog package management test',
      'description' => 'install/enable/disable/uninstall operations.',
      'group' => 'MongoDB: Watchdog',
    );
  }

  /**
   * {@inheritdoc}
   */
  public function setUp() {

    // Support using the MongoDB cache.
    drupal_flush_all_caches();
    parent::setUp();
  }

  /**
   * {@inheritdoc}
   */
  public function tearDown() {

    // Support using the MongoDB cache.
    drupal_flush_all_caches();
    parent::tearDown();
  }

  /**
   * Test successful execution of hook_uninstall() with Mongodb disabled.
   *
   * This cannot be checked by API calls, because the missing functions will
   * still be loaded in PHP, hence the need to use the UI to trigger page
   * reloads.
   */
  public function testUninstall() {
    module_enable([
      static::DRIVER,
      static::MODULE,
    ]);
    $this
      ->pass('Successfully enabled driver and watchdog.module.');
    module_disable([
      static::MODULE,
      static::DRIVER,
    ]);
    $admin = $this
      ->drupalCreateUser([
      'administer modules',
    ]);
    $this
      ->drupalLogin($admin);
    $modules = [
      'uninstall[mongodb_watchdog]' => 1,
    ];
    $this
      ->drupalPost('admin/modules/uninstall', $modules, t('Uninstall'));
    $this
      ->assertResponse(200, 'Module uninstall form succeeded');
    $this
      ->drupalPost(NULL, [], t('Uninstall'));

    // Broken core : this should NOT be a 200, but actually is.

    /*
        $this->assertResponse(200, 'Module uninstall confirmation succeeded');
    */
    $this
      ->assertText(t('The selected modules have been uninstalled.'), 'Module uninstall confirmation succeeded.');
    $this
      ->pass('Successfully uninstalled watchdog module.');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PackageManagementTest::$profile protected property Override the default "standard" profile for this test, to cut testing time.
PackageManagementTest::DRIVER constant
PackageManagementTest::getInfo public static function
PackageManagementTest::MODULE constant
PackageManagementTest::setUp public function
PackageManagementTest::tearDown public function
PackageManagementTest::testUninstall public function Test successful execution of hook_uninstall() with Mongodb disabled.