public function testEnumValues() { $one = new \TestEnum(\TestEnum::ONE); $two = new \TestEnum(\TestEnum::TWO); $three = new \TestEnum(\TestEnum::THREE); $this->assertSame(\TestEnum::ONE, $one->__toString()); $this->assertSame(array('ONE' => \TestEnum::ONE, 'TWO' => \TestEnum::TWO, 'THREE' => \TestEnum::THREE), \TestEnum::values()); $this->assertEquals($two, \TestEnum::valueOf('two')); }
public function testEnum() { // test values $this->assertSame(array('FOO' => TestEnum::FOO, 'BAR' => TestEnum::BAR), TestEnum::values()); // test toString $this->assertSame((string) TestEnum::BAR(), (string) TestEnum::BAR); // test instances $this->assertInstanceOf('Plista\\Core\\Enum', TestEnum::BAR()); $this->assertInstanceOf('PlistaTest\\small\\Core\\TestEnum', TestEnum::BAR()); $this->assertSame(TestEnum::BAR, TestEnum::BAR()->val()); $this->assertFalse(TestEnum::ABC()); // test equals $this->assertTrue(TestEnum::BAR()->equals(TestEnum::BAR())); $this->assertTrue(TestEnum::BAR()->equals(TestEnum::BAR)); $this->assertFalse(TestEnum::BAR()->equals(TestEnum::FOO())); $this->assertFalse(TestEnum::BAR()->equals($this->getMockEnum())); // test fromValue $this->assertSame(TestEnum::BAR(), TestEnum::fromValue(TestEnum::BAR)); $this->assertFalse(TestEnum::fromValue('abc')); }