-
Notifications
You must be signed in to change notification settings - Fork 438
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
Move shared testing code into core #822
Merged
dwsupplee
merged 43 commits into
googleapis:master
from
michaelbausor:move-shared-into-core
Jan 31, 2018
Merged
Changes from 12 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
8143806
manual changes
michaelbausor d7742e4
Grpc trait rename
michaelbausor e267e07
Rename key storage trait
michaelbausor 233156e
Rename stub
michaelbausor f393c70
Rename impl
michaelbausor da1dc86
Rename snippet tests
michaelbausor 902be47
Rename stub
michaelbausor 307f0ed
Rename SystemTestCase
michaelbausor 44a1c7e
Rename DeletionQueue
michaelbausor 7029491
Move fixtures
michaelbausor d589514
Rename stub and impl
michaelbausor 6d52f27
Fix locking and fixtures
michaelbausor a1f8aec
Fixes
michaelbausor e5c3569
Merge branch 'master' into move-shared-into-core
michaelbausor 0b0f30e
Restructure MockGlobals, update fixtures
michaelbausor 84b2b22
Fix phpcs errors
michaelbausor d929d42
Fix snippet tests
michaelbausor 2669893
Merge branch 'master' into move-shared-into-core
michaelbausor 668295a
Add comments to support doc building
michaelbausor 75722a2
Exclude MockValues from side effects phpcs rule
michaelbausor 7134422
Update StubTrait
michaelbausor e7b1fc7
Remove Storage dependency from StreamableUploaderTest
michaelbausor 71cb2b0
Move code out of dev
michaelbausor 4f87b74
Add snippet testing of parser
michaelbausor e8751c3
Update Iam
michaelbausor 520cf29
Handle servicebuilder tests
michaelbausor e76b08f
Add internal and experimental annotations
michaelbausor c6e4837
Add README to testing directory
michaelbausor 9673c49
Merge branch 'master' into move-shared-into-core
michaelbausor a60255b
Fix phpcs errors
michaelbausor c2d88c3
Fix import for doc gen
michaelbausor 5a9d835
Add comments to new code in Core/Testing
michaelbausor d74c478
Merge branch 'master' into move-shared-into-core
michaelbausor da17de0
Update after merge
michaelbausor a8e503a
Merge branch 'master' into move-shared-into-core
michaelbausor 19b6867
Address PR comments
michaelbausor 803368d
Merge branch 'master' into move-shared-into-core
michaelbausor 5f6d92a
Fix reference to impl
michaelbausor ec12d53
Address PR feedback
michaelbausor e98e0c6
Exclude Core/Testing from unit tests
michaelbausor a12ce04
Remove extra space
michaelbausor d99d600
Merge branch 'master' into move-shared-into-core
michaelbausor 8200a4b
Rename Functions to TestHelpers
michaelbausor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
tests/ArrayHasSameValuesToken.php → src/Core/Testing/ArrayHasSameValuesToken.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2017 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\Core\Testing; | ||
|
||
class Functions | ||
{ | ||
/** | ||
* Create a test stub which extends a real class and allows overriding of private properties. | ||
* | ||
* @param string $extends The fully-qualified name of the class to extend. | ||
* @param array $args An array of constructor arguments to use when creating the stub. | ||
* @param array $props A list of private properties on which to enable overrriding. | ||
* @return mixed | ||
*/ | ||
public static function stub($extends, array $args = [], array $props = []) | ||
{ | ||
if (empty($props)) { | ||
$props = ['connection']; | ||
} | ||
|
||
$tpl = 'class %s extends %s {private $___props = \'%s\'; use \Google\Cloud\Dev\StubTrait; }'; | ||
|
||
$name = 'Stub' . sha1($extends); | ||
|
||
if (!class_exists($name)) { | ||
eval(sprintf($tpl, $name, $extends, json_encode($props))); | ||
} | ||
|
||
$reflection = new \ReflectionClass($name); | ||
return $reflection->newInstanceArgs($args); | ||
} | ||
|
||
/** | ||
* Get a trait implementation. | ||
* | ||
* @param string $trait The fully-qualified name of the trait to implement. | ||
* @return mixed | ||
*/ | ||
public static function impl($trait, array $props = []) | ||
{ | ||
$properties = []; | ||
foreach ($props as $prop) { | ||
$properties[] = 'private $' . $prop . ';'; | ||
} | ||
|
||
$tpl = 'class %s { | ||
use %s; | ||
use \Google\Cloud\Dev\StubTrait; | ||
private $___props = \'%s\'; | ||
%s | ||
public function call($fn, array $args = []) { return call_user_func_array([$this, $fn], $args); } | ||
}'; | ||
|
||
$name = 'Trait' . sha1($trait . json_encode($props)); | ||
|
||
if (!class_exists($name)) { | ||
eval(sprintf($tpl, $name, $trait, json_encode($props), implode("\n", $properties))); | ||
} | ||
|
||
return new $name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2017 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. | ||
*/ | ||
|
||
use Google\Cloud\Core\Testing\Lock\MockValues; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.