public function testDecodingData() { $data = '{"toAccount":1,"fromAccount":2,"userId":3}'; $generator = new AccountSwitcherTokenGenerator(); $result = $generator->decodeData($data); $this->assertAttributeEquals(1, 'toAccount', $result); $this->assertAttributeEquals(2, 'fromAccount', $result); $this->assertAttributeEquals(3, 'userId', $result); }
/** * Get token data * * @param $token * * @return array */ protected function getTokenData($token) { $generator = new AccountSwitcherTokenGenerator(); return $generator->decodeData($token->data); }
/** * Create a new AccountSwitch record * * @param \Tectonic\Application\Commanding\Command $command * * @return mixed */ protected function createAccountSwitchRecord(Command $command) { $generator = new AccountSwitcherTokenGenerator(); $generator->setData($command->accountId, CurrentAccount::get(), $command->user->id); return Token::createToken($generator); }