Projet

Général

Profil

Révision 6b24a280

Ajouté par Assos Assos il y a presque 4 ans

-a

Voir les différences:

drupal7/modules/comment/comment.test
6 6
 */
7 7

  
8 8
class CommentHelperCase extends DrupalWebTestCase {
9
  protected $super_user;
9 10
  protected $admin_user;
10 11
  protected $web_user;
11 12
  protected $node;
......
19 20
    parent::setUp($modules);
20 21

  
21 22
    // Create users and test node.
23
    $this->super_user = $this->drupalCreateUser(array('access administration pages', 'administer modules'));
22 24
    $this->admin_user = $this->drupalCreateUser(array('administer content types', 'administer comments', 'administer blocks', 'administer actions', 'administer fields'));
23 25
    $this->web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'create article content', 'edit own comments'));
24 26
    $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->uid));
......
2264 2266
    $this->assertFalse(comment_load($comment->id), 'The comment could not be loaded after the node was deleted.');
2265 2267
  }
2266 2268
}
2269

  
2270
/**
2271
 * Tests uninstalling the comment module.
2272
 */
2273
class CommentUninstallTestCase extends CommentHelperCase {
2274

  
2275
  public static function getInfo() {
2276
    return array(
2277
      'name' => 'Comment module uninstallation',
2278
      'description' => 'Tests that the comments module can be properly uninstalled.',
2279
      'group' => 'Comment',
2280
    );
2281
  }
2282

  
2283
  function testCommentUninstall() {
2284
    $this->drupalLogin($this->super_user);
2285

  
2286
    // Disable comment module.
2287
    $edit['modules[Core][comment][enable]'] = FALSE;
2288
    $this->drupalPost('admin/modules', $edit, t('Save configuration'));
2289
    $this->assertText(t('The configuration options have been saved.'), 'Comment module was disabled.');
2290

  
2291
    // Uninstall comment module.
2292
    $edit = array('uninstall[comment]' => 'comment');
2293
    $this->drupalPost('admin/modules/uninstall', $edit, t('Uninstall'));
2294
    $this->drupalPost(NULL, NULL, t('Uninstall'));
2295
    $this->assertText(t('The selected modules have been uninstalled.'), 'Comment module was uninstalled.');
2296

  
2297
    // Run cron and clear field cache so that comment fields and instances
2298
    // marked for deletion are actually removed.
2299
    $this->cronRun();
2300
    field_cache_clear();
2301

  
2302
    // Verify that comment fields have been removed.
2303
    $all_fields = array_keys(field_info_field_map());
2304
    $this->assertFalse(in_array('comment_body', $all_fields), 'Comment fields were removed by uninstall.');
2305

  
2306
    // Verify that comment field instances have been removed (or at least marked
2307
    // for deletion).
2308
    // N.B. field_read_instances does an INNER JOIN on field_config so if the
2309
    // comment_body row has been removed successfully from there no instances
2310
    // will be returned, but that does not guarantee that no rows are left over
2311
    // in the field_config_instance table.
2312
    $count = db_select('field_config_instance', 'fci')
2313
      ->condition('entity_type', 'comment')
2314
      ->condition('field_name', 'comment_body')
2315
      ->condition('deleted', 0)
2316
      ->countQuery()
2317
      ->execute()
2318
      ->fetchField();
2319
    $this->assertTrue($count == 0, 'Comment field instances were removed by uninstall.');
2320
  }
2321
}

Formats disponibles : Unified diff