From d916b8e16501faaea8f70674e1b502702ea90617 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Fri, 1 Jun 2018 20:26:06 +0100 Subject: [PATCH] Allow for setting multiple subject conditions --- src/Model/Filter.php | 8 +++++--- tests/Unit/FilterTest.php | 13 ++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Model/Filter.php b/src/Model/Filter.php index 4d71ff3..c7e4d03 100644 --- a/src/Model/Filter.php +++ b/src/Model/Filter.php @@ -74,13 +74,15 @@ class Filter } /** - * @param string $subject + * @param string|array $values * * @return $this */ - public function subject($subject) + public function subject($values) { - $this->properties['subject'] = $subject; + $this->properties['subject'] = collect($values)->map(function ($value) { + return json_encode($value); + })->implode('|'); return $this; } diff --git a/tests/Unit/FilterTest.php b/tests/Unit/FilterTest.php index f3cc066..c95c5fb 100644 --- a/tests/Unit/FilterTest.php +++ b/tests/Unit/FilterTest.php @@ -102,11 +102,22 @@ class FilterTest extends TestCase public function testSubject() { $this->assertEquals( - ['subject' => 'Something'], + ['subject' => '"Something"'], $this->filter->subject('Something')->toArray() ); } + /** + * Test that multiple subject conditions can be added. + */ + public function testMultipleSubjectsCanBeAdded() + { + $this->assertEquals( + ['subject' => '"Test"|"Foo bar"'], + $this->filter->subject(['Test', 'Foo bar'])->toArray() + ); + } + /** * @covers Filter::hasAttachment() */