public function viewsFieldViewTestCase::testChildViewWithFieldapiField in Views Field View 7
Test a child view using a fieldapi field.
File
- tests/
views_field_view.test, line 72 - Contains the test for views_field_view
Class
- viewsFieldViewTestCase
- @file Contains the test for views_field_view
Code
public function testChildViewWithFieldapiField() {
// Setup a fieldapi field.
$field_name = 'field_test_name';
field_create_field(array(
'field_name' => $field_name,
'type' => 'text',
));
field_create_instance(array(
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => 'page',
));
foreach ($this->nodes as $node) {
// "Reference" to itself to ensure that query aggregation works for
// fieldapi fields as well.
$node->{$field_name}[LANGUAGE_NONE][0]['value'] = $node->nid;
node_save($node);
}
// Get the child view and add it to the database, so it can be used later.
$child_view = $this
->view_child_field_api();
$child_view
->save();
views_invalidate_cache();
$parent_view = $this
->view_parent_field_api();
$parent_view
->save();
views_invalidate_cache();
$parent_view
->preview();
// Check that the child view has the same title as the parent one
foreach ($parent_view->result as $index => $values) {
$title = $parent_view->style_plugin
->get_field($index, 'title');
$child_view_field = $parent_view->style_plugin
->get_field($index, 'view');
$this
->assertContains($title, $child_view_field);
}
}