Skip to content

Commit

Permalink
Merge pull request #258 from peter-gribanov/doctrine_orm_2.5
Browse files Browse the repository at this point in the history
Require Doctrine ORM 2.5
  • Loading branch information
peter-gribanov authored Dec 3, 2020
2 parents c4ed36f + c5a22f4 commit bb854ea
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
dependencies:
# TODO require phpspec/phpspec >= 6.3.0 and doctrine/orm >= 2.5
# TODO require phpspec/phpspec >= 6.3.0
#- lowest
- highest
php-version:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],
"require": {
"php": ">=7.0",
"doctrine/orm": ">=2.2.3"
"doctrine/orm": "~2.5"
},
"require-dev": {
"phpspec/phpspec": "~2.1"
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/InstanceOfX.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ public function getFilter(QueryBuilder $qb, $dqlAlias)
$dqlAlias = $this->dqlAlias;
}

return sprintf('%s INSTANCE OF %s', $dqlAlias, $this->value);
return (string) $qb->expr()->isInstanceOf($dqlAlias, $this->value);
}
}
9 changes: 8 additions & 1 deletion tests/Filter/InstanceOfXSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace tests\Happyr\DoctrineSpecification\Filter;

use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\Query\Expr\Comparison;
use Doctrine\ORM\QueryBuilder;
use Happyr\DoctrineSpecification\Filter\Filter;
use Happyr\DoctrineSpecification\Filter\InstanceOfX;
Expand All @@ -39,8 +41,13 @@ public function it_is_an_expression()
$this->shouldBeAnInstanceOf(Filter::class);
}

public function it_returns_expression_func_object(QueryBuilder $qb)
public function it_returns_expression_func_object(QueryBuilder $qb, Expr $exp)
{
$exp_comparison = new Comparison('o', 'INSTANCE OF', 'My\Model');
$exp->isInstanceOf('o', 'My\Model')->willReturn($exp_comparison);

$qb->expr()->willReturn($exp);

$this->getFilter($qb, null)->shouldReturn('o INSTANCE OF My\Model');
}
}

0 comments on commit bb854ea

Please sign in to comment.