You are here

function ContentCrudTestCase::shareField in Content Construction Kit (CCK) 6.3

Same name and namespace in other branches
  1. 6 tests/content.crud.test \ContentCrudTestCase::shareField()
  2. 6.2 tests/content.crud.test \ContentCrudTestCase::shareField()

Makes a copy of a field instance on a different content type, effectively sharing the field with a new content type. Also makes all future calls to functions which take an optional field use the shared one as the default.

Parameters

$new_content_type Either a content type object, or the index of an acquired content type:

$field The field instance to share (defaults to the last worked upon field):

Return value

The shared (newly created) field instance.

2 calls to ContentCrudTestCase::shareField()
ContentCrudMultipleToSingleTest::testMultipleToSingle in tests/content.crud.test
ContentCrudSingleToMultipleTest::testSingleToMultiple in tests/content.crud.test

File

tests/content.crud.test, line 347

Class

ContentCrudTestCase
Base class for CCK CRUD tests. Defines many helper functions useful for writing CCK CRUD tests.

Code

function shareField($new_content_type, $field = NULL) {
  if (!isset($field)) {
    $field = $this->last_field;
  }
  if (is_numeric($new_content_type) && isset($this->content_types[$new_content_type])) {
    $new_content_type = $this->content_types[$new_content_type];
  }
  $field['type_name'] = $new_content_type->type;
  $this->last_field = content_field_instance_create($field);
  return $this->last_field;
}