/** * @covers OAuth2\AccessToken::__construct() */ public function testConstructorBuildsAccessToken() { // assigns client and token $this->assertEquals($this->client, $this->accessToken->getClient()); $this->assertEquals($this->token, $this->accessToken->getToken()); // assigns extra params $target = new \OAuth2\AccessToken($this->client, $this->token, array('foo' => 'bar')); $this->assertArrayHasKey('foo', $target->getParams()); $this->assertEquals('bar', $target->getParam('foo')); // initialize with a Hash $hash = array('access_token' => $this->token, 'expires_in' => time() + 200, 'foo' => 'bar'); $target = \OAuth2\AccessToken::fromHash($this->client, $hash); $this->assertInitializeToken($target); // initalizes with a form-urlencoded key/value string $kvform = "access_token={$this->token}&expires_in={time() + 200}&foo=bar"; $target = \OAuth2\AccessToken::fromKvform($this->client, $kvform); $this->assertInitializeToken($target); // sets options $target = new \OAuth2\AccessToken($this->client, $this->token, array('param_name' => 'foo', 'header_format' => 'Bearer %', 'mode' => 'body')); $this->assertEquals('foo', $target->options['param_name']); $this->assertEquals('Bearer %', $target->options['header_format']); $this->assertEquals('body', $target->options['mode']); }