1 field_views.test | protected FieldViewsDataTest::setUp(array $modules = array()) |
Sets up a Backdrop site for running functional and integration tests.
Generates a random database prefix and installs Backdrop with the specified installation profile in BackdropWebTestCase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.
After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.
Parameters
...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.
Return value
bool: TRUE if set up completes, FALSE if an error occurred.
Overrides ViewsSqlTest::setUp
See also
BackdropWebTestCase::prepareDatabasePrefix()
BackdropWebTestCase::changeDatabasePrefix()
BackdropWebTestCase::prepareEnvironment()
File
- core/
modules/ field/ tests/ field_views.test, line 117 - Tests the Views integration with Field API.
Class
- FieldViewsDataTest
- Test the produced views_data.
Code
protected function setUp(array $modules = array()) {
parent::setUp($modules);
$langcode = LANGUAGE_NONE;
$field_names = $this->setUpFields();
// The first one will be attached to nodes only.
$instance = array(
'field_name' => $field_names[0],
'entity_type' => 'node',
'bundle' => 'page',
);
field_create_instance($instance);
// The second one will be attached to users only.
$instance = array(
'field_name' => $field_names[1],
'entity_type' => 'user',
'bundle' => 'user',
);
field_create_instance($instance);
// The third will be attached to both nodes and users.
$instance = array(
'field_name' => $field_names[2],
'entity_type' => 'node',
'bundle' => 'page',
);
field_create_instance($instance);
$instance = array(
'field_name' => $field_names[2],
'entity_type' => 'user',
'bundle' => 'user',
);
field_create_instance($instance);
// Now create some example nodes/users for the view result.
for ($i = 0; $i < 5; $i++) {
$edit = array(
// @TODO Write a helper method to create such values.
'field_name_0' => array($langcode => array((array('value' => $this->randomName())))),
'field_name_2' => array($langcode => array((array('value' => $this->randomName())))),
);
$this->nodes[] = $this->backdropCreateNode($edit);
}
for ($i = 0; $i < 5; $i++) {
$edit = array(
'field_name_1' => array($langcode => array((array('value' => $this->randomName())))),
'field_name_2' => array($langcode => array((array('value' => $this->randomName())))),
);
$this->users[] = $this->CreateUser($edit);
}
// Reset views data cache.
$this->clearViewsCaches();
}