public function FileEntityViewsFieldLinkUsageHandlerTest::testViewsUsageField in File Entity (fieldable files) 7.2
Same name and namespace in other branches
- 7.3 file_entity_views.test \FileEntityViewsFieldLinkUsageHandlerTest::testViewsUsageField()
Test views file usage handlers.
File
- ./
file_entity_views.test, line 34 - Definition of FileEntityViewsFieldLinkUsageHandlerTest.
Class
- FileEntityViewsFieldLinkUsageHandlerTest
- Tests for file_entity views file usage handlers.
Code
public function testViewsUsageField() {
$file = $this
->createFileEntity();
file_usage_add($file, 'foo', 'bar', 1, 1);
file_usage_add($file, 'foo', 'bar', 1, 2);
$file2 = $this
->createFileEntity();
file_usage_add($file2, 'foo', 'bar', 1, 99);
$view = $this
->getTestView();
$view
->set_display();
$view
->pre_execute();
$view
->execute();
$row = $view->result[0];
$render = $view->field['usage']
->render_link($row, $row);
$this
->assertEqual($render, '1 place');
$row = $view->result[1];
$render = $view->field['usage']
->render_link($row, $row);
$this
->assertEqual($render, '1 place');
$view->field['usage']->options['count_entities_once'] = 0;
$row = $view->result[0];
$render = $view->field['usage']
->render_link($row, $row);
$this
->assertEqual($render, '3 places');
$row = $view->result[1];
$render = $view->field['usage']
->render_link($row, $row);
$this
->assertEqual($render, '99 places');
}