예제 #1
0
파일: EnumTest.php 프로젝트: plista/core
 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'));
 }