コード例 #1
0
 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);
 }
コード例 #2
0
 /**
  * Get token data
  *
  * @param $token
  *
  * @return array
  */
 protected function getTokenData($token)
 {
     $generator = new AccountSwitcherTokenGenerator();
     return $generator->decodeData($token->data);
 }
コード例 #3
0
 /**
  * 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);
 }