added test for sort enums (todo: handle exception on test)

This commit is contained in:
Susann Sgorzaly
2018-02-22 21:15:00 +01:00
parent a74736d4da
commit 7a3120dd28
2 changed files with 19 additions and 0 deletions

View File

@@ -3,6 +3,8 @@ namespace ParseCsv\enums;
class SortEnum extends AbstractEnum { class SortEnum extends AbstractEnum {
const __DEFAULT = self::SORT_TYPE_REGULAR;
const SORT_TYPE_REGULAR = SORT_REGULAR; const SORT_TYPE_REGULAR = SORT_REGULAR;
const SORT_TYPE_NUMERIC = SORT_NUMERIC; const SORT_TYPE_NUMERIC = SORT_NUMERIC;

View File

@@ -3,6 +3,7 @@
namespace ParseCsv\tests\properties; namespace ParseCsv\tests\properties;
use ParseCsv\Csv; use ParseCsv\Csv;
use ParseCsv\enums\SortEnum;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class PublicPropertiesTest extends TestCase { class PublicPropertiesTest extends TestCase {
@@ -145,4 +146,20 @@ class PublicPropertiesTest extends TestCase {
$this->assertCount($counter, $this->properties); $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);
}
} }