$key, Token::TIMESTAMP_KEY => $timeStamp, ]; $subject = new Token($data); $encodedTokenData = json_decode(json_encode($subject), true); // Applying rounding on float because of the limited precision. // See: https://www.php.net/manual/en/language.types.float.php $this->assertEquals(round($timeStamp, 2), round($encodedTokenData[Token::TIMESTAMP_KEY], 2)); $this->assertEquals($key, $encodedTokenData[Token::TOKEN_KEY]); } public function testCreateNewToken() { $token = new Token(); self::assertSame(40, strlen($token->getValue()), 'The token has the expected length'); self::assertRegExp('/^[0-9a-f]{40}$/', $token->getValue(), 'The token is correctly formatted'); } }