From 7a3120dd28ffbbcad962ea514c2e247c450028dd Mon Sep 17 00:00:00 2001 From: Susann Sgorzaly Date: Thu, 22 Feb 2018 21:15:00 +0100 Subject: [PATCH] added test for sort enums (todo: handle exception on test) --- src/enums/SortEnum.php | 2 ++ tests/properties/PublicPropertiesTest.php | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/enums/SortEnum.php b/src/enums/SortEnum.php index e5b78f3..42626ef 100644 --- a/src/enums/SortEnum.php +++ b/src/enums/SortEnum.php @@ -3,6 +3,8 @@ namespace ParseCsv\enums; class SortEnum extends AbstractEnum { + const __DEFAULT = self::SORT_TYPE_REGULAR; + const SORT_TYPE_REGULAR = SORT_REGULAR; const SORT_TYPE_NUMERIC = SORT_NUMERIC; diff --git a/tests/properties/PublicPropertiesTest.php b/tests/properties/PublicPropertiesTest.php index fbf85d5..0510e73 100644 --- a/tests/properties/PublicPropertiesTest.php +++ b/tests/properties/PublicPropertiesTest.php @@ -3,6 +3,7 @@ namespace ParseCsv\tests\properties; use ParseCsv\Csv; +use ParseCsv\enums\SortEnum; use PHPUnit\Framework\TestCase; class PublicPropertiesTest extends TestCase { @@ -145,4 +146,20 @@ class PublicPropertiesTest extends TestCase { $this->assertCount($counter, $this->properties); } + + public function testDefaultSortTypeIsRegular(){ + $this->assertEquals(SortEnum::SORT_TYPE_REGULAR, $this->csv->sort_type); + } + + public function testSetSortType(){ + $this->csv->sort_type = SortEnum::SORT_TYPE_NUMERIC; + $this->assertEquals(SortEnum::SORT_TYPE_NUMERIC, $this->csv->sort_type); + + $this->csv->sort_type = SortEnum::SORT_TYPE_STRING; + $this->assertEquals(SortEnum::SORT_TYPE_STRING, $this->csv->sort_type); + + $this->csv->sort_type = SortEnum::SORT_TYPE_UNKNOWN; + // todo: how to handle this exception? + $this->expectException(InvalidArgumentException::class); + } }