File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,16 @@ public function __toString()
7373 return (string )$ this ->value ;
7474 }
7575
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+
7686 /**
7787 * Returns the names (keys) of all constants in the Enum class
7888 *
Original file line number Diff line number Diff line change @@ -213,4 +213,13 @@ public function searchProvider() {
213213 array (array (), false ),
214214 );
215215 }
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+ }
216225}
You can’t perform that action at this time.
0 commit comments