You are here

public function CustomBreadcrumbsFeaturesMachineNamesTestCase::testDuplicateNames in Custom Breadcrumbs Features 7.2

Test machine name generation when 2 breadcrumbs have the same name.

Generated machine names should be unique.

File

tests/machine_names.test, line 127
Test that custom_breadcrumbs_features provides allows crumbs to have a machine name.

Class

CustomBreadcrumbsFeaturesMachineNamesTestCase
Test that Custom Breadcrumbs can be associated with machine names.

Code

public function testDuplicateNames() {

  // Create several crumbs twice (i.e. with the same name).
  $crumbs = $this->crumbs;
  foreach ($crumbs as $type => $edit) {
    $crumbs[$type]['name'] = $this
      ->randomName();
    $this
      ->createBreadcrumb($type, $crumbs[$type]);
    $this
      ->assertText($crumbs[$type]['name']);
    $this
      ->createBreadcrumb($type, $crumbs[$type]);
    $this
      ->assertText($crumbs[$type]['name']);
  }

  // Enable our module + assert they have a unique machine name.
  $this
    ->drupalGet('admin/modules');
  $this
    ->assertResponse(200);
  $edit = array(
    'modules[Custom breadcrumbs][custom_breadcrumbs_features][enable]' => TRUE,
    'modules[Features][features][enable]' => TRUE,
  );
  $this
    ->drupalPost(NULL, $edit, t('Save configuration'));
  $this
    ->assertResponse(200);
  $this
    ->assertText(t('Generated machine name'));
  foreach ($crumbs as $type => $edit) {
    $this
      ->assertMachineName($type, $edit['name']);
    $machine_names_count = db_select($type, 'cb')
      ->distinct()
      ->fields('cb', array(
      'machine_name',
    ))
      ->condition('name', $edit['name'])
      ->execute()
      ->rowCount();
    $this
      ->assertEqual($machine_names_count, 2);
  }
}