Beispiel #1
0
 public function testWithersReturnNewModifiedInstance()
 {
     $value = 'bob';
     $newValue = 'alice';
     $type = new TokenType(TokenType::DYNAMIC_ARRAY_TYPE);
     $token = new Token($value, $type);
     $newToken = $token->withValue($newValue);
     $this->assertEquals($value, $token->getValue());
     $this->assertEquals($type->getValue(), $token->getType());
     $this->assertInstanceOf(Token::class, $newToken);
     $this->assertEquals($newValue, $newToken->getValue());
     $this->assertEquals($type->getValue(), $newToken->getType());
 }
Beispiel #2
0
 public function __toString()
 {
     return sprintf('(%s) %s', $this->type->getValue(), $this->value);
 }
Beispiel #3
0
 /**
  * @dataProvider provideAcceptableTypes
  */
 public function testCanCreateType(string $typeConstant)
 {
     $type = new TokenType($typeConstant);
     $this->assertEquals($type->getValue(), constant(sprintf('%s::%s', TokenType::class, $typeConstant)));
 }