From 21a6f431db0b21b3cd994b31e9b7ca6276912f75 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Fri, 3 May 2019 22:09:50 +0100 Subject: [PATCH] Get FilterTest passing again for now --- src/Model/Filter.php | 12 +++++++++++- tests/Unit/Model/FilterTest.php | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Model/Filter.php b/src/Model/Filter.php index ed8c26c..6e07eb1 100644 --- a/src/Model/Filter.php +++ b/src/Model/Filter.php @@ -274,7 +274,17 @@ class Filter */ public function toArray(): array { - return $this->properties; + return collect($this->properties)->merge( + $this->conditions->flatten(1)->mapWithKeys(function (FilterCondition $condition) { + $values = $condition->getValues(); + + return [ + $condition->getProperty() => $values->count() == 1 + ? $values->first() + : $values + ]; + }) + )->toArray(); } public function getConditions(): Collection diff --git a/tests/Unit/Model/FilterTest.php b/tests/Unit/Model/FilterTest.php index ba1be91..04fd10b 100644 --- a/tests/Unit/Model/FilterTest.php +++ b/tests/Unit/Model/FilterTest.php @@ -358,7 +358,7 @@ class FilterTest extends TestCase 'shouldStar' => 'true', 'shouldAlwaysMarkAsImportant' => 'true', ], - $this->filter->from(['foo@example.com ', 'bar@example.com']) + $this->filter->from(['foo@example.com', 'bar@example.com']) ->has('Something') ->excludeChats() ->labelAndArchive('Foo')