Refactor Forms::trash() to use Doctrine

[MAILPOET-3039]
This commit is contained in:
Rodrigo Primo
2021-04-01 15:03:56 -03:00
committed by Veljko V
parent 86fa574ce8
commit e054f05222
4 changed files with 53 additions and 8 deletions

View File

@ -0,0 +1,33 @@
<?php
namespace MailPoet\Form;
use MailPoet\Entities\FormEntity;
class FormsRepositoryTest extends \MailPoetTest {
/** @var FormsRepository */
private $repository;
public function _before() {
parent::_before();
$this->repository = $this->diContainer->get(FormsRepository::class);
}
public function testItCanTrashForm() {
$form = $this->createForm('Form 1');
expect($form->getDeletedAt())->null();
$this->repository->trash($form);
expect($form->getDeletedAt())->notNull();
}
public function _after() {
$this->truncateEntity(FormEntity::class);
}
private function createForm(string $name): FormEntity {
$form = new FormEntity($name);
$this->repository->persist($form);
$this->repository->flush();
return $form;
}
}