Skip to content

Commit a1abf73

Browse files
committed
test refactoring
* test files/classes match class names * removes tests/general/AuthTest.php because it tested firebase-jwt library, and not this library. * removes tests/testdata/*.pem, tests/testdata/*.p12, and tests/testdata/*.json as they are no longer used.
1 parent 48dfd95 commit a1abf73

31 files changed

Lines changed: 51 additions & 338 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ vendor
55
examples/testfile-small.txt
66
examples/testfile.txt
77
tests/.accessToken
8+
tests/.apiKey

phpunit.xml.dist

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,13 @@
44
colors="true"
55
bootstrap="tests/bootstrap.php">
66
<testsuites>
7-
<testsuite name="Google YouTube API tests">
8-
<directory>tests/youtube</directory>
9-
</testsuite>
10-
<testsuite name="Google Tasks API tests">
11-
<directory>tests/tasks</directory>
12-
</testsuite>
13-
<testsuite name="Google PageSpeed API tests">
14-
<directory>tests/pagespeed</directory>
15-
</testsuite>
16-
<testsuite name="Google UrlShortener API tests">
17-
<directory>tests/urlshortener</directory>
18-
</testsuite>
19-
<testsuite name="Google Plus API tests">
20-
<directory>tests/plus</directory>
21-
</testsuite>
22-
<testsuite name="AdSense Management API tests">
23-
<directory>tests/adsense</directory>
24-
</testsuite>
25-
<testsuite name="Google API PHP Library core component tests">
26-
<directory>tests/general</directory>
7+
<testsuite name="Google PHP Client Test Suite">
8+
<directory>tests/Google</directory>
279
</testsuite>
2810
</testsuites>
2911
<filter>
30-
<blacklist>
31-
<directory suffix=".php">tests</directory>
32-
</blacklist>
12+
<whitelist>
13+
<directory suffix=".php">./src/Google</directory>
14+
</whitelist>
3315
</filter>
3416
</phpunit>

tests/BaseTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class BaseTest extends PHPUnit_Framework_TestCase
2121
private $token;
2222
private $memcacheHost;
2323
private $memcachePort;
24+
protected $testDir = __DIR__;
2425

2526
public function __construct()
2627
{
@@ -79,12 +80,12 @@ public function loadToken()
7980

8081
public function checkKey()
8182
{
83+
$this->key = $this->loadKey();
84+
8285
if (!strlen($this->key)) {
8386
$this->markTestSkipped("Test requires api key\nYou can create one in your developer console");
8487
return false;
8588
}
86-
87-
$this->key = $this->loadKey();
8889
}
8990

9091
public function loadKey()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
use GuzzleHttp\Message\Request;
2222

23-
class ComputeEngineAuthTest extends BaseTest
23+
class Google_Auth_ComputeEngineTest extends BaseTest
2424
{
2525
public function testTokenAcquisition()
2626
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* under the License.
2222
*/
2323

24-
class ApiOAuth2Test extends BaseTest
24+
class Google_Auth_OAuth2Test extends BaseTest
2525
{
2626

2727
public function testSign()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* under the License.
1919
*/
2020

21-
class CacheTest extends BaseTest
21+
class Google_CacheTest extends BaseTest
2222
{
2323
public function testFile()
2424
{
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
use GuzzleHttp\Message\Request;
2222

23-
class ApiClientTest extends BaseTest
23+
class Google_ClientTest extends BaseTest
2424
{
2525
public function testClient()
2626
{
@@ -195,7 +195,7 @@ public function testJsonConfig()
195195

196196
public function testIniConfig()
197197
{
198-
$config = new Google_Config(__DIR__ . "/testdata/test.ini");
198+
$config = new Google_Config($this->testDir . "/config/test.ini");
199199
$this->assertEquals('My Test application', $config->getApplicationName());
200200
$this->assertEquals(
201201
'gjfiwnGinpena3',
@@ -210,4 +210,17 @@ public function testIniConfig()
210210
$config->getClassConfig('Google_IO_Abstract', 'request_timeout_seconds')
211211
);
212212
}
213+
214+
public function testNoAuth()
215+
{
216+
/** @var $noAuth Google_Auth_Simple */
217+
$noAuth = new Google_Auth_Simple($this->getClient());
218+
$client = new Google_Client();
219+
$client->setAuth($noAuth);
220+
$client->setDeveloperKey(null);
221+
$req = new Request('GET', 'http://example.com');
222+
223+
$resp = $noAuth->sign($req);
224+
$this->assertEquals('http://example.com', $resp->getUrl());
225+
}
213226
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* under the License.
1919
*/
2020

21-
class ApiBatchRequestTest extends BaseTest
21+
class Google_Http_BatchTest extends BaseTest
2222
{
2323
public $plus;
2424

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* under the License.
2323
*/
2424

25-
class ApiMediaFileUploadTest extends BaseTest
25+
class Google_Http_MediaFileUploadTest extends BaseTest
2626
{
2727
public function testMediaFile()
2828
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use GuzzleHttp\Message\Response;
1919
use GuzzleHttp\Stream\Stream;
2020

21-
class RestTest extends BaseTest
21+
class Google_HTTP_RESTTest extends BaseTest
2222
{
2323
/**
2424
* @var Google_Http_REST $rest

0 commit comments

Comments
 (0)