diff --git a/tests/model/DataObjectDuplicationTest.php b/tests/model/DataObjectDuplicationTest.php index 953eaa0b4..5d61b7a85 100644 --- a/tests/model/DataObjectDuplicationTest.php +++ b/tests/model/DataObjectDuplicationTest.php @@ -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();