File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,16 @@ public function __toString()
73
73
return (string )$ this ->value ;
74
74
}
75
75
76
+ /**
77
+ * Compares one Enum with another.
78
+ *
79
+ * @return bool True if Enums are equal, false if not equal
80
+ */
81
+ public function equals (Enum $ enum )
82
+ {
83
+ return $ this ->getValue () === $ enum ->getValue ();
84
+ }
85
+
76
86
/**
77
87
* Returns the names (keys) of all constants in the Enum class
78
88
*
Original file line number Diff line number Diff line change @@ -213,4 +213,13 @@ public function searchProvider() {
213
213
array (array (), false ),
214
214
);
215
215
}
216
+
217
+ public function testEquals ()
218
+ {
219
+ $ enum = new EnumFixture (EnumFixture::FOO );
220
+ $ this ->assertTrue ($ enum ->equals (EnumFixture::FOO ()));
221
+
222
+ $ enum = new EnumFixture (EnumFixture::PROBLEMATIC_BOOLEAN_FALSE );
223
+ $ this ->assertFalse ($ enum ->equals (EnumFixture::PROBLEMATIC_EMPTY_STRING ()));
224
+ }
216
225
}
You can’t perform that action at this time.
0 commit comments