Refactor Forms::duplicate() to use Doctrine instead of Paris
[MAILPOET-3038]
This commit is contained in:
41
tests/integration/Form/FormSaveControllerTest.php
Normal file
41
tests/integration/Form/FormSaveControllerTest.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Form;
|
||||
|
||||
use Codeception\Util\Fixtures;
|
||||
use MailPoet\Entities\FormEntity;
|
||||
|
||||
class FormSaveControllerTest extends \MailPoetTest {
|
||||
/** @var FormSaveController */
|
||||
private $saveController;
|
||||
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$this->saveController = $this->diContainer->get(FormSaveController::class);
|
||||
}
|
||||
|
||||
public function testItDuplicatesForms() {
|
||||
$form = $this->createForm();
|
||||
$duplicate = $this->saveController->duplicate($form);
|
||||
expect($duplicate->getName())->equals('Copy of ' . $form->getName());
|
||||
expect($duplicate->getDeletedAt())->equals(null);
|
||||
expect($duplicate->getBody())->equals($form->getBody());
|
||||
expect($duplicate->getStatus())->equals($form->getStatus());
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
$this->cleanup();
|
||||
}
|
||||
|
||||
private function createForm(): FormEntity {
|
||||
$form = new FormEntity('My Form');
|
||||
$form->setBody(Fixtures::get('form_body_template'));
|
||||
$this->entityManager->persist($form);
|
||||
$this->entityManager->flush();
|
||||
return $form;
|
||||
}
|
||||
|
||||
private function cleanup() {
|
||||
$this->truncateEntity(FormEntity::class);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user