function viewsHandlerFieldFieldTest::_testMultipleFieldRender
1 call to viewsHandlerFieldFieldTest::_testMultipleFieldRender()
- viewsHandlerFieldFieldTest::testFieldRender in tests/
field/ views_fieldapi.test
File
-
tests/
field/ views_fieldapi.test, line 389
Class
- viewsHandlerFieldFieldTest
- Tests the field_field handler.
Code
public function _testMultipleFieldRender() {
$view = $this->getFieldView();
// Test delta limit.
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE;
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3;
$this->executeView($view);
for ($i = 0; $i < 3; $i++) {
$rendered_field = $view->style_plugin
->get_field($i, $this->fields[3]['field_name']);
$this->assertNotNull($rendered_field);
$items = array();
$pure_items = $this->nodes[$i]->{$this->fields[3]['field_name']}[LANGUAGE_NONE];
$pure_items = array_splice($pure_items, 0, 3);
foreach ($pure_items as $j => $item) {
$items[] = $pure_items[$j]['value'];
}
$this->assertEqual($rendered_field, implode(', ', $items), 'Take sure that the amount of items are limited.');
}
// Test that an empty field is rendered without error.
$rendered_field = $view->style_plugin
->get_field(4, $this->fields[4]['field_name']);
$view->destroy();
// Test delta limit + offset.
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE;
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3;
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_offset'] = 1;
$this->executeView($view);
for ($i = 0; $i < 3; $i++) {
$rendered_field = $view->style_plugin
->get_field($i, $this->fields[3]['field_name']);
$this->assertNotNull($rendered_field);
$items = array();
$pure_items = $this->nodes[$i]->{$this->fields[3]['field_name']}[LANGUAGE_NONE];
$pure_items = array_splice($pure_items, 1, 3);
foreach ($pure_items as $j => $item) {
$items[] = $pure_items[$j]['value'];
}
$this->assertEqual($rendered_field, implode(', ', $items), 'Take sure that the amount of items are limited.');
}
$view->destroy();
// Test delta limit + reverse.
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_offset'] = 0;
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE;
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3;
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_reversed'] = TRUE;
$this->executeView($view);
for ($i = 0; $i < 3; $i++) {
$rendered_field = $view->style_plugin
->get_field($i, $this->fields[3]['field_name']);
$this->assertNotNull($rendered_field);
$items = array();
$pure_items = $this->nodes[$i]->{$this->fields[3]['field_name']}[LANGUAGE_NONE];
array_splice($pure_items, 0, -3);
$pure_items = array_reverse($pure_items);
foreach ($pure_items as $j => $item) {
$items[] = $pure_items[$j]['value'];
}
$this->assertEqual($rendered_field, implode(', ', $items), 'Take sure that the amount of items are limited.');
}
$view->destroy();
// Test delta first last.
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE;
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_limit'] = 'all';
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_first_last'] = TRUE;
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_reversed'] = FALSE;
$this->executeView($view);
for ($i = 0; $i < 3; $i++) {
$rendered_field = $view->style_plugin
->get_field($i, $this->fields[3]['field_name']);
$this->assertNotNull($rendered_field);
$items = array();
$pure_items = $this->nodes[$i]->{$this->fields[3]['field_name']}[LANGUAGE_NONE];
$items[] = $pure_items[0]['value'];
$items[] = $pure_items[4]['value'];
$this->assertEqual($rendered_field, implode(', ', $items), 'Take sure that the amount of items are limited.');
}
$view->destroy();
// Test delta limit + custom seperator.
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_first_last'] = FALSE;
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3;
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE;
$view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['separator'] = ':';
$this->executeView($view);
for ($i = 0; $i < 3; $i++) {
$rendered_field = $view->style_plugin
->get_field($i, $this->fields[3]['field_name']);
$this->assertNotNull($rendered_field);
$items = array();
$pure_items = $this->nodes[$i]->{$this->fields[3]['field_name']}[LANGUAGE_NONE];
$pure_items = array_splice($pure_items, 0, 3);
foreach ($pure_items as $j => $item) {
$items[] = $pure_items[$j]['value'];
}
$this->assertEqual($rendered_field, implode(':', $items), 'Take sure that the amount of items are limited.');
}
}