Skip to content

Commit

Permalink
Fix undefined variable error in HttpRequestWrapper
Browse files Browse the repository at this point in the history
Fixes #19
  • Loading branch information
mcrumm committed Mar 9, 2016
1 parent 1fefffd commit 426ca6c
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/HttpRequestWrapperTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/**
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Google\Gcloud\Tests;

use Google\Gcloud\HttpRequestWrapper;
use Prophecy\Argument;
use Psr\Http\Message\RequestInterface;

class HttpRequestWrapperTest extends \PHPUnit_Framework_TestCase
{
public function testSignRequestCanCheckTheExistingCredentialsExpiry()
{
$request = $this->getMock(RequestInterface::class);

$wrapper = new HttpRequestWrapper();
$refl = new \ReflectionClass($wrapper);

$now = time();
$token = 'some_generated_token';
$credentials = $refl->getProperty('credentials');
$credentials->setAccessible(true);
$credentials->setValue($wrapper, [
'expiry' => strtotime('+300s', $now),
'access_token' => $token
]);

$this->setExpectedException('PHPUnit_Framework_Error_Notice');

$signedRequest = $wrapper->signRequest($request);

$header = $signedRequest->getHeader('Authorization')[0];

$this->assertEquals("Bearer $token", $header);
}
}

0 comments on commit 426ca6c

Please sign in to comment.