Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial logging system tests #229

Merged
merged 6 commits into from
Nov 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
},
"autoload-dev": {
"psr-4": {
"Google\\Cloud\\Dev\\": "dev/src"
"Google\\Cloud\\Dev\\": "dev/src",
"Google\\Cloud\\Tests\\System\\": "tests/system"
}
},
"scripts": {
Expand Down
16 changes: 16 additions & 0 deletions phpunit.system.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/system/bootstrap.php" colors="true">
<testsuites>
<testsuite>
<directory>tests/system</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
<exclude>
<directory suffix=".php">src/*/V[!a-zA-Z]*</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php" colors="true">
<phpunit bootstrap="./tests/unit/bootstrap.php" colors="true">
<testsuites>
<testsuite>
<directory>tests</directory>
<directory>tests/unit</directory>
</testsuite>
</testsuites>
<filter>
Expand Down
2 changes: 1 addition & 1 deletion src/BigQuery/JobConfigurationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

namespace Google\Cloud\Bigquery;
namespace Google\Cloud\BigQuery;

/**
* A trait used to build out configuration for jobs.
Expand Down
3 changes: 0 additions & 3 deletions tests/bootstrap.php

This file was deleted.

44 changes: 44 additions & 0 deletions tests/system/Datastore/AllocateKeyTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Copyright 2016 Google Inc. All Rights Reserved.
*
* 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\Cloud\Tests\System\Datastore;

class AllocateKeyTest extends DatastoreTestCase
{
public function testAllocateId()
{
$kind = 'Person';
$key = self::$client->key($kind);
$path = self::$client->allocateId($key)->path()[0];

$this->assertTrue(is_numeric($path['id']));
$this->assertEquals($kind, $path['kind']);
}

public function testAllocateIds()
{
$kind = 'Person';
$keys = self::$client->keys($kind);
$allocatedKeys = self::$client->allocateIds($keys);

foreach ($allocatedKeys as $key) {
$path = $key->path()[0];
$this->assertTrue(is_numeric($path['id']));
$this->assertEquals($kind, $path['kind']);
}
}
}
58 changes: 58 additions & 0 deletions tests/system/Datastore/DatastoreTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* Copyright 2016 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\Cloud\Tests\System\Datastore;

use Google\Cloud\ExponentialBackoff;
use Google\Cloud\Datastore\DatastoreClient;

class DatastoreTestCase extends \PHPUnit_Framework_TestCase
{
const TESTING_PREFIX = 'gcloud_testing_';

protected static $client;
protected static $deletionQueue = [];
private static $hasSetUp = false;

public static function setUpBeforeClass()
{
if (self::$hasSetUp) {
return;
}

self::$client = new DatastoreClient([
'keyFilePath' => getenv('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH'),
'namespaceId' => uniqid(self::TESTING_PREFIX)
]);
self::$hasSetUp = true;
}

public static function tearDownFixtures()
{
if (empty(self::$deletionQueue)) {
return;
}

$backoff = new ExponentialBackoff(8);
$transaction = self::$client->transaction();
$backoff->execute(function () use ($transaction) {
$transaction->deleteBatch(self::$deletionQueue);
});
}
}


Loading