accessibility-8.x-1.x-dev/modules/accessibility_testswarm/accessibility_testswarm.install

modules/accessibility_testswarm/accessibility_testswarm.install
<?php

/**
 * Implements hook_install().
 * Here we are creating default entities like nodes and taxonomy terms so we
 * can test pages like edit or delete.
 */
function accessibility_testswarm_install() {
	$node_ids = array();
	$node = array(
           'uid' => 0,
           'type' => 'article',
           'title' => t('Published article'),
           'status' => 1,
           'comment' => 2
  );
  $node = entity_create('node', $node);
  $node->save();
  $node_ids[] = $node->nid;

  $comment_values = array('nid' => $node->nid, 'pid' => 0, 'node_type' => 'comment_node_' . $node->type, 'subject' => t('Test comment'));
  $comment = entity_create('comment', $comment_values);
  $comment->save();
  variable_set('accessibility_testswarm_comment', $comment->id());
  
	$node = array(
           'uid' => 0,
           'type' => 'article',
           'title' => t('Unpublished article'),
           'status' => 0,
           'comment' => 2

  );
  $node = entity_create('node', $node);
  $node->save();
	$node_ids[] = $node->nid;
  
  $node = array(
           'uid' => 0,
           'type' => 'page',
           'title' => t('Published page'),
           'status' => 1,
           'comment' => 2
  );
  $node = entity_create('node', $node);
  $node->save();
  $node_ids[] = $node->nid;
  
  $node = array(
           'uid' => 0,
           'type' => 'page',
           'title' => t('Unpublished page'),
           'status' => 0,
           'comment' => 2
  );
  $node = entity_create('node', $node);
  $node->save();
  $node_ids[] = $node->nid;
	
	variable_set('accessibility_testswarm_nodes', $node_ids);

  $vocabularies = taxonomy_vocabulary_load_multiple();
  $vocabulary = array_shift($vocabularies);
  variable_set('accessibility_testswarm_taxonomy_vocabulary', $vocabulary->id());

  $taxonomy_term = entity_create('taxonomy_term', array('name' => array('und' => t('Test')), 'vid' => $vocabulary->id()));
  $taxonomy_term->save();
  variable_set('accessibility_testswarm_taxonomy_term', $taxonomy_term->id());

  $menu_link = entity_create('menu_link', array(
      'mlid' => 0,
      'plid' => 0,
      'menu_name' => 'main',
      'link_path' => 'admin',
      'link_title' => t('Administer')
    ));
  $menu_link->save();

  $menu_link = entity_create('menu_link', array(
      'mlid' => 0,
      'plid' => 0,
      'menu_name' => 'footer',
      'link_path' => 'admin',
      'link_title' => t('Administer')
    ));
  $menu_link->save();
}

/**
 * Implements hook_schema().
 */
function accessibility_testswarm_schema() {
  $schema = array();

  $schema['accessibility_testswarm_test_detail'] = array(
    'description' => 'Table for storing details about failed accessibility tests.',
    'fields' => array(
      'tri' => array(
        'type' => 'int',
        'not null' => TRUE,
        'unsigned' => TRUE,
      ),
      'test' => array(
        'type' => 'varchar',
        'length' => 150,
        'not null' => TRUE,
      ),
      'hook' => array(
        'type' => 'varchar',
        'length' => 150,
        'not null' => TRUE,
      ),
      'type' => array(
        'type' => 'char',
        'length' => 50,
        'not null' => TRUE,
      ),
      'theme_item' => array(
        'type' => 'varchar',
        'length' => 250,
        'not null' => TRUE,
      ),
      'element' => array(
        'type' => 'text',
        'not null' => TRUE,
      ),
    ),
    'indexes' => array(
      'tri' => array('tri'),
      'tri_test' => array('tri', 'test'),
    )
  );

  return $schema;
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc