Commit 9ac8d938 authored by generalredneck's avatar generalredneck

Adding tests to the module that actually run and copy d8.

parent 82a1a990
name = Views Natural Sort Test
description = Set up module for Views Natural Sort testing.
package = Testing
core = 7.x
dependencies[] = views_natural_sort
hidden = TRUE
<?php
/**
* Implements hook_install().
*/
function views_natural_sort_test_install() {
node_types_rebuild();
$types = node_type_get_types();
node_add_body_field($types['views_natural_sort_test_content']);
}
<?php
/**
* Implement hook_form()
*/
function views_natural_sort_test_form($node, $form_state) {
return node_content_form($node, $form_state);
}
/**
* Implements hook_node_info().
*/
function views_natural_sort_test_node_info() {
return array(
'views_natural_sort_test_content' => array(
'name' => t('Views Natural Sort Test Content'),
'base' => 'node_content',
'description' => t('Content type used for testing the basic functionality of the Views Natural Sort module.'),
),
);
}
/**
* Implementation of hook_views_api().
*/
function views_natural_sort_test_views_api() {
return array(
'api' => 3.0,
'path' => drupal_get_path('module', 'views_natural_sort_test'),
);
}
/**
* Implements hook_views_default_views().
*/
function views_natural_sort_test_views_default_views() {
$view = new view();
$view->name = 'views_natural_sort_test';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Views Natural Sort Test';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
/* Sort criterion: Content: Title */
$handler->display->display_options['sorts']['title']['id'] = 'title';
$handler->display->display_options['sorts']['title']['table'] = 'node';
$handler->display->display_options['sorts']['title']['field'] = 'title';
$handler->display->display_options['sorts']['title']['order'] = 'NASC';
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
'views_natural_sort_test_content' => 'views_natural_sort_test_content',
);
$views[$view->name] = $view;
return $views;
}
......@@ -8,4 +8,4 @@ core = 7.x
; Views handlers
files[] = handlers/views_natural_sort_handler_sort.inc
files[] = views_natrual_sort.test
files[] = views_natural_sort.test
<?php
module_load_include('test','views','tests/views_query');
class ViewsNaturalSortBasicTest extends ViewsTestCase {
public static function getInfo() {
return array(
'name' => 'Views Natural Sort Basic Test',
'description' => 'Tests basic functionality of View Natural Sort',
'group' => 'Views Natural Sort',
);
}
protected function setUp() {
parent::setUp('views', 'views_natural_sort', 'views_natural_sort_test');
}
public function testNaturalSortDefaultBeginningWords() {
$titles = array(
'A Stripped Zebra',
'Oklahoma',
'The King And I',
);
$nodes = array();
foreach($titles as $title) {
$nodes[] = $this->drupalCreateNode(array(
'type' => 'views_natural_sort_test_content',
'title' => $title,
));
}
$view = views_get_view('views_natural_sort_test');
$this->executeView($view);
$this->assertIdenticalResultset(
$view,
array(
array('title' => 'The King And I'),
array('title' => 'Oklahoma'),
array('title' => 'A Stripped Zebra'),
),
array('node_title' => 'title')
);
}
public function testNaturalSortDefaultSymbols() {
$titles = array(
'A(Z',
'A[B',
'A\\C',
);
foreach($titles as $title) {
$nodes[] = $this->drupalCreateNode(array(
'type' => 'views_natural_sort_test_content',
'title' => $title,
));
}
$view = views_get_view('views_natural_sort_test');
$this->executeView($view);
$this->assertIdenticalResultset(
$view,
array(
array('title' => 'A[B'),
array('title' => 'A\\C'),
array('title' => 'A(Z'),
),
array('node_title' => 'title')
);
}
public function testNaturalSortNumbers() {
$titles = array(
'1 apple',
'2 apples',
'10 apples',
'-1 apples',
'-10 apples',
'-2 appels',
'-3.550 apples',
'-3.5501 apples',
'3.5501 apples',
'3.550 apples',
);
foreach($titles as $title) {
$nodes[] = $this->drupalCreateNode(array(
'type' => 'views_natural_sort_test_content',
'title' => $title,
));
}
$view = views_get_view('views_natural_sort_test');
$this->executeView($view);
$this->assertIdenticalResultset(
$view,
array(
array('title' => '-10 apples'),
array('title' => '-3.5501 apples'),
array('title' => '-3.550 apples'),
array('title' => '-2 apples'),
array('title' => '-1 apples'),
array('title' => '1 apple'),
array('title' => '2 apples'),
array('title' => '3.550 apples'),
array('title' => '3.5501 apples'),
array('title' => '10 apples'),
),
array('node_title' => 'title')
);
}
}
class ViewsNaturalSortDaysOfTheWeekTest extends DrupalWebTestCase {
......@@ -10,18 +115,19 @@ class ViewsNaturalSortDaysOfTheWeekTest extends DrupalWebTestCase {
);
}
function testDefaultDayReplace() {
protected function setUp() {
parent::setUp('views', 'views_natural_sort');
variable_set('views_natural_sort_days_of_the_week_enabled', TRUE);
}
function testDefaultDayReplace() {
foreach(views_natural_sort_days_of_the_week_get_default_days() as $replaced => $day) {
$this->assertEqual(views_natural_sort_days_of_the_week_sort_days($day), $replaced);
}
}
function testFirstDayMonday() {
variable_set('views_natural_sort_days_of_the_week_enabled', TRUE);
$variable_original = variable_get("views_natural_sort_days_of_the_week_first_day_en", "Sunday");
variable_set("views_natural_sort_days_of_the_week_first_day_en", "Monday");
db_set_active("default");
$expected = array(
"Monday",
"Tuesday",
......@@ -34,10 +140,8 @@ class ViewsNaturalSortDaysOfTheWeekTest extends DrupalWebTestCase {
foreach($expected as $replaced => $day) {
$this->assertEqual(views_natural_sort_days_of_the_week_sort_days($day), $replaced);
}
variable_set("views_natural_sort_days_of_the_week_first_day_en", $variable_original);
}
function testAbbreviations() {
variable_set('views_natural_sort_days_of_the_week_enabled', TRUE);
$expected = array(
"Sun",
"Mon.",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment