File tree Expand file tree Collapse file tree 2 files changed +9
-16
lines changed Expand file tree Collapse file tree 2 files changed +9
-16
lines changed Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ public static function isValid($value)
198198 * @psalm-pure
199199 * @psalm-assert T $value
200200 */
201- public static function assertValidValue ($ value ): void
201+ private static function assertValidValue ($ value ): void
202202 {
203203 if (!static ::isValid ($ value )) {
204204 throw new \UnexpectedValueException ("Value ' $ value' is not part of the enum " . static ::class);
Original file line number Diff line number Diff line change @@ -60,6 +60,14 @@ public function testFailToCreateEnumWithInvalidValueThroughNamedConstructor($val
6060 EnumFixture::from ($ value );
6161 }
6262
63+ public function testFailToCreateEnumWithEnumItselfThroughNamedConstructor (): void
64+ {
65+ $ this ->expectException (\UnexpectedValueException::class);
66+ $ this ->expectExceptionMessage ("Value 'foo' is not part of the enum " . EnumFixture::class);
67+
68+ EnumFixture::from (EnumFixture::FOO ());
69+ }
70+
6371 /**
6472 * Contains values not existing in EnumFixture
6573 * @return array
@@ -344,19 +352,4 @@ public function testEnumValuesInheritance()
344352 $ inheritedEnumFixture = InheritedEnumFixture::VALUE ();
345353 new EnumFixture ($ inheritedEnumFixture );
346354 }
347-
348- /**
349- * @dataProvider isValidProvider
350- */
351- public function testAssertValidValue ($ value , $ isValid ): void
352- {
353- if (!$ isValid ) {
354- $ this ->expectException (\UnexpectedValueException::class);
355- $ this ->expectExceptionMessage ("Value ' $ value' is not part of the enum " . EnumFixture::class);
356- }
357-
358- EnumFixture::assertValidValue ($ value );
359-
360- self ::assertTrue (EnumFixture::isValid ($ value ));
361- }
362355}
You can’t perform that action at this time.
0 commit comments