diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index e979b51a..f056a561 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -3,9 +3,9 @@ on: push: branches: - master - pull_request: - branches: - - master + pull_request: + branches: + - master jobs: run-tests: name: PHP ${{ matrix.php-versions }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 87a8f241..d280ad3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,10 +25,11 @@ All notable changes to this project will be documented in this file, in reverse ### Removed - Deprecated `Api::VERSION` constant +- Removed dependency on APC-BC Extension ### Fixed -- Nothing. +- [#18](https://github.com/netglue/prismic-php-kit/pull/18) correctly serializes booleans for predicates when querying the api. ## 4.3.0 - 2020-03-12 diff --git a/src/Prismic/SimplePredicate.php b/src/Prismic/SimplePredicate.php index 09135920..d707be15 100644 --- a/src/Prismic/SimplePredicate.php +++ b/src/Prismic/SimplePredicate.php @@ -5,6 +5,7 @@ use function implode; use function is_array; +use function is_bool; use function is_string; class SimplePredicate implements Predicate @@ -55,6 +56,10 @@ private function serializeField($value) : string return '"' . $value . '"'; } + if (is_bool($value)) { + return $value ? 'true' : 'false'; + } + if (is_array($value)) { $fields = []; foreach ($value as $elt) { diff --git a/tests/Prismic/PredicatesTest.php b/tests/Prismic/PredicatesTest.php index e97aab6f..6ce5abba 100644 --- a/tests/Prismic/PredicatesTest.php +++ b/tests/Prismic/PredicatesTest.php @@ -308,4 +308,12 @@ public function testGeopointNear() : void $p = Predicates::near('my.store.coordinates', 40.689757, -74.0451453, 15); $this->assertEquals('[:d = geopoint.near(my.store.coordinates, 40.689757, -74.0451453, 15)]', $p->q()); } + + public function testAtPredicateAcceptsBooleanValue() : void + { + $p = Predicates::at('my.doc.field', true); + $this->assertEquals('[:d = at(my.doc.field, true)]', $p->q()); + $p = Predicates::at('my.doc.field', false); + $this->assertEquals('[:d = at(my.doc.field, false)]', $p->q()); + } }