public function SearchByPageAttachTest::setUpTypes in Search by Page 7
Sets up File field for content type.
4 calls to SearchByPageAttachTest::setUpTypes()
- SearchbyPageAttach2Test::setUp in tests/
search_by_page.test - Sets up a Drupal site for running functional and integration tests.
- SearchbyPageAttachNotReadable::setUp in tests/
search_by_page.test - Sets up a Drupal site for running functional and integration tests.
- SearchbyPageAttachReindexTest::setUp in tests/
search_by_page.test - Sets up a Drupal site for running functional and integration tests.
- SearchByPageAttachTest::setUp in tests/
search_by_page.test - Sets up a Drupal site for running functional and integration tests.
File
- tests/
search_by_page.test, line 2239 - Tests for the Search by Page module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com
Class
- SearchByPageAttachTest
- Functionality test 1 for Search by Page Attachments.
Code
public function setUpTypes() {
// Create the field type.
$field = array(
'field_name' => 'field_myfile',
'type' => 'file',
'cardinality' => 5,
'settings' => array(
'display_field' => 1,
'display_default' => 1,
),
);
$field = field_create_field($field);
$this
->assertTrue($field['id'], "Field was given an ID");
$this->fieldid = $field['id'];
// Attach it to both sbp_indexed and spb_hidden content types.
$instance = array(
'field_name' => $field['field_name'],
'entity_type' => 'node',
'bundle' => 'sbp_indexed',
'settings' => array(
'file_extensions' => 'txt not',
'description_field' => 1,
),
'label' => 'A file',
);
field_create_instance($instance);
$instance['bundle'] = 'sbp_hidden';
field_create_instance($instance);
// Verify the field was attached.
$fieldinfo = field_info_field_by_id($field['id']);
$this
->assertTrue($fieldinfo, "Field information could be read");
$this
->assertEqual($fieldinfo['field_name'], 'field_myfile', "Field name is correct");
$this
->assertTrue(count($fieldinfo['bundles']), 'Field is attached to a bundle');
$this
->assertTrue(count($fieldinfo['bundles']['node']), 'Field is attached to a node bundle');
$this
->assertTrue(in_array('sbp_indexed', $fieldinfo['bundles']['node']), 'Field is attached to sbp_indexed');
$this
->assertTrue(in_array('sbp_hidden', $fieldinfo['bundles']['node']), 'Field is attached to sbp_hidden');
}