public function BundleInherit::inheritPerform in Bundle Inherit 7
1 call to BundleInherit::inheritPerform()
- BundleInherit::testCRUD in ./
bundle_inherit.test - Run complex CRUD test based on node entity type.
File
- ./
bundle_inherit.test, line 55 - Tests for bundle_inherit module.
Class
- BundleInherit
- @file Tests for bundle_inherit module.
Code
public function inheritPerform() {
// When implementing inheritance on node entity type we should delete body
// field first.
if ($body_field_instance = field_info_instance('node', 'body', $this->childType->type)) {
field_delete_instance($body_field_instance);
}
// Perform inherit operations
bundle_inherit_perform('node', $this->childType->type, $this->parentType->type, TRUE);
$type_inherited = db_query('SELECT 1 FROM {bundle_inherit} WHERE entity_type = :entity_type AND bundle = :bundle AND bundle_parent = :bundle_parent', array(
':entity_type' => 'node',
':bundle' => $this->childType->type,
':bundle_parent' => $this->parentType->type,
))
->fetchField();
$this
->assertTrue($type_inherited, t('Type was inherited.'));
// Check if fields instances was succesfuly inherited
$n = 1;
foreach ($this->customFields as $field_name => $field) {
$parent_type_field_instance = $this->customFields[$field_name]['instance'];
$child_type_field_instance = field_info_instance('node', $field_name, $this->childType->type);
$this
->assertTrue($this
->compareInstances($parent_type_field_instance, $child_type_field_instance), t('Child field instance %n is equal to the parent one', array(
'%n' => $n++,
)));
}
}