public function testRollbackReplacesFile() { file_put_contents($this->file->getFullPath(), 'second-version'); $this->file->createVersion(); $this->logInWithPermission('ADMIN'); $this->getFileEditForm(); $this->assertEquals('second-version', file_get_contents($this->file->CurrentVersion()->getFullPath())); $form = $this->mainSession->lastPage()->getFormById('Form_ItemEditForm'); $url = Director::makeRelative($form->getAction()->asString()); $data = array(); foreach ($form->_widgets as $widget) { $data[$widget->getName()] = $widget->getValue(); } $this->post($url, array_merge($data, array('Replace' => 'rollback', 'PreviousVersion' => 1, 'ReplacementFile' => array()))); $this->assertEquals('first-version', file_get_contents($this->file->getFullPath())); $this->assertEquals(1, DataObject::get_by_id('File', $this->file->ID)->getVersionNumber()); }