mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
DataObject->duplicate() test
Advanced relationship copying is already tested further down, but doesn't cover the same basics. Triggered by a CMS bug which turned out to be unrelated (https://github.com/silverstripe/silverstripe-cms/issues/689)
This commit is contained in:
parent
677122256e
commit
1a52a51195
@ -8,6 +8,26 @@ class DataObjectDuplicationTest extends SapphireTest {
|
||||
'DataObjectDuplicateTestClass3'
|
||||
);
|
||||
|
||||
public function testDuplicate() {
|
||||
$orig = new DataObjectDuplicateTestClass1();
|
||||
$orig->text = 'foo';
|
||||
$orig->write();
|
||||
|
||||
$duplicate = $orig->duplicate();
|
||||
$this->assertInstanceOf('DataObjectDuplicateTestClass1', $duplicate,
|
||||
'Creates the correct type'
|
||||
);
|
||||
$this->assertNotEquals($duplicate->ID, $orig->ID,
|
||||
'Creates a unique record'
|
||||
);
|
||||
$this->assertEquals('foo', $duplicate->text,
|
||||
'Copies fields'
|
||||
);
|
||||
$this->assertEquals(2, DataObjectDuplicateTestClass1::get()->Count(),
|
||||
'Only creates a single duplicate'
|
||||
);
|
||||
}
|
||||
|
||||
public function testDuplicateManyManyClasses() {
|
||||
//create new test classes below
|
||||
$one = new DataObjectDuplicateTestClass1();
|
||||
|
Loading…
Reference in New Issue
Block a user