Skip to content

Commit

Permalink
Lint bash tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Barber committed Oct 22, 2014
1 parent 5333b00 commit 5376eee
Show file tree
Hide file tree
Showing 25 changed files with 903 additions and 579 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2013 Google Inc.
Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
6 changes: 4 additions & 2 deletions tests/AllTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
require_once 'plus/PlusTest.php';
require_once 'youtube/YouTubeTest.php';

class AllTests {
public static function suite() {
class AllTests
{
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite();
$suite->setName('All Google API PHP Client tests');
$suite->addTestSuite(YouTubeTests::suite());
Expand Down
34 changes: 18 additions & 16 deletions tests/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
require_once 'bootstrap.php';
require_once 'Google/Client.php';

class BaseTest extends PHPUnit_Framework_TestCase {
class BaseTest extends PHPUnit_Framework_TestCase
{
const KEY = "";
private $token;
private $memcacheHost;
Expand All @@ -26,36 +27,38 @@ class BaseTest extends PHPUnit_Framework_TestCase {
public function __construct()
{
parent::__construct();
// Fill in a token JSON here and you can test the oauth token
// Fill in a token JSON here and you can test the oauth token
// requiring functions.
// $this->token = '';

$this->memcacheHost = getenv('MEMCACHE_HOST') ? getenv('MEMCACHE_HOST') : null;
$this->memcachePort = getenv('MEMCACHE_PORT') ? getenv('MEMCACHE_PORT') : null;
}

public function getClient() {
$client = new Google_Client();
$client->setDeveloperKey(self::KEY);
if (strlen($this->token)) {
$client->setAccessToken($this->token);
}
if (strlen($this->memcacheHost)) {
$client->setClassConfig('Google_Cache_Memcache', 'host', $this->memcacheHost);
$client->setClassConfig('Google_Cache_Memcache', 'port', $this->memcachePort);
}
return $client;
public function getClient()
{
$client = new Google_Client();
$client->setDeveloperKey(self::KEY);
if (strlen($this->token)) {
$client->setAccessToken($this->token);
}
if (strlen($this->memcacheHost)) {
$client->setClassConfig('Google_Cache_Memcache', 'host', $this->memcacheHost);
$client->setClassConfig('Google_Cache_Memcache', 'port', $this->memcachePort);
}
return $client;
}

public function testClientConstructor()
{
$this->assertInstanceOf('Google_Client', $this->getClient());
}

public function testIncludes() {
public function testIncludes()
{
$prefix = dirname(dirname(__FILE__)) . '/src/';
$path = dirname(dirname(__FILE__)) . '/src/Google/Service';
foreach(glob($path . "/*.php") as $file) {
foreach (glob($path . "/*.php") as $file) {
// Munge prefix so we don't double require.
$this->assertEquals(1, require_once(str_replace($prefix, '', $file)));
}
Expand All @@ -69,5 +72,4 @@ public function checkToken()
}
return true;
}

}
21 changes: 10 additions & 11 deletions tests/OAuthHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@
* limitations under the License.
*/
include_once 'bootstrap.php';
require_once realpath(dirname(__FILE__) . '/../autoload.php');
require_once 'Google/Client.php';

$client = new Google_Client();
$client->setScopes(array(
"https://www.googleapis.com/auth/plus.me",
"https://www.googleapis.com/auth/urlshortener",
"https://www.googleapis.com/auth/tasks",
"https://www.googleapis.com/auth/adsense",
"https://www.googleapis.com/auth/youtube"
));
$client->setScopes(
array(
"https://www.googleapis.com/auth/plus.me",
"https://www.googleapis.com/auth/urlshortener",
"https://www.googleapis.com/auth/tasks",
"https://www.googleapis.com/auth/adsense",
"https://www.googleapis.com/auth/youtube"
)
);
$client->setRedirectUri("urn:ietf:wg:oauth:2.0:oob");
// Visit https://code.google.com/apis/console to
// generate your oauth2_client_id, oauth2_client_secret, and to
// register your oauth2_redirect_uri.
$client->setClientId("");
$client->setClientSecret("");


$authUrl = $client->createAuthUrl();

Expand Down
Loading

0 comments on commit 5376eee

Please sign in to comment.