function ContentCrudMultipleToSingleTest::testMultipleToSingle in Content Construction Kit (CCK) 6.2
Same name and namespace in other branches
- 6.3 tests/content.crud.test \ContentCrudMultipleToSingleTest::testMultipleToSingle()
- 6 tests/content.crud.test \ContentCrudMultipleToSingleTest::testMultipleToSingle()
File
- tests/
content.crud.test, line 524
Class
Code
function testMultipleToSingle() {
// Create a multivalue text field
$this
->createFieldText(array(
'text_processing' => 1,
'multiple' => 1,
));
$this
->assertSchemaMatchesTables(array(
'per_type' => array(
'simpletest_t1' => array(),
),
'per_field' => array(
'simpletest_f1' => array(
'delta',
'simpletest_f1' => array(
'value',
'format',
),
),
),
));
$this
->assertNodeSaveValues(0, array(
'simpletest_f1' => array(
0 => $this
->createRandomTextFieldData(),
1 => $this
->createRandomTextFieldData(),
2 => $this
->createRandomTextFieldData(),
),
));
// Change to a simple text field
$this
->updateField(array(
'multiple' => 0,
));
$this
->assertSchemaMatchesTables(array(
'per_type' => array(
'simpletest_t1' => array(
'simpletest_f1' => array(
'value',
'format',
),
),
),
'per_field' => array(
'simpletest_f1' => NULL,
),
));
$node0values = $this
->assertNodeSaveValues(0, array(
'simpletest_f1' => array(
0 => $this
->createRandomTextFieldData(),
),
));
// Share the text field with other content type
$this
->shareField(1);
$this
->assertSchemaMatchesTables(array(
'per_type' => array(
'simpletest_t1' => array(),
'simpletest_t2' => array(),
),
'per_field' => array(
'simpletest_f1' => array(
'simpletest_f1' => array(
'value',
'format',
),
),
),
));
$node1values = $this
->assertNodeSaveValues(1, array(
'simpletest_f1' => array(
0 => $this
->createRandomTextFieldData(),
),
));
$this
->assertNodeValues(0, $node0values);
// Share the text field with a 3rd type
$this
->shareField(2);
$this
->assertSchemaMatchesTables(array(
'per_type' => array(
'simpletest_t1' => array(),
'simpletest_t2' => array(),
'simpletest_t3' => array(),
),
'per_field' => array(
'simpletest_f1' => array(
'simpletest_f1' => array(
'value',
'format',
),
),
),
));
$this
->assertNodeSaveValues(2, array(
'simpletest_f1' => array(
0 => $this
->createRandomTextFieldData(),
),
));
$this
->assertNodeValues(1, $node1values);
$this
->assertNodeValues(0, $node0values);
// Remove text field from 3rd type
$this
->deleteField(2);
$this
->assertSchemaMatchesTables(array(
'per_type' => array(
'simpletest_t1' => array(),
'simpletest_t2' => array(),
'simpletest_t3' => NULL,
),
'per_field' => array(
'simpletest_f1' => array(
'simpletest_f1' => array(
'value',
'format',
),
),
),
));
$this
->assertNodeMissingFields($this->nodes[2], array(
'simpletest_f1',
));
// Remove text field from 2nd type (field isn't shared anymore)
$this
->deleteField(1);
$this
->assertSchemaMatchesTables(array(
'per_type' => array(
'simpletest_t1' => array(
'simpletest_f1' => array(
'value',
'format',
),
),
'simpletest_t2' => NULL,
'simpletest_t3' => NULL,
),
'per_field' => array(
'simpletest_f1' => NULL,
),
));
$this
->assertNodeMissingFields(1, array(
'simpletest_f1',
));
$this
->assertNodeValues(0, $node0values);
// Remove text field from original type
$this
->deleteField(0);
$this
->assertSchemaMatchesTables(array(
'per_type' => array(
'simpletest_t1' => NULL,
'simpletest_t2' => NULL,
'simpletest_t3' => NULL,
),
'per_field' => array(
'simpletest_f1' => NULL,
),
));
$this
->assertNodeMissingFields(0, array(
'simpletest_f1',
));
}