Commit 23a2db2d authored by alexpott's avatar alexpott

Issue #2385209 by tadityar, cilefen, ardnet, hussainweb, AjitS, tibbsa:...

Issue #2385209 by tadityar, cilefen, ardnet, hussainweb, AjitS, tibbsa: Clean-up views module test members - ensure property definition and use of camelCase naming convention
parent c7837f9a
......@@ -49,7 +49,7 @@ protected function setUp() {
// Create Basic page node type.
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
$this->vocabulary = entity_create('taxonomy_vocabulary', array(
$vocabulary = entity_create('taxonomy_vocabulary', array(
'name' => $this->randomMachineName(),
'description' => $this->randomMachineName(),
'vid' => Unicode::strtolower($this->randomMachineName()),
......@@ -58,25 +58,25 @@ protected function setUp() {
'nodes' => array('page' => 'page'),
'weight' => mt_rand(0, 10),
));
$this->vocabulary->save();
$vocabulary->save();
// Create a field.
$this->field_name = Unicode::strtolower($this->randomMachineName());
$field_name = Unicode::strtolower($this->randomMachineName());
entity_create('field_storage_config', array(
'field_name' => $this->field_name,
'field_name' => $field_name,
'entity_type' => 'node',
'type' => 'taxonomy_term_reference',
'settings' => array(
'allowed_values' => array(
array(
'vocabulary' => $this->vocabulary->id(),
'vocabulary' => $vocabulary->id(),
'parent' => '0',
),
),
)
))->save();
entity_create('field_config', array(
'field_name' => $this->field_name,
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => 'page',
))->save();
......@@ -90,10 +90,10 @@ protected function setUp() {
for ($i = 0; $i <= 10; $i++) {
$user = $this->drupalCreateUser();
$term = $this->createTerm($this->vocabulary);
$term = $this->createTerm($vocabulary);
$values = array('created' => $time, 'type' => 'page');
$values[$this->field_name][]['target_id'] = $term->id();
$values[$field_name][]['target_id'] = $term->id();
// Make every other node promoted.
if ($i % 2) {
......
......@@ -28,7 +28,12 @@ class FieldUnitTest extends ViewUnitTestBase {
*/
public static $testViews = array('test_view', 'test_field_tokens', 'test_field_output');
protected $column_map = array(
/**
* Map column names.
*
* @var array
*/
protected $columnMap = array(
'views_test_data_name' => 'name',
);
......@@ -265,7 +270,7 @@ function _testHideIfEmpty() {
$view->initDisplay();
$this->executeView($view);
$column_map_reversed = array_flip($this->column_map);
$column_map_reversed = array_flip($this->columnMap);
$view->row_index = 0;
$random_name = $this->randomMachineName();
$random_value = $this->randomMachineName();
......@@ -483,7 +488,7 @@ function _testEmptyText() {
$view->initDisplay();
$this->executeView($view);
$column_map_reversed = array_flip($this->column_map);
$column_map_reversed = array_flip($this->columnMap);
$view->row_index = 0;
$empty_text = $view->field['name']->options['empty'] = $this->randomMachineName();
......
......@@ -32,7 +32,12 @@ class FieldWebTest extends HandlerTestBase {
*/
public static $modules = ['node'];
protected $column_map = array(
/**
* Maps between the key in the expected result and the query result.
*
* @var array
*/
protected $columnMap = array(
'views_test_data_name' => 'name',
);
......
......@@ -33,7 +33,12 @@ class FilterBooleanOperatorStringTest extends ViewUnitTestBase {
*/
public static $testViews = array('test_view');
protected $column_map = array(
/**
* Map column names.
*
* @var array
*/
protected $columnMap = array(
'views_test_data_id' => 'id',
);
......@@ -117,7 +122,7 @@ public function testFilterBooleanOperatorString() {
);
$this->assertEqual(2, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->column_map);
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
$view->destroy();
$view->setDisplay();
......@@ -140,7 +145,7 @@ public function testFilterBooleanOperatorString() {
);
$this->assertEqual(3, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->column_map);
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
}
/**
......@@ -163,7 +168,7 @@ public function testFilterGroupedExposed() {
);
$this->assertEqual(3, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->column_map);
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
$view->destroy();
$view->setExposedInput(array('status' => 2));
......@@ -178,7 +183,7 @@ public function testFilterGroupedExposed() {
);
$this->assertEqual(2, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->column_map);
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
}
/**
......
......@@ -32,7 +32,12 @@ class FilterBooleanOperatorTest extends ViewUnitTestBase {
*/
public static $testViews = array('test_view');
protected $column_map = array(
/**
* Map column names.
*
* @var array
*/
protected $columnMap = array(
'views_test_data_id' => 'id',
);
......@@ -66,7 +71,7 @@ public function testFilterBooleanOperator() {
);
$this->assertEqual(2, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->column_map);
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
$view->destroy();
$view->setDisplay();
......@@ -89,7 +94,7 @@ public function testFilterBooleanOperator() {
);
$this->assertEqual(3, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->column_map);
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
}
/**
......@@ -112,7 +117,7 @@ public function testFilterGroupedExposed() {
);
$this->assertEqual(3, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->column_map);
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
$view->destroy();
$view->setExposedInput(array('status' => 2));
......@@ -127,7 +132,7 @@ public function testFilterGroupedExposed() {
);
$this->assertEqual(2, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->column_map);
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
}
/**
......
......@@ -24,7 +24,12 @@ class FilterCombineTest extends ViewUnitTestBase {
*/
public static $testViews = array('test_view');
protected $column_map = array(
/**
* Map column names.
*
* @var array
*/
protected $columnMap = array(
'views_test_data_name' => 'name',
'views_test_data_job' => 'job',
);
......@@ -78,7 +83,7 @@ public function testFilterCombineContains() {
'job' => NULL,
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
/**
......
......@@ -26,7 +26,12 @@ class FilterEqualityTest extends ViewUnitTestBase {
*/
public static $testViews = array('test_view');
protected $column_map = array(
/**
* Map column names.
*
* @var array
*/
protected $columnMap = array(
'views_test_data_name' => 'name',
);
......@@ -64,7 +69,7 @@ function testEqual() {
'name' => 'Ringo',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
public function testEqualGroupedExposed() {
......@@ -85,7 +90,7 @@ public function testEqualGroupedExposed() {
'name' => 'Ringo',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testNotEqual() {
......@@ -119,7 +124,7 @@ function testNotEqual() {
'name' => 'Meredith',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
public function testEqualGroupedNotExposed() {
......@@ -149,7 +154,7 @@ public function testEqualGroupedNotExposed() {
'name' => 'Meredith',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
......
......@@ -26,7 +26,12 @@ class FilterInOperatorTest extends ViewUnitTestBase {
*/
public static $testViews = array('test_view');
protected $column_map = array(
/**
* Map column names.
*
* @var array
*/
protected $columnMap = array(
'views_test_data_name' => 'name',
'views_test_data_age' => 'age',
);
......@@ -72,7 +77,7 @@ public function testFilterInOperatorSimple() {
);
$this->assertEqual(2, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->column_map);
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
$view->destroy();
$view->setDisplay();
......@@ -106,7 +111,7 @@ public function testFilterInOperatorSimple() {
);
$this->assertEqual(3, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->column_map);
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
}
public function testFilterInOperatorGroupedExposedSimple() {
......@@ -132,7 +137,7 @@ public function testFilterInOperatorGroupedExposedSimple() {
);
$this->assertEqual(2, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->column_map);
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
}
public function testFilterNotInOperatorGroupedExposedSimple() {
......@@ -162,7 +167,7 @@ public function testFilterNotInOperatorGroupedExposedSimple() {
);
$this->assertEqual(3, count($view->result));
$this->assertIdenticalResultset($view, $expected_result, $this->column_map);
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
}
protected function getGroupedExposedFilters() {
......
......@@ -26,7 +26,12 @@ class FilterNumericTest extends ViewUnitTestBase {
*/
public static $testViews = array('test_view');
protected $column_map = array(
/**
* Map column names.
*
* @var array
*/
protected $columnMap = array(
'views_test_data_name' => 'name',
'views_test_data_age' => 'age',
);
......@@ -68,7 +73,7 @@ public function testFilterNumericSimple() {
'age' => 28,
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
public function testFilterNumericExposedGroupedSimple() {
......@@ -90,7 +95,7 @@ public function testFilterNumericExposedGroupedSimple() {
'age' => 28,
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
public function testFilterNumericBetween() {
......@@ -127,7 +132,7 @@ public function testFilterNumericBetween() {
'age' => 26,
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
// test not between
$view->destroy();
......@@ -163,7 +168,7 @@ public function testFilterNumericBetween() {
'age' => 30,
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
public function testFilterNumericExposedGroupedBetween() {
......@@ -193,7 +198,7 @@ public function testFilterNumericExposedGroupedBetween() {
'age' => 26,
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
public function testFilterNumericExposedGroupedNotBetween() {
......@@ -223,7 +228,7 @@ public function testFilterNumericExposedGroupedNotBetween() {
'age' => 30,
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
public function testFilterNumericEmpty() {
......@@ -244,7 +249,7 @@ public function testFilterNumericEmpty() {
$this->executeView($view);
$resultset = array(
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
$view->destroy();
$view->setDisplay();
......@@ -283,7 +288,7 @@ public function testFilterNumericEmpty() {
'age' => 30,
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
public function testFilterNumericExposedGroupedEmpty() {
......@@ -301,7 +306,7 @@ public function testFilterNumericExposedGroupedEmpty() {
$this->executeView($view);
$resultset = array(
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
public function testFilterNumericExposedGroupedNotEmpty() {
......@@ -339,7 +344,7 @@ public function testFilterNumericExposedGroupedNotEmpty() {
'age' => 30,
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
public function testAllowEmpty() {
......
......@@ -26,7 +26,12 @@ class FilterStringTest extends ViewUnitTestBase {
*/
public static $testViews = array('test_view');
protected $column_map = array(
/**
* Map column names.
*
* @var array
*/
protected $columnMap = array(
'views_test_data_name' => 'name',
);
......@@ -109,7 +114,7 @@ function testFilterStringEqual() {
'name' => 'Ringo',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringGroupedExposedEqual() {
......@@ -131,7 +136,7 @@ function testFilterStringGroupedExposedEqual() {
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringNotEqual() {
......@@ -165,7 +170,7 @@ function testFilterStringNotEqual() {
'name' => 'Meredith',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringGroupedExposedNotEqual() {
......@@ -197,7 +202,7 @@ function testFilterStringGroupedExposedNotEqual() {
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringContains() {
......@@ -222,7 +227,7 @@ function testFilterStringContains() {
'name' => 'Ringo',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
......@@ -245,7 +250,7 @@ function testFilterStringGroupedExposedContains() {
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
......@@ -274,7 +279,7 @@ function testFilterStringWord() {
'name' => 'Ringo',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
$view->destroy();
$view = Views::getView('test_view');
......@@ -298,7 +303,7 @@ function testFilterStringWord() {
'name' => 'Ringo',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
......@@ -321,7 +326,7 @@ function testFilterStringGroupedExposedWord() {
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
$view->destroy();
$filters = $this->getGroupedExposedFilters();
......@@ -341,7 +346,7 @@ function testFilterStringGroupedExposedWord() {
'name' => 'Ringo',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringStarts() {
......@@ -366,7 +371,7 @@ function testFilterStringStarts() {
'name' => 'George',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringGroupedExposedStarts() {
......@@ -387,7 +392,7 @@ function testFilterStringGroupedExposedStarts() {
'name' => 'George',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringNotStarts() {
......@@ -419,7 +424,7 @@ function testFilterStringNotStarts() {
),
// There is no Meredith returned because his description is empty
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringGroupedExposedNotStarts() {
......@@ -447,7 +452,7 @@ function testFilterStringGroupedExposedNotStarts() {
),
// There is no Meredith returned because his description is empty
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringEnds() {
......@@ -475,7 +480,7 @@ function testFilterStringEnds() {
'name' => 'Ringo',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringGroupedExposedEnds() {
......@@ -499,7 +504,7 @@ function testFilterStringGroupedExposedEnds() {
'name' => 'Ringo',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringNotEnds() {
......@@ -528,7 +533,7 @@ function testFilterStringNotEnds() {
),
// There is no Meredith returned because his description is empty
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringGroupedExposedNotEnds() {
......@@ -553,7 +558,7 @@ function testFilterStringGroupedExposedNotEnds() {
),
// There is no Meredith returned because his description is empty
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringNot() {
......@@ -582,7 +587,7 @@ function testFilterStringNot() {
),
// There is no Meredith returned because his description is empty
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
......@@ -608,7 +613,7 @@ function testFilterStringGroupedExposedNot() {
),
// There is no Meredith returned because his description is empty
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
......@@ -637,7 +642,7 @@ function testFilterStringShorter() {
'name' => 'Paul',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringGroupedExposedShorter() {
......@@ -660,7 +665,7 @@ function testFilterStringGroupedExposedShorter() {
'name' => 'Paul',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringLonger() {
......@@ -685,7 +690,7 @@ function testFilterStringLonger() {
'name' => 'Meredith',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringGroupedExposedLonger() {
......@@ -705,7 +710,7 @@ function testFilterStringGroupedExposedLonger() {
'name' => 'Meredith',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
......@@ -730,7 +735,7 @@ function testFilterStringEmpty() {
'name' => 'Meredith',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
function testFilterStringGroupedExposedEmpty() {
......@@ -750,7 +755,7 @@ function testFilterStringGroupedExposedEmpty() {
'name' => 'Meredith',
),
);
$this->assertIdenticalResultset($view, $resultset, $this->column_map);
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
}
protected function getGroupedExposedFilters() {
......
......@@ -33,6 +33,20 @@ class AccessTest extends PluginTestBase {
*/
public static $modules = array('node');
/**
* Web user for testing.
*
* @var \Drupal\user\UserInterface
*/
protected $webUser;
/**
* Normal user for testing.
*
* @var \Drupal\user\UserInterface
*/
protected $normalUser;
protected function setUp() {
parent::setUp();
......@@ -40,13 +54,11 @@ protected function setUp() {
ViewTestData::createTestViews(get_class($this), array('views_test_data'));
$this->web_user = $this->drupalCreateUser();
$roles = $this->web_user->getRoles();
$this->web_role = $roles[0];
$this->webUser = $this->drupalCreateUser();
$this->normal_role = $this->drupalCreateRole(array());
$this->normal_user = $this->drupalCreateUser(array('views_test_data test permission'));
$this->normal_user->addRole($this->normal_role);
$normal_role = $this->drupalCreateRole(array());
$this->normalUser = $this->drupalCreateUser(array('views_test_data test permission'));
$this->normalUser->addRole($normal_role);
// @todo when all the plugin information is cached make a reset function and
// call it here.
}
......@@ -58,8 +70,8 @@ function testAccessNone() {
$view = Views::getView('test_access_none');
$view->setDisplay();
$this->assertTrue($view->display_handler->access($this->web_user));
$this->assertTrue($view->display_handler->access($this->normal_user));
$this->assertTrue($view->display_handler->access($this->webUser));
$this->assertTrue($view->display_handler->access($this->normalUser));
}
/**
......@@ -77,7 +89,7 @@ function testStaticAccessPlugin() {
$access_plugin = $view->display_handler->getPlugin('access');
$this->assertFalse($access_plugin->access($this->normal_user));
$this->assertFalse($access_plugin->access($this->normalUser));
$this->drupalGet('test_access_static');
$this->assertResponse(403);
......@@ -89,7 +101,7 @@ function testStaticAccessPlugin() {
// termination event fires. Simulate that here.
$this->container->get('router.builder')->rebuildIfNeeded();