本文整理汇总了PHP中Drupal\views\Views类的典型用法代码示例。如果您正苦于以下问题:PHP Views类的具体用法?PHP Views怎么用?PHP Views使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Views类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testStyleUI
/**
* Tests changing the style plugin and changing some options of a style.
*/
public function testStyleUI()
{
$view_name = 'test_view';
$view_edit_url = "admin/structure/views/view/{$view_name}/edit";
$style_plugin_url = "admin/structure/views/nojs/display/{$view_name}/default/style";
$style_options_url = "admin/structure/views/nojs/display/{$view_name}/default/style_options";
$this->drupalGet($style_plugin_url);
$this->assertFieldByName('style[type]', 'default', 'The default style plugin selected in the UI should be unformatted list.');
$edit = array('style[type]' => 'test_style');
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertFieldByName('style_options[test_option]', NULL, 'Make sure the custom settings form from the test plugin appears.');
$random_name = $this->randomMachineName();
$edit = array('style_options[test_option]' => $random_name);
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->drupalGet($style_options_url);
$this->assertFieldByName('style_options[test_option]', $random_name, 'Make sure the custom settings form field has the expected value stored.');
$this->drupalPostForm($view_edit_url, array(), t('Save'));
$this->assertLink(t('Test style plugin'), 0, 'Make sure the test style plugin is shown in the UI');
$view = Views::getView($view_name);
$view->initDisplay();
$style = $view->display_handler->getOption('style');
$this->assertEqual($style['type'], 'test_style', 'Make sure that the test_style got saved as used style plugin.');
$this->assertEqual($style['options']['test_option'], $random_name, 'Make sure that the custom settings field got saved as expected.');
// Test that fields are working correctly in the UI for style plugins when
// a field row plguin is selected.
$this->drupalPostForm("admin/structure/views/view/{$view_name}/edit", array(), 'Add Page');
$this->drupalPostForm("admin/structure/views/nojs/display/{$view_name}/page_1/row", array('row[type]' => 'fields'), t('Apply'));
// If fields are being used this text will not be shown.
$this->assertNoText(t('The selected style or row format does not utilize fields.'));
}
示例2: testCalculateDependencies
/**
* Tests the calculateDependencies method.
*/
public function testCalculateDependencies()
{
$comment_type = entity_create('comment_type', array('id' => 'comment', 'label' => 'Comment settings', 'description' => 'Comment settings', 'target_entity_type_id' => 'node'));
$comment_type->save();
$content_type = entity_create('node_type', array('type' => $this->randomMachineName(), 'name' => $this->randomString()));
$content_type->save();
$field_storage = entity_create('field_storage_config', array('field_name' => Unicode::strtolower($this->randomMachineName()), 'entity_type' => 'node', 'type' => 'comment'));
$field_storage->save();
entity_create('field_config', array('field_storage' => $field_storage, 'bundle' => $content_type->id(), 'label' => $this->randomMachineName() . '_label', 'description' => $this->randomMachineName() . '_description', 'settings' => array('comment_type' => $comment_type->id())))->save();
entity_create('field_config', array('field_storage' => FieldStorageConfig::loadByName('node', 'body'), 'bundle' => $content_type->id(), 'label' => $this->randomMachineName() . '_body', 'settings' => array('display_summary' => TRUE)))->save();
$expected = [];
$expected['test_field_get_entity'] = ['module' => ['comment', 'node', 'user']];
// Tests dependencies of relationships.
$expected['test_relationship_dependency'] = ['module' => ['comment', 'node', 'user']];
$expected['test_plugin_dependencies'] = ['module' => ['comment', 'views_test_data'], 'content' => ['RowTest', 'StaticTest', 'StyleTest']];
$expected['test_argument_dependency'] = ['config' => ['core.entity_view_mode.node.teaser', 'field.storage.node.body'], 'content' => ['ArgumentDefaultTest', 'ArgumentValidatorTest'], 'module' => ['node', 'search', 'text', 'user']];
foreach ($this::$testViews as $view_id) {
$view = Views::getView($view_id);
$dependencies = $view->calculateDependencies();
$this->assertEqual($expected[$view_id], $dependencies);
$config = $this->config('views.view.' . $view_id);
\Drupal::service('config.storage.staging')->write($view_id, $config->get());
}
// Ensure that dependencies are calculated on the display level.
$expected_display['default'] = ['config' => ['core.entity_view_mode.node.teaser'], 'content' => ['ArgumentDefaultTest', 'ArgumentValidatorTest'], 'module' => ['core', 'node', 'search', 'user', 'views']];
$expected_display['page'] = ['config' => ['field.storage.node.body'], 'module' => ['core', 'text', 'views']];
$view = Views::getView('test_argument_dependency');
$view->initDisplay();
foreach ($view->displayHandlers as $display) {
// Calculate the dependencies each display has.
$this->assertEqual($expected_display[$display->getPluginId()], $display->calculateDependencies());
}
}
示例3: setUp
function setUp()
{
parent::setUp();
// Add two new languages.
ConfigurableLanguage::createFromLangcode('fr')->save();
ConfigurableLanguage::createFromLangcode('es')->save();
// Set up term names.
$this->termNames = array('en' => 'Food in Paris', 'es' => 'Comida en Paris', 'fr' => 'Nouriture en Paris');
// Create a vocabulary.
$this->vocabulary = Vocabulary::create(['name' => 'Views testing tags', 'vid' => 'views_testing_tags']);
$this->vocabulary->save();
// Add a translatable field to the vocabulary.
$field = FieldStorageConfig::create(array('field_name' => 'field_foo', 'entity_type' => 'taxonomy_term', 'type' => 'text'));
$field->save();
FieldConfig::create(['field_name' => 'field_foo', 'entity_type' => 'taxonomy_term', 'label' => 'Foo', 'bundle' => 'views_testing_tags'])->save();
// Create term with translations.
$taxonomy = $this->createTermWithProperties(array('name' => $this->termNames['en'], 'langcode' => 'en', 'description' => $this->termNames['en'], 'field_foo' => $this->termNames['en']));
foreach (array('es', 'fr') as $langcode) {
$translation = $taxonomy->addTranslation($langcode, array('name' => $this->termNames[$langcode]));
$translation->description->value = $this->termNames[$langcode];
$translation->field_foo->value = $this->termNames[$langcode];
}
$taxonomy->save();
Views::viewsData()->clear();
ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
$this->container->get('router.builder')->rebuild();
}
示例4: testHooks
/**
* Tests the hooks.
*/
public function testHooks()
{
$view = Views::getView('test_view');
$view->setDisplay();
// Test each hook is found in the implementations array and is invoked.
foreach (static::$hooks as $hook => $type) {
$this->assertTrue($this->moduleHandler->implementsHook('views_test_data', $hook), format_string('The hook @hook was registered.', array('@hook' => $hook)));
if ($hook == 'views_post_render') {
$this->moduleHandler->invoke('views_test_data', $hook, array($view, &$view->display_handler->output, $view->display_handler->getPlugin('cache')));
continue;
}
switch ($type) {
case 'view':
$this->moduleHandler->invoke('views_test_data', $hook, array($view));
break;
case 'alter':
$data = array();
$this->moduleHandler->invoke('views_test_data', $hook, array($data));
break;
default:
$this->moduleHandler->invoke('views_test_data', $hook);
}
$this->assertTrue($this->container->get('state')->get('views_hook_test_' . $hook), format_string('The %hook hook was invoked.', array('%hook' => $hook)));
// Reset the module implementations cache, so we ensure that the
// .views.inc file is loaded actively.
$this->moduleHandler->resetImplementations();
}
}
示例5: testIntegration
/**
* Tests the integration.
*/
public function testIntegration()
{
// Remove the watchdog entries added by the potential batch process.
$this->container->get('database')->truncate('watchdog')->execute();
$entries = array();
// Setup a watchdog entry without tokens.
$entries[] = array('message' => $this->randomMachineName(), 'variables' => array(), 'link' => l('Link', 'node/1'));
// Setup a watchdog entry with one token.
$entries[] = array('message' => '@token1', 'variables' => array('@token1' => $this->randomMachineName()), 'link' => l('Link', 'node/2'));
// Setup a watchdog entry with two tokens.
$entries[] = array('message' => '@token1 !token2', 'variables' => array('@token1' => $this->randomMachineName(), '!token2' => $this->randomMachineName()), 'link' => l('<object>Link</object>', 'node/2', array('html' => TRUE)));
foreach ($entries as $entry) {
$entry += array('type' => 'test-views', 'severity' => WATCHDOG_NOTICE);
watchdog($entry['type'], $entry['message'], $entry['variables'], $entry['severity'], $entry['link']);
}
$view = Views::getView('test_dblog');
$this->executeView($view);
$view->initStyle();
foreach ($entries as $index => $entry) {
$this->assertEqual($view->style_plugin->getField($index, 'message'), String::format($entry['message'], $entry['variables']));
$this->assertEqual($view->style_plugin->getField($index, 'link'), Xss::filterAdmin($entry['link']));
}
// Disable replacing variables and check that the tokens aren't replaced.
$view->destroy();
$view->initHandlers();
$this->executeView($view);
$view->initStyle();
$view->field['message']->options['replace_variables'] = FALSE;
foreach ($entries as $index => $entry) {
$this->assertEqual($view->style_plugin->getField($index, 'message'), $entry['message']);
}
}
示例6: testSimple
function testSimple()
{
$view = Views::getView('test_view');
$view->setDisplay();
$view->displayHandlers->get('default')->overrideOption('fields', array('counter' => array('id' => 'counter', 'table' => 'views', 'field' => 'counter', 'relationship' => 'none'), 'name' => array('id' => 'name', 'table' => 'views_test_data', 'field' => 'name', 'relationship' => 'none')));
$view->preview();
$counter = $view->style_plugin->getField(0, 'counter');
$this->assertEqual($counter, '1', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 1, '@counter' => $counter)));
$counter = $view->style_plugin->getField(1, 'counter');
$this->assertEqual($counter, '2', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 2, '@counter' => $counter)));
$counter = $view->style_plugin->getField(2, 'counter');
$this->assertEqual($counter, '3', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 3, '@counter' => $counter)));
$view->destroy();
$view->storage->invalidateCaches();
$view->setDisplay();
$rand_start = rand(5, 10);
$view->displayHandlers->get('default')->overrideOption('fields', array('counter' => array('id' => 'counter', 'table' => 'views', 'field' => 'counter', 'relationship' => 'none', 'counter_start' => $rand_start), 'name' => array('id' => 'name', 'table' => 'views_test_data', 'field' => 'name', 'relationship' => 'none')));
$view->preview();
$counter = $view->style_plugin->getField(0, 'counter');
$expected_number = 0 + $rand_start;
$this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
$counter = $view->style_plugin->getField(1, 'counter');
$expected_number = 1 + $rand_start;
$this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
$counter = $view->style_plugin->getField(2, 'counter');
$expected_number = 2 + $rand_start;
$this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
}
示例7: testUsername
/**
* Test the username formatter.
*/
public function testUsername()
{
$view_id = $this->randomMachineName();
$view = View::create(['id' => $view_id, 'base_table' => 'comment_field_data', 'display' => ['default' => ['display_plugin' => 'default', 'id' => 'default', 'display_options' => ['fields' => ['name' => ['table' => 'comment_field_data', 'field' => 'name', 'id' => 'name', 'plugin_id' => 'field', 'type' => 'comment_username'], 'subject' => ['table' => 'comment_field_data', 'field' => 'subject', 'id' => 'subject', 'plugin_id' => 'field', 'type' => 'string', 'settings' => ['link_to_entity' => TRUE]]]]]]]);
$view->save();
/* @var \Drupal\Core\Session\AccountSwitcherInterface $account_switcher */
$account_switcher = \Drupal::service('account_switcher');
/* @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$account_switcher->switchTo($this->adminUser);
$executable = Views::getView($view_id);
$build = $executable->preview();
$this->setRawContent($renderer->renderRoot($build));
$this->verbose($this->getRawContent());
$this->assertLink('My comment title');
$this->assertLink('Anonymous comment title');
$this->assertLink($this->adminUser->label());
$this->assertLink('barry (not verified)');
$account_switcher->switchTo(new AnonymousUserSession());
$executable = Views::getView($view_id);
$executable->storage->invalidateCaches();
$build = $executable->preview();
$this->setRawContent($renderer->renderRoot($build));
// No access to user-profiles, so shouldn't be able to see links.
$this->assertNoLink($this->adminUser->label());
// Note: External users aren't pointing to drupal user profiles.
$this->assertLink('barry (not verified)');
$this->verbose($this->getRawContent());
$this->assertLink('My comment title');
$this->assertLink('Anonymous comment title');
}
示例8: testCustomOption
/**
* Tests the setting and output of custom labels for boolean values.
*/
public function testCustomOption()
{
// Add the boolean field handler to the test view.
$view = Views::getView('test_view');
$view->setDisplay();
$view->displayHandlers->get('default')->overrideOption('fields', array('age' => array('id' => 'age', 'table' => 'views_test_data', 'field' => 'age', 'relationship' => 'none')));
$this->executeView($view);
$custom_true = 'Yay';
$custom_false = 'Nay';
// Set up some custom value mappings for different types.
$custom_values = array('plain' => array('true' => $custom_true, 'false' => $custom_false, 'test' => 'assertTrue'), 'allowed tag' => array('true' => '<p>' . $custom_true . '</p>', 'false' => '<p>' . $custom_false . '</p>', 'test' => 'assertTrue'), 'disallowed tag' => array('true' => '<script>' . $custom_true . '</script>', 'false' => '<script>' . $custom_false . '</script>', 'test' => 'assertFalse'));
// Run the same tests on each type.
foreach ($custom_values as $type => $values) {
$options = array('options[type]' => 'custom', 'options[type_custom_true]' => $values['true'], 'options[type_custom_false]' => $values['false']);
$this->drupalPostForm('admin/structure/views/nojs/handler/test_view/default/field/age', $options, 'Apply');
// Save the view.
$this->drupalPostForm('admin/structure/views/view/test_view', array(), 'Save');
$view = Views::getView('test_view');
$output = $view->preview();
$output = drupal_render($output);
$replacements = array('%type' => $type);
$this->{$values['test']}(strpos($output, $values['true']), format_string('Expected custom boolean TRUE value in output for %type.', $replacements));
$this->{$values['test']}(strpos($output, $values['false']), format_string('Expected custom boolean FALSE value in output for %type', $replacements));
}
}
示例9: testFilterEntity
/**
* Tests the generic bundle filter.
*/
public function testFilterEntity()
{
$view = Views::getView('test_entity_type_filter');
// Tests \Drupal\views\Plugin\views\filter\Bundle::calculateDependencies().
$expected = ['config' => ['node.type.test_bundle', 'node.type.test_bundle_2'], 'module' => ['node']];
$this->assertIdentical($expected, $view->getDependencies());
$this->executeView($view);
// Test we have all the results, with all types selected.
$this->assertEqual(count($view->result), $this->entities['count']);
// Test the valueOptions of the filter handler.
$expected = array();
foreach ($this->entityBundles as $key => $info) {
$expected[$key] = $info['label'];
}
$this->assertIdentical($view->filter['type']->getValueOptions(), $expected);
$view->destroy();
// Test each bundle type.
foreach ($this->entityBundles as $key => $info) {
// Test each bundle type.
$view->initDisplay();
$filters = $view->display_handler->getOption('filters');
$filters['type']['value'] = array($key => $key);
$view->display_handler->setOption('filters', $filters);
$this->executeView($view);
$this->assertEqual(count($view->result), count($this->entities[$key]));
$view->destroy();
}
// Test an invalid bundle type to make sure we have no results.
$view->initDisplay();
$filters = $view->display_handler->getOption('filters');
$filters['type']['value'] = array('type_3' => 'type_3');
$view->display_handler->setOption('filters', $filters);
$this->executeView($view);
$this->assertEqual(count($view->result), 0);
}
示例10: testHandlers
/**
* Tests the handlers.
*/
public function testHandlers()
{
$nodes = array();
$nodes[] = $this->drupalCreateNode();
$nodes[] = $this->drupalCreateNode();
$account = $this->drupalCreateUser();
$this->drupalLogin($account);
\Drupal::currentUser()->setAccount($account);
db_insert('history')->fields(array('uid' => $account->id(), 'nid' => $nodes[0]->id(), 'timestamp' => REQUEST_TIME - 100))->execute();
db_insert('history')->fields(array('uid' => $account->id(), 'nid' => $nodes[1]->id(), 'timestamp' => REQUEST_TIME + 100))->execute();
$column_map = array('nid' => 'nid');
// Test the history field.
$view = Views::getView('test_history');
$view->setDisplay('page_1');
$this->executeView($view);
$this->assertEqual(count($view->result), 2);
$output = $view->preview();
$this->setRawContent(\Drupal::service('renderer')->renderRoot($output));
$result = $this->xpath('//span[@class=:class]', array(':class' => 'marker'));
$this->assertEqual(count($result), 1, 'Just one node is marked as new');
// Test the history filter.
$view = Views::getView('test_history');
$view->setDisplay('page_2');
$this->executeView($view);
$this->assertEqual(count($view->result), 1);
$this->assertIdenticalResultset($view, array(array('nid' => $nodes[0]->id())), $column_map);
}
示例11: testGlossary
/**
* Tests the glossary feature.
*/
function testGlossary()
{
// Setup some nodes, one with a, two with b and three with c.
$counter = 1;
foreach (array('a', 'b', 'c') as $char) {
for ($i = 0; $i < $counter; $i++) {
$edit = array('title' => $char . $this->randomMachineName());
$this->drupalCreateNode($edit);
}
}
$view = Views::getView('test_glossary');
$this->executeView($view);
$count_field = 'nid';
foreach ($view->result as &$row) {
if (strpos($view->field['title']->getValue($row), 'a') === 0) {
$this->assertEqual(1, $row->{$count_field});
}
if (strpos($view->field['title']->getValue($row), 'b') === 0) {
$this->assertEqual(2, $row->{$count_field});
}
if (strpos($view->field['title']->getValue($row), 'c') === 0) {
$this->assertEqual(3, $row->{$count_field});
}
}
}
示例12: testCommentFieldName
/**
* Test comment field name.
*/
public function testCommentFieldName()
{
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$view = Views::getView('test_comment_field_name');
$this->executeView($view);
$expected_result = [['cid' => $this->comment->id(), 'field_name' => $this->comment->getFieldName()], ['cid' => $this->customComment->id(), 'field_name' => $this->customComment->getFieldName()]];
$column_map = ['cid' => 'cid', 'comment_field_data_field_name' => 'field_name'];
$this->assertIdenticalResultset($view, $expected_result, $column_map);
// Test that no data can be rendered.
$this->assertIdentical(FALSE, isset($view->field['field_name']));
// Grant permission to properly check view access on render.
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access comments']);
$this->container->get('account_switcher')->switchTo(new AnonymousUserSession());
$view = Views::getView('test_comment_field_name');
$this->executeView($view);
// Test that data rendered.
$output = $renderer->executeInRenderContext(new RenderContext(), function () use($view) {
return $view->field['field_name']->advancedRender($view->result[0]);
});
$this->assertIdentical($this->comment->getFieldName(), $output);
$output = $renderer->executeInRenderContext(new RenderContext(), function () use($view) {
return $view->field['field_name']->advancedRender($view->result[1]);
});
$this->assertIdentical($this->customComment->getFieldName(), $output);
}
示例13: testUserName
public function testUserName()
{
$this->drupalLogin($this->drupalCreateUser(array('access user profiles')));
$view = Views::getView('test_views_handler_field_user_name');
$this->executeView($view);
$view->field['name']->options['link_to_user'] = TRUE;
$username = $view->result[0]->users_field_data_name = $this->randomMachineName();
$view->result[0]->users_field_data_uid = 1;
$render = $view->field['name']->advancedRender($view->result[0]);
$this->assertTrue(strpos($render, $username) !== FALSE, 'If link to user is checked the username should be part of the output.');
$this->assertTrue(strpos($render, 'user/1') !== FALSE, 'If link to user is checked the link to the user should appear as well.');
$view->field['name']->options['link_to_user'] = FALSE;
$username = $view->result[0]->users_field_data_name = $this->randomMachineName();
$view->result[0]->users_field_data_uid = 1;
$render = $view->field['name']->advancedRender($view->result[0]);
$this->assertIdentical($render, $username, 'If the user is not linked the username should be printed out for a normal user.');
$view->result[0]->users_field_data_uid = 0;
$anon_name = \Drupal::config('user.settings')->get('anonymous');
$view->result[0]->users_field_data_name = '';
$render = $view->field['name']->advancedRender($view->result[0]);
$this->assertIdentical($render, $anon_name, 'For user0 it should use the default anonymous name by default.');
$view->field['name']->options['overwrite_anonymous'] = TRUE;
$anon_name = $view->field['name']->options['anonymous_text'] = $this->randomMachineName();
$render = $view->field['name']->advancedRender($view->result[0]);
$this->assertIdentical($render, $anon_name, 'For user0 it should use the configured anonymous text if overwrite_anonymous is checked.');
}
示例14: testCalculateDependencies
/**
* Tests the calculateDependencies method.
*/
public function testCalculateDependencies()
{
$expected = [];
$expected['test_field_get_entity'] = ['module' => ['comment', 'node', 'user']];
// Tests dependencies of relationships.
$expected['test_relationship_dependency'] = ['module' => ['comment', 'node', 'user']];
$expected['test_plugin_dependencies'] = ['module' => ['comment', 'views_test_data'], 'content' => ['RowTest', 'StaticTest', 'StyleTest']];
$expected['test_argument_dependency'] = ['config' => ['core.entity_view_mode.node.teaser', 'field.storage.node.body'], 'content' => ['ArgumentDefaultTest', 'ArgumentValidatorTest'], 'module' => ['node', 'search', 'text', 'user']];
foreach ($this::$testViews as $view_id) {
$view = Views::getView($view_id);
$dependencies = $view->calculateDependencies();
$this->assertEqual($expected[$view_id], $dependencies);
$config = $this->config('views.view.' . $view_id);
\Drupal::service('config.storage.staging')->write($view_id, $config->get());
}
// Ensure that dependencies are calculated on the display level.
$expected_display['default'] = ['config' => ['core.entity_view_mode.node.teaser'], 'content' => ['ArgumentDefaultTest', 'ArgumentValidatorTest'], 'module' => ['core', 'node', 'search', 'user', 'views']];
$expected_display['page'] = ['config' => ['field.storage.node.body'], 'module' => ['core', 'text', 'views']];
$view = Views::getView('test_argument_dependency');
$view->initDisplay();
foreach ($view->displayHandlers as $display) {
// Calculate the dependencies each display has.
$this->assertEqual($expected_display[$display->getPluginId()], $display->calculateDependencies());
}
}
示例15: testFileExtensionTarOption
/**
* Tests file extension views field handler extension_detect_tar option.
*/
public function testFileExtensionTarOption()
{
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$view = Views::getView('file_extension_view');
$view->setDisplay();
$this->executeView($view);
// Test without the tar option.
$renderer->executeInRenderContext(new RenderContext(), function () use($view) {
$this->assertEqual($view->field['extension']->advancedRender($view->result[0]), 'png');
$this->assertEqual($view->field['extension']->advancedRender($view->result[1]), 'tar');
$this->assertEqual($view->field['extension']->advancedRender($view->result[2]), 'gz');
$this->assertEqual($view->field['extension']->advancedRender($view->result[3]), '');
});
// Test with the tar option.
$view = Views::getView('file_extension_view');
$view->setDisplay();
$view->initHandlers();
$view->field['extension']->options['settings']['extension_detect_tar'] = TRUE;
$this->executeView($view);
$renderer->executeInRenderContext(new RenderContext(), function () use($view) {
$this->assertEqual($view->field['extension']->advancedRender($view->result[0]), 'png');
$this->assertEqual($view->field['extension']->advancedRender($view->result[1]), 'tar');
$this->assertEqual($view->field['extension']->advancedRender($view->result[2]), 'tar.gz');
$this->assertEqual($view->field['extension']->advancedRender($view->result[3]), '');
});
}