class ContentCrudSingleToMultipleTest in Content Construction Kit (CCK) 6
Same name and namespace in other branches
- 6.3 tests/content.crud.test \ContentCrudSingleToMultipleTest
- 6.2 tests/content.crud.test \ContentCrudSingleToMultipleTest
Hierarchy
- class \ContentCrudTestCase extends \DrupalTestCase
Expanded class hierarchy of ContentCrudSingleToMultipleTest
File
- tests/
content.crud.test, line 361
View source
class ContentCrudSingleToMultipleTest extends ContentCrudTestCase {
function get_info() {
return array(
'name' => t('CCK CRUD API - Single to multiple'),
'desc' => t('Tests the CRUD (create, read, update, delete) API for content types by creating a single value field and chaning it to a multivalue field, sharing it between several content types.'),
'group' => t('CCK'),
);
}
function testSingleToMultiple() {
// Acquire the context
$this
->loginWithPermissions();
$this
->acquireContentTypes(3);
$this
->acquireNodes();
// Create a simple text field
$this
->createFieldText(array(
'text_processing' => 1,
));
$this
->assertSchemaMatchesTables(array(
'per_type' => array(
'simpletest_t1' => array(
'simpletest_f1' => array(
'value',
'format',
),
),
),
));
$node0values = $this
->assertNodeSaveValues(0, array(
'simpletest_f1' => array(
0 => $this
->createRandomTextFieldData(),
),
));
// Change the text field to allow multiple values
$this
->updateField(array(
'multiple' => 1,
));
$this
->assertSchemaMatchesTables(array(
'per_type' => array(
'simpletest_t1' => array(),
),
'per_field' => array(
'simpletest_f1' => array(
'delta',
'simpletest_f1' => array(
'value',
'format',
),
),
),
));
$this
->assertNodeValues(0, $node0values);
// Share the text field with other content types
for ($share_with_content_type = 1; $share_with_content_type <= 2; $share_with_content_type++) {
$this
->shareField($share_with_content_type);
$this
->assertSchemaMatchesTables(array(
'per_type' => array(
'simpletest_t' . ($share_with_content_type + 1) => array(),
),
));
// The acquired node index will match the content type index as exactly one node is acquired per content type
$this
->assertNodeSaveValues($share_with_content_type, array(
'simpletest_f1' => array(
0 => $this
->createRandomTextFieldData(),
),
));
}
// Delete the text field from all content types
for ($delete_from_content_type = 2; $delete_from_content_type >= 0; $delete_from_content_type--) {
$this
->deleteField($delete_from_content_type);
// The acquired node index will match the content type index as exactly one node is acquired per content type
$this
->assertNodeMissingFields($this->nodes[$delete_from_content_type], array(
'simpletest_f1',
));
}
$this
->assertSchemaMatchesTables(array(
'per_type' => array(
'simpletest_t1' => NULL,
'simpletest_t2' => NULL,
'simpletest_t3' => NULL,
),
));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContentCrudSingleToMultipleTest:: |
function | |||
ContentCrudSingleToMultipleTest:: |
function | |||
ContentCrudTestCase:: |
property | |||
ContentCrudTestCase:: |
property | |||
ContentCrudTestCase:: |
property | |||
ContentCrudTestCase:: |
property | |||
ContentCrudTestCase:: |
property | |||
ContentCrudTestCase:: |
function | Creates a number of content types with predictable names (simpletest_t1 ... simpletest_tN) These content types can later be accessed via $this->content_types[0 ... N-1] | ||
ContentCrudTestCase:: |
function | Creates a number of nodes of each acquired content type. Remember to call acquireContentTypes() before calling this, else the content types won't exist. | ||
ContentCrudTestCase:: |
function | Checks that the output from node_load is missing certain fields | ||
ContentCrudTestCase:: |
function | Checks that after a node is saved using node_save, the values to be saved match up with the output from node_load. | ||
ContentCrudTestCase:: |
function | Checks that the output from node_load matches the expected values. | ||
ContentCrudTestCase:: |
function | Checks that the database itself and the reported database schema match the expected columns for the given tables. | ||
ContentCrudTestCase:: |
function | Creates a field instance with a predictable name. Also makes all future calls to functions which take an optional field use this one as the default. | ||
ContentCrudTestCase:: |
function | Creates a textfield instance. Identical to createField() except it ensures that the text module is enabled, and adds default settings of type (text) and widget_type (text_textfield) if they are not given in $settings. @sa createField() | ||
ContentCrudTestCase:: |
function | Creates random values for a text field | ||
ContentCrudTestCase:: |
function | Deletes an instance of a field. | ||
ContentCrudTestCase:: |
function | Creates a user / role with certain permissions and then logs in as that user | ||
ContentCrudTestCase:: |
function | 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. | ||
ContentCrudTestCase:: |
function | Updates a field instance. Also makes all future calls to functions which take an optional field use the updated one as the default. | ||
ContentCrudTestCase:: |
function | Helper function for assertSchemaMatchesTables Checks that the database and schema for the given table contain only the correct fields | ||
ContentCrudTestCase:: |
function | Helper function for assertSchemaMatchesTables Checks that the given database table does NOT exist | ||
ContentCrudTestCase:: |
function | Helper function for assertNodeSaveValues. Recursively checks that all the keys of a table are present in a second and have the same value. |