Skip to content

Commit

Permalink
Merge pull request #11 from open-source-contributions/improve_assertions
Browse files Browse the repository at this point in the history
Improve PHPUnit assertions
  • Loading branch information
fenric authored Feb 15, 2022
2 parents 58b8e04 + 748a91d commit 1e033a2
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/QueryFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public function testFilterBoolean() : void
$qf->allowFilterBy('foo', 'a.b', $qf::TYPE_BOOL);
$qf->apply($qb);
$this->assertSame('SELECT a FROM A a WHERE a.b = :p0', $qb->getDQL());
$this->assertSame(true, $qb->getParameter('p0')->getValue());
$this->assertTrue($qb->getParameter('p0')->getValue());

$qb = (new QueryBuilder($em))->select('a')->from('A', 'a');
$qf = new QueryFilter(['foo' => 'no']);
$qf->allowFilterBy('foo', 'a.b', $qf::TYPE_BOOL);
$qf->apply($qb);
$this->assertSame('SELECT a FROM A a WHERE a.b = :p0', $qb->getDQL());
$this->assertSame(false, $qb->getParameter('p0')->getValue());
$this->assertFalse($qb->getParameter('p0')->getValue());
}

public function testFilterBooleanWithEmptyString() : void
Expand Down Expand Up @@ -107,14 +107,14 @@ public function testFilterDate() : void
$qf->allowFilterBy('foo', 'a.b', $qf::TYPE_DATE);
$qf->apply($qb);
$this->assertSame('SELECT a FROM A a', $qb->getDQL());
$this->assertSame(null, $qb->getParameter('p0'));
$this->assertNull($qb->getParameter('p0'));

$qb = (new QueryBuilder($em))->select('a')->from('A', 'a');
$qf = new QueryFilter(['foo' => new \stdClass /* date invalid type */]);
$qf->allowFilterBy('foo', 'a.b', $qf::TYPE_DATE);
$qf->apply($qb);
$this->assertSame('SELECT a FROM A a', $qb->getDQL());
$this->assertSame(null, $qb->getParameter('p0'));
$this->assertNull($qb->getParameter('p0'));
}

public function testFilterDateMin() : void
Expand Down Expand Up @@ -240,21 +240,21 @@ public function testFilterNumeric() : void
$qf->allowFilterBy('foo', 'a.b', $qf::TYPE_NUM);
$qf->apply($qb);
$this->assertSame('SELECT a FROM A a', $qb->getDQL());
$this->assertSame(null, $qb->getParameter('p0'));
$this->assertNull($qb->getParameter('p0'));

$qb = (new QueryBuilder($em))->select('a')->from('A', 'a');
$qf = new QueryFilter(['foo' => 'not number']);
$qf->allowFilterBy('foo', 'a.b', $qf::TYPE_NUM);
$qf->apply($qb);
$this->assertSame('SELECT a FROM A a', $qb->getDQL());
$this->assertSame(null, $qb->getParameter('p0'));
$this->assertNull($qb->getParameter('p0'));

$qb = (new QueryBuilder($em))->select('a')->from('A', 'a');
$qf = new QueryFilter(['foo' => new \stdClass /* invalid number type */]);
$qf->allowFilterBy('foo', 'a.b', $qf::TYPE_NUM);
$qf->apply($qb);
$this->assertSame('SELECT a FROM A a', $qb->getDQL());
$this->assertSame(null, $qb->getParameter('p0'));
$this->assertNull($qb->getParameter('p0'));
}

public function testFilterNumericMin() : void
Expand Down Expand Up @@ -310,14 +310,14 @@ public function testFilterString() : void
$qf->allowFilterBy('foo', 'a.b', $qf::TYPE_STR);
$qf->apply($qb);
$this->assertSame('SELECT a FROM A a', $qb->getDQL());
$this->assertSame(null, $qb->getParameter('p0'));
$this->assertNull($qb->getParameter('p0'));

$qb = (new QueryBuilder($em))->select('a')->from('A', 'a');
$qf = new QueryFilter(['foo' => new \stdClass /* invalid string type */]);
$qf->allowFilterBy('foo', 'a.b', $qf::TYPE_STR);
$qf->apply($qb);
$this->assertSame('SELECT a FROM A a', $qb->getDQL());
$this->assertSame(null, $qb->getParameter('p0'));
$this->assertNull($qb->getParameter('p0'));
}

public function testFilterStringWithEmptyString() : void
Expand Down

0 comments on commit 1e033a2

Please sign in to comment.