Skip to content

Commit 07a11aa

Browse files
committed
100% code coverage
1 parent d392f07 commit 07a11aa

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
strict="true"
1212
>
1313
<testsuite name="php-enum Test-Suite">
14-
<directory>./tests/MabeEnumTest</directory>
14+
<directory>./tests</directory>
1515
</testsuite>
1616
<filter>
1717
<whitelist addUncoveredFilesFromWhitelist="true">

tests/MabeEnumTest/EnumSet.php renamed to tests/MabeEnumTest/EnumSetTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function testBasic()
2121
{
2222
$enumSet = new EnumSet('MabeEnumTest\TestAsset\EnumWithoutDefaultValue');
2323
$this->assertSame('MabeEnumTest\TestAsset\EnumWithoutDefaultValue', $enumSet->getEnumClass());
24+
$this->assertSame(EnumSet::UNIQUE, $enumSet->getFlags());
2425

2526
$enum1 = EnumWithoutDefaultValue::ONE();
2627
$enum2 = EnumWithoutDefaultValue::TWO();
@@ -65,6 +66,7 @@ public function testBasicWithConstantValuesAsEnums()
6566
public function testUnique()
6667
{
6768
$enumSet = new EnumSet('MabeEnumTest\TestAsset\EnumWithoutDefaultValue', EnumSet::UNIQUE);
69+
$this->assertSame(EnumSet::UNIQUE, $enumSet->getFlags());
6870

6971
$enumSet->attach(EnumWithoutDefaultValue::ONE());
7072
$enumSet->attach(EnumWithoutDefaultValue::ONE);
@@ -78,6 +80,7 @@ public function testUnique()
7880
public function testNotUnique()
7981
{
8082
$enumSet = new EnumSet('MabeEnumTest\TestAsset\EnumWithoutDefaultValue', 0);
83+
$this->assertSame(0, $enumSet->getFlags());
8184

8285
$enumSet->attach(EnumWithoutDefaultValue::ONE());
8386
$enumSet->attach(EnumWithoutDefaultValue::ONE);
@@ -102,6 +105,7 @@ public function testIterateUnordered()
102105
// an empty enum set needs to be invalid, starting by 0
103106
$this->assertSame(0, $enumSet->count());
104107
$this->assertFalse($enumSet->valid());
108+
$this->assertNull($enumSet->current());
105109

106110
// attach
107111
$enumSet->attach($enum1);
@@ -123,6 +127,7 @@ public function testIterateUnordered()
123127
$this->assertNull($enumSet->next());
124128
$this->assertFalse($enumSet->valid());
125129
$this->assertSame(2, $enumSet->key());
130+
$this->assertNull($enumSet->current());
126131

127132
// rewind will set the iterator position back to 0
128133
$enumSet->rewind();
@@ -141,6 +146,7 @@ public function testIterateOrdered()
141146
// an empty enum set needs to be invalid, starting by 0
142147
$this->assertSame(0, $enumSet->count());
143148
$this->assertFalse($enumSet->valid());
149+
$this->assertNull($enumSet->current());
144150

145151
// attach
146152
$enumSet->attach($enum2);
@@ -162,6 +168,7 @@ public function testIterateOrdered()
162168
$this->assertNull($enumSet->next());
163169
$this->assertFalse($enumSet->valid());
164170
$this->assertSame(2, $enumSet->key());
171+
$this->assertNull($enumSet->current());
165172

166173
// rewind will set the iterator position back to 0
167174
$enumSet->rewind();
@@ -180,6 +187,7 @@ public function testIterateOrderedNotUnique()
180187
// an empty enum set needs to be invalid, starting by 0
181188
$this->assertSame(0, $enumSet->count());
182189
$this->assertFalse($enumSet->valid());
190+
$this->assertNull($enumSet->current());
183191

184192
// attach
185193
$enumSet->attach($enum2);
@@ -215,6 +223,7 @@ public function testIterateOrderedNotUnique()
215223
$this->assertNull($enumSet->next());
216224
$this->assertFalse($enumSet->valid());
217225
$this->assertSame(4, $enumSet->key());
226+
$this->assertNull($enumSet->current());
218227

219228
// rewind will set the iterator position back to 0
220229
$enumSet->rewind();
@@ -247,6 +256,7 @@ public function testIterateAndDetach()
247256
// detach enum of current index if the last index
248257
$enumSet->detach($enumSet->current());
249258
$this->assertFalse($enumSet->valid());
259+
$this->assertNull($enumSet->current());
250260
}
251261

252262
public function testConstructThrowsInvalidArgumentExceptionIfEnumClassDoesNotExtendBaseEnum()

0 commit comments

Comments
 (0)