public function SearchByPageAttachTest::setUpTypes in Search by Page 8
Sets up File field for content type.
4 calls to SearchByPageAttachTest::setUpTypes()
- SearchbyPageAttach2Test::setUp in tests/
src/ Functional/ search_by_page.test - SearchbyPageAttachNotReadable::setUp in tests/
src/ Functional/ search_by_page.test - SearchbyPageAttachReindexTest::setUp in tests/
src/ Functional/ search_by_page.test - SearchByPageAttachTest::setUp in tests/
src/ Functional/ search_by_page.test
File
- tests/
src/ Functional/ search_by_page.test, line 1925 - 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.
Namespace
Drupal\Tests\search_by_page\FunctionalCode
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 search_by_page_indexed and spb_hidden content types.
$instance = array(
'field_name' => $field['field_name'],
'entity_type' => 'node',
'bundle' => 'search_by_page_indexed',
'settings' => array(
'file_extensions' => 'txt not',
'description_field' => 1,
),
'label' => 'A file',
);
field_create_instance($instance);
$instance['bundle'] = 'search_by_page_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('search_by_page_indexed', $fieldinfo['bundles']['node']), 'Field is attached to search_by_page_indexed');
$this
->assertTrue(in_array('search_by_page_hidden', $fieldinfo['bundles']['node']), 'Field is attached to search_by_page_hidden');
}