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()); }
public function __toString() { return sprintf('(%s) %s', $this->type->getValue(), $this->value); }
/** * @dataProvider provideAcceptableTypes */ public function testCanCreateType(string $typeConstant) { $type = new TokenType($typeConstant); $this->assertEquals($type->getValue(), constant(sprintf('%s::%s', TokenType::class, $typeConstant))); }