From d5d9f72375509dcac165ed36f488343d2bde8d2b Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Fri, 3 Nov 2017 23:45:54 +0000 Subject: [PATCH] Add more methods --- src/Filter.php | 42 +++++++++++++++++++++++++++++++ tests/Unit/FilterTest.php | 52 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/src/Filter.php b/src/Filter.php index 9fe67ce..4e77b2e 100644 --- a/src/Filter.php +++ b/src/Filter.php @@ -67,6 +67,48 @@ class Filter return $this; } + public function read() + { + $this->properties['markAsRead'] = 'true'; + + return $this; + } + + public function star() + { + $this->properties['shouldStar'] = 'true'; + + return $this; + } + + public function forward($to) + { + $this->properties['forwardTo'] = $to; + + return $this; + } + + public function important() + { + $this->properties['shouldAlwaysMarkAsImportant'] = 'true'; + + return $this; + } + + public function notImportant() + { + $this->properties['shouldNeverMarkAsImportant'] = 'true'; + + return $this; + } + + public function categorise($category) + { + $this->properties['smartLabelToApply'] = $category; + + return $this; + } + public function getProperties() { return $this->properties; diff --git a/tests/Unit/FilterTest.php b/tests/Unit/FilterTest.php index b87dcd6..031dc71 100644 --- a/tests/Unit/FilterTest.php +++ b/tests/Unit/FilterTest.php @@ -124,6 +124,54 @@ class FilterTest extends \PHPUnit_Framework_TestCase ); } + public function testMarkAsRead() + { + $this->assertEquals( + ['markAsRead' => 'true'], + $this->filter->read()->getProperties() + ); + } + + public function testStar() + { + $this->assertEquals( + ['shouldStar' => 'true'], + $this->filter->star()->getProperties() + ); + } + + public function testForwardTo() + { + $this->assertEquals( + ['forwardTo' => 'foo@example.com'], + $this->filter->forward('foo@example.com')->getProperties() + ); + } + + public function testMarkImportant() + { + $this->assertEquals( + ['shouldAlwaysMarkAsImportant' => 'true'], + $this->filter->important()->getProperties() + ); + } + + public function testMarkNotImportant() + { + $this->assertEquals( + ['shouldNeverMarkAsImportant' => 'true'], + $this->filter->notImportant()->getProperties() + ); + } + public function testCategorise() + { + $this->assertEquals( + ['smartLabelToApply' => 'Foo'], + $this->filter->categorise('Foo')->getProperties() + ); + } + + public function testMethodsCanBeChained() { $this->assertEquals( @@ -131,14 +179,18 @@ class FilterTest extends \PHPUnit_Framework_TestCase 'from' => 'foo@example.com,bar@example.com', 'hasTheWord' => 'Something', 'label' => 'Foo', + 'markAsRead' => 'true', 'shouldArchive' => 'true', 'shouldNeverSpam' => 'true', 'shouldSpam' => 'false', + 'shouldStar' => 'true', ], $this->filter->from('foo@example.com ', 'bar@example.com') ->has('Something') ->labelAndArchive('Foo') + ->read() ->neverSpam() + ->star() ->getProperties() ); }