Skip to content

Commit

Permalink
Removal helper: fix STI
Browse files Browse the repository at this point in the history
  • Loading branch information
matej21 committed Jul 24, 2017
1 parent 7f8bf6b commit febe45e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Repository/RemovalHelper.php
Expand Up @@ -122,7 +122,7 @@ private static function setNulls(IEntity $entity, array $metadata, IModel $model

$reverseRepository = $model->getRepository($propertyMeta->relationship->repository);
$reverseProperty = $propertyMeta->relationship->property
? $reverseRepository->getEntityMetadata()->getProperty($propertyMeta->relationship->property)
? $reverseRepository->getEntityMetadata($propertyMeta->relationship->entity)->getProperty($propertyMeta->relationship->property)
: null;

if ($type === Relationship::MANY_HAS_MANY) {
Expand Down
21 changes: 21 additions & 0 deletions tests/cases/integration/Repository/repository.cascadeRemove.phpt
Expand Up @@ -10,7 +10,9 @@ namespace NextrasTests\Orm\Integration\Repository;
use Mockery;
use Nextras\Orm\InvalidStateException;
use NextrasTests\Orm\Book;
use NextrasTests\Orm\Comment;
use NextrasTests\Orm\DataTestCase;
use NextrasTests\Orm\Thread;
use Tester\Assert;

$dic = require_once __DIR__ . '/../../../bootstrap.php';
Expand Down Expand Up @@ -48,6 +50,25 @@ class RepostiroyCascadeRemoveTest extends DataTestCase
$this->orm->publishers->removeAndFlush(1);
}, InvalidStateException::class, 'Cannot remove NextrasTests\Orm\Publisher::$id=1 because NextrasTests\Orm\Book::$publisher cannot be a null.');
}


public function testSti()
{
$thread = new Thread();

$comment = new Comment();
$comment->thread = $thread;
$this->orm->persist($thread);
$this->orm->persist($comment);
$this->orm->flush();

$this->orm->remove($thread);
$this->orm->flush();

Assert::false($thread->isPersisted());
Assert::false($comment->isPersisted());
}

}


Expand Down

0 comments on commit febe45e

Please sign in to comment.