function ContentCrudSingleToMultipleTest::testSingleToMultiple in Content Construction Kit (CCK) 6.3
Same name and namespace in other branches
- 6 tests/content.crud.test \ContentCrudSingleToMultipleTest::testSingleToMultiple()
- 6.2 tests/content.crud.test \ContentCrudSingleToMultipleTest::testSingleToMultiple()
File
- tests/
content.crud.test, line 449
Class
Code
function testSingleToMultiple() {
// Create a simple text field
$this
->createFieldText(array(
'text_processing' => 1,
));
$target_schema = array(
'per_type' => array(
'simpletest_t1' => array(
'simpletest_f1' => array(
'value',
'format',
),
),
),
'per_field' => array(),
);
$this
->assertSchemaMatchesTables($target_schema);
$node0values = $this
->assertNodeSaveValues(0, array(
'simpletest_f1' => array(
0 => $this
->createRandomTextFieldData(),
),
));
// Change the text field to allow multiple values
$this
->updateField(array(
'multiple' => 1,
));
$target_schema = array(
'per_type' => array(
'simpletest_t1' => array(),
),
'per_field' => array(
'simpletest_f1' => array(
'delta',
'simpletest_f1' => array(
'value',
'format',
),
),
),
);
$this
->assertSchemaMatchesTables($target_schema);
$this
->assertNodeValues(0, $node0values);
// Share the text field with 2 additional types t2 and t3.
for ($share_with_content_type = 1; $share_with_content_type <= 2; $share_with_content_type++) {
$this
->shareField($share_with_content_type);
// There should be a new 'empty' per-type table for each content type that has fields.
$target_schema['per_type']['simpletest_t' . ($share_with_content_type + 1)] = array();
$this
->assertSchemaMatchesTables($target_schema);
// 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);
// Content types that don't have fields any more shouldn't have any per-type table.
$target_schema['per_type']['simpletest_t' . ($delete_from_content_type + 1)] = NULL;
// After removing the last instance, there should be no table for the field either.
if ($delete_from_content_type == 0) {
$target_schema['per_field']['simpletest_f1'] = NULL;
}
$this
->assertSchemaMatchesTables($target_schema);
// 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',
));
}
}