Example #1
0
 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'));
 }
 /**
  * @covers FactoryEnum::introspect()
  * @covers FactoryEnum::contains()
  * @covers FactoryEnum::defines()
  */
 public function testIntrospect()
 {
     $_constants = TestEnum::all();
     $this->assertNotEmpty($_constants);
     foreach ($_constants as $_constant => $_value) {
         $this->assertTrue(TestEnum::contains($_value));
         $this->assertTrue(TestEnum::defines($_constant));
     }
 }
Example #3
0
 /**
  * @covers FactoryEnum::toConstant()
  * @covers FactoryEnum::toValue()
  * @covers FactoryEnum::resolve()
  */
 public function testResolvers()
 {
     $this->assertEquals('BOOLEAN_TRUE', TestEnum::toConstant('true'));
     $this->assertEquals('INTEGER', TestEnum::toConstant(12345));
     $this->assertEquals('STRING', TestEnum::toConstant('i am a string'));
     $this->assertEquals('BOOLEAN_TRUE', TestEnum::resolve('true'));
     $this->assertEquals('INTEGER', TestEnum::resolve(12345));
     $this->assertEquals('STRING', TestEnum::resolve('i am a string'));
 }
Example #4
0
 public function testMultipleEnumCaching()
 {
     // populate cache
     $this->assertEquals(TestEnum::BAR, TestEnum::BAR()->val());
     $this->assertEquals(AnotherTestEnum::BAR2, AnotherTestEnum::BAR2()->val());
     // and check it
     $this->assertTrue(TestEnum::FOO()->equals(TestEnum::FOO));
     $this->assertTrue(AnotherTestEnum::FOO2()->equals(AnotherTestEnum::FOO2));
 }
 public function testInstancesHaveValueMethod()
 {
     $instance = TestEnum::TestMember();
     $this->assertSame(TestEnum::TestMember, $instance->value());
 }
Example #6
0
 /**
  * @dataProvider typeSensitiveProvider
  */
 public function testEqualsIsTypeSesnsitive($init_value, $other_value)
 {
     $enum = new TestEnum($init_value);
     $this->assertFalse($enum->equals($other_value));
 }