1 node.test | PagePreviewTestCase::setUp() |
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 BackdropWebTestCase::setUp
See also
BackdropWebTestCase::prepareDatabasePrefix()
BackdropWebTestCase::changeDatabasePrefix()
BackdropWebTestCase::prepareEnvironment()
File
- core/
modules/ node/ tests/ node.test, line 507 - Tests for node.module.
Class
- PagePreviewTestCase
- Tests the node entity preview functionality.
Code
function setUp() {
parent::setUp(array('taxonomy', 'node', 'email'));
$web_user = $this->backdropCreateUser(array(
'administer content types',
'edit own page content',
'create page content',
'administer nodes'
));
$this->backdropLogin($web_user);
// Add a vocabulary so we can test different view modes.
$vocabulary = new TaxonomyVocabulary(array(
'name' => $this->randomName(),
'description' => $this->randomName(),
'machine_name' => backdrop_strtolower($this->randomName()),
));
taxonomy_vocabulary_save($vocabulary);
// Add a term to the vocabulary.
$term = entity_create('taxonomy_term', array(
'name' => $this->randomName(),
'description' => $this->randomName(),
'format' => 1,
'vocabulary' => $vocabulary->machine_name,
));
taxonomy_term_save($term);
$this->term = $term;
// Create a field with settings to validate.
$this->field_email_name = backdrop_strtolower($this->randomName());
$field_email = array(
'field_name' => $this->field_email_name,
'type' => 'email',
);
field_create_field($field_email);
$email_instance = array(
'field_name' => $field_email['field_name'],
'entity_type' => 'node',
'bundle' => 'page',
'widget' => array(
'type' => 'email_default',
),
'display' => array(
'full' => array(
'type' => 'email_mailto',
),
),
);
field_create_instance($email_instance);
// Set up a field and instance.
$this->field_name = backdrop_strtolower($this->randomName());
$field = array(
'field_name' => $this->field_name,
'type' => 'taxonomy_term_reference',
'settings' => array(
'allowed_values' => array(
array(
'vocabulary' => $vocabulary->machine_name,
'parent' => '0',
),
),
)
);
field_create_field($field);
$instance = array(
'field_name' => $this->field_name,
'entity_type' => 'node',
'bundle' => 'page',
'widget' => array(
'type' => 'options_select',
),
// Hide on full display but render on teaser.
'display' => array(
'default' => array(
'type' => 'hidden',
),
'teaser' => array(
'type' => 'taxonomy_term_reference_link',
),
),
);
field_create_instance($instance);
}