<?php
/**
 * @file
 * Automated tests for disable breadcrumbs module.
 */
class DisableBreadcrumbsTestCase extends DrupalWebTestCase {
  public static function getInfo() {
    return array(
      'name' => t("Disable breadcrumbs"),
      'description' => t("Automated tests for Disable breadcrumbs"),
      'group' => t("Disable breadcrumbs"),
    );
  }

  public function setUp() {
    parent::setUp('disable_breadcrumbs');
    $this->admin_user = $this->drupalCreateUser(array('administer breadcrumbs', 'administer nodes', 'bypass node access'));
    $this->editor_user = $this->drupalCreateUser(array('disable node breadcrumbs', 'administer nodes'));
  }
  
  // Test admin settings page as admin.
/*
  public function testAddSettings() {

  }
*/
  
  // Disable breadcrumb on node as editor.
  public function testDisableNodeBreadcrumbs() {


    // Login in the admin user.
    $this->drupalLogin($this->admin_user);
    
    // Get admin settings form.
    $this->drupalGet('admin/appearance/disable_breadcrumbs');

    $edit = array(
      //'disable_breadcrumbs_node_types' => drupal_map_assoc(array('page', 'article')),
      //'disable_breadcrumbs_node_types_all[article]' => 'article',
      'disable_breadcrumbs_all' => 1,
    );

    $this->drupalPost('admin/appearance/disable_breadcrumbs', $edit, t("Save configuration"));
    $this->assertText(t('The configuration options have been saved.'), t('Configuration options saved.'));

    // Login the editor user.
    $this->drupalLogin($editor);
    
    $settings = array(
      'type' => 'page',
      'title' => $this->randomName(24),
      'body' => array(LANGUAGE_NONE => array(array($this->randomName(28)))),
    );
    $node = $this->drupalCreateNode($settings);
    
    $this->verbose('Node created: ' . var_export($node, TRUE));
    
    $edit = array();
    $edit['disable_breadcrumb'] = 1; //$this->randomName(16);
    $this->drupalPost("node/$node->nid", $edit, t('Save'));
    //$this->assertText(t('Breadcrumb changed on node @nid', array('@nid' => $node->nid)));
  }

} // DisableBreadcrumbsTestCase.
