diff --git a/.travis.yml b/.travis.yml index 46135df..695a1a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: php php: - 7.1 - 7.2 + - 7.3 install: composer install -n diff --git a/Driver/ORM/ActionManager.php b/Driver/ORM/ActionManager.php index 81d08a0..ddbc1ab 100644 --- a/Driver/ORM/ActionManager.php +++ b/Driver/ORM/ActionManager.php @@ -80,10 +80,8 @@ public function findOrCreateComponent($model, $identifier = null, $flush = true) $component = $this->getComponentRepository() ->createQueryBuilder('c') - ->where('c.model = :model') - ->andWhere('c.identifier = :identifier') - ->setParameter('model', $resolvedComponentData->getModel()) - ->setParameter('identifier', serialize($resolvedComponentData->getIdentifier())) + ->where('c.hash = :hash') + ->setParameter('hash', $resolvedComponentData->getHash()) ->getQuery() ->getOneOrNullResult() ; @@ -123,7 +121,7 @@ public function findComponents(array $hashes) $qb = $this->getComponentRepository()->createQueryBuilder('c'); return $qb->where( - $qb->expr()->in('c.hash', $hashes) + $qb->expr()->in('c.hash', $hashes) ) ->getQuery() ->getResult() diff --git a/Tests/Units/Driver/ORM/ActionManager.php b/Tests/Units/Driver/ORM/ActionManager.php index 7cdb7a2..c4258a7 100644 --- a/Tests/Units/Driver/ORM/ActionManager.php +++ b/Tests/Units/Driver/ORM/ActionManager.php @@ -26,9 +26,10 @@ public function testCreateComponent() ->and($componentClass = 'Spy\Timeline\Model\Component') ->and($actionComponentClass = 'Spy\Timeline\Model\ActionComponent') ->and($actionManager = new TestedModel($objectManager, $resultBuilder, $actionClass, $componentClass, $actionComponentClass)) - ->exception(function () use ($actionManager) { - $actionManager->getComponentDataResolver(); - } + ->exception( + function () use ($actionManager) { + $actionManager->getComponentDataResolver(); + } )->hasMessage('Component data resolver not set') ->and($actionManager->setComponentDataResolver($componentDataResolver)) ->when($result = $actionManager->createComponent($model, $identifier)) @@ -67,16 +68,22 @@ public function testfindOrCreateComponentWithExistingComponent() return $queryBuilder; }) //here we return the component as result of the query - ->and($this->calling($query)->getOneOrNullResult = function () use ($component) { return $component;}) + ->and($this->calling($query)->getOneOrNullResult = function () use ($component) { + return $component; + }) //grouping those did not work the method was __call - ->and($this->calling($queryBuilder)->where = function () use ($queryBuilder) { return $queryBuilder;}) + ->and($this->calling($queryBuilder)->where = function () use ($queryBuilder) { + return $queryBuilder; + }) ->and($this->calling($queryBuilder)->andWhere = function () use ($queryBuilder) { return $queryBuilder; }) ->and($this->calling($queryBuilder)->setParameter = function () use ($queryBuilder) { return $queryBuilder; }) - ->and($this->calling($queryBuilder)->getQuery = function () use ($query) { return $query;}) + ->and($this->calling($queryBuilder)->getQuery = function () use ($query) { + return $query; + }) ->and($actionClass = 'Spy\Timeline\Model\Action') ->and($componentClass = 'Spy\Timeline\Model\Component') ->and($actionComponentClass = 'Spy\Timeline\Model\ActionComponent') @@ -87,10 +94,8 @@ public function testfindOrCreateComponentWithExistingComponent() }) ->when($result = $actionManager->findOrCreateComponent('user', 1)) ->mock($componentDataResolver)->call('resolveComponentData')->withArguments($resolve)->exactly(1) - ->mock($queryBuilder)->call('where')->withArguments('c.model = :model')->exactly(1) - ->mock($queryBuilder)->call('andWhere')->withArguments('c.identifier = :identifier')->exactly(1) - ->mock($queryBuilder)->call('setParameter')->withArguments('model', $resolvedComponentData->getModel())->exactly(1) - ->mock($queryBuilder)->call('setParameter')->withArguments('identifier', serialize($resolvedComponentData->getIdentifier()))->exactly(1) + ->mock($queryBuilder)->call('where')->withArguments('c.hash = :hash')->exactly(1) + ->mock($queryBuilder)->call('setParameter')->withArguments('hash', $resolvedComponentData->getHAsh())->exactly(1) ->object($result)->isEqualTo($component) ; } diff --git a/composer.json b/composer.json index 4007eb3..0f26415 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ }], "require": { "php": "^7.1", - "stephpy/timeline": "^1.0", + "stephpy/timeline": "^1.2", "symfony/framework-bundle": "~2.0|~3.0|~4.0", "symfony/options-resolver": "~2.0|~3.0|~4.0" },