|
@@ -7,6 +7,7 @@ use Doctrine\Common\EventManager;
|
|
use Doctrine\Common\Util\Debug,
|
|
use Doctrine\Common\Util\Debug,
|
|
SoftDeleteable\Fixture\Entity\Article,
|
|
SoftDeleteable\Fixture\Entity\Article,
|
|
SoftDeleteable\Fixture\Entity\Comment,
|
|
SoftDeleteable\Fixture\Entity\Comment,
|
|
|
|
+ SoftDeleteable\Fixture\Entity\User,
|
|
SoftDeleteable\Fixture\Entity\Page,
|
|
SoftDeleteable\Fixture\Entity\Page,
|
|
SoftDeleteable\Fixture\Entity\MegaPage,
|
|
SoftDeleteable\Fixture\Entity\MegaPage,
|
|
SoftDeleteable\Fixture\Entity\Module,
|
|
SoftDeleteable\Fixture\Entity\Module,
|
|
@@ -29,6 +30,7 @@ class SoftDeleteableEntityTest extends BaseTestCaseORM
|
|
const MEGA_PAGE_CLASS = 'SoftDeleteable\Fixture\Entity\MegaPage';
|
|
const MEGA_PAGE_CLASS = 'SoftDeleteable\Fixture\Entity\MegaPage';
|
|
const MODULE_CLASS = 'SoftDeleteable\Fixture\Entity\Module';
|
|
const MODULE_CLASS = 'SoftDeleteable\Fixture\Entity\Module';
|
|
const SOFT_DELETEABLE_FILTER_NAME = 'soft-deleteable';
|
|
const SOFT_DELETEABLE_FILTER_NAME = 'soft-deleteable';
|
|
|
|
+ const USER_CLASS = 'SoftDeleteable\Fixture\Entity\User';
|
|
|
|
|
|
private $softDeleteableListener;
|
|
private $softDeleteableListener;
|
|
|
|
|
|
@@ -45,6 +47,31 @@ class SoftDeleteableEntityTest extends BaseTestCaseORM
|
|
$this->em->getFilters()->enable(self::SOFT_DELETEABLE_FILTER_NAME);
|
|
$this->em->getFilters()->enable(self::SOFT_DELETEABLE_FILTER_NAME);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @test
|
|
|
|
+ */
|
|
|
|
+ public function shouldSoftlyDeleteIfColumnNameDifferFromPropertyName()
|
|
|
|
+ {
|
|
|
|
+ $repo = $this->em->getRepository(self::USER_CLASS);
|
|
|
|
+
|
|
|
|
+ $newUser = new User();
|
|
|
|
+ $username = 'test_user';
|
|
|
|
+ $newUser->setUsername($username);
|
|
|
|
+
|
|
|
|
+ $this->em->persist($newUser);
|
|
|
|
+ $this->em->flush();
|
|
|
|
+
|
|
|
|
+ $user = $repo->findOneBy(array('username' => $username));
|
|
|
|
+
|
|
|
|
+ $this->assertNull($user->getDeletedAt());
|
|
|
|
+
|
|
|
|
+ $this->em->remove($user);
|
|
|
|
+ $this->em->flush();
|
|
|
|
+
|
|
|
|
+ $user = $repo->findOneBy(array('username' => $username));
|
|
|
|
+ $this->assertNull($user);
|
|
|
|
+ }
|
|
|
|
+
|
|
public function testSoftDeleteable()
|
|
public function testSoftDeleteable()
|
|
{
|
|
{
|
|
$repo = $this->em->getRepository(self::ARTICLE_CLASS);
|
|
$repo = $this->em->getRepository(self::ARTICLE_CLASS);
|
|
@@ -168,7 +195,8 @@ class SoftDeleteableEntityTest extends BaseTestCaseORM
|
|
self::PAGE_CLASS,
|
|
self::PAGE_CLASS,
|
|
self::MEGA_PAGE_CLASS,
|
|
self::MEGA_PAGE_CLASS,
|
|
self::MODULE_CLASS,
|
|
self::MODULE_CLASS,
|
|
- self::COMMENT_CLASS
|
|
|
|
|
|
+ self::COMMENT_CLASS,
|
|
|
|
+ self::USER_CLASS
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|