Skip to content

Commit 999660a

Browse files
authored
Merge pull request #43 from launchdarkly/eb/ch37610/allow-skip-db-tests
add param to skip db tests, update docs for new repo name
2 parents 4199948 + ff1a19d commit 999660a

File tree

8 files changed

+86
-16
lines changed

8 files changed

+86
-16
lines changed

CONTRIBUTING.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,39 @@
1-
Contributing to the LaunchDarkly SDK for PHP
2-
================================================
1+
# Contributing to the LaunchDarkly SDK FOR PHP
32

4-
We encourage pull-requests and other contributions from the community. We've also published an [SDK contributor's guide](http://docs.launchdarkly.com/docs/sdk-contributors-guide) that provides a detailed explanation of how our SDKs work.
3+
LaunchDarkly has published an [SDK contributor's guide](https://docs.launchdarkly.com/docs/sdk-contributors-guide) that provides a detailed explanation of how our SDKs work. See below for additional information on how to contribute to this SDK.
4+
5+
## Submitting bug reports and feature requests
6+
7+
The LaunchDarkly SDK team monitors the issue tracker associated with in the `launchdarkly/php-server-sdk` SDK repository. Bug reports and feature requests specific to this SDK should be filed in this issue tracker. The SDK team will respond to all newly filed issues within two business days.
8+
9+
## Submitting pull requests
10+
11+
We encourage pull requests and other contributions from the community. Before submitting pull requests, ensure that all temporary or unintended code is removed. Don't worry about adding reviewers to the pull request; the LaunchDarkly SDK team will add themselves. The SDK team will acknowledge all pull requests within two business days.
12+
13+
## Build instructions
14+
15+
### Prerequisites
16+
17+
The project uses [Composer](https://getcomposer.org/).
18+
19+
If you will be running the full test suite that includes the database integrations, you will need to have instances of Consul, DynamoDB, and Redis running locally. See below for how to skip these tests.
20+
21+
### Installing dependencies
22+
23+
From the project root directory:
24+
25+
```
26+
composer install
27+
```
28+
29+
### Testing
30+
31+
To run all unit tests:
32+
33+
```
34+
phpunit
35+
```
36+
37+
By default, the full unit test suite includes live tests of the integrations for Consul, DynamoDB, and Redis. To skip these, set the environment variable `LD_SKIP_DATABASE_TESTS=1` before running the tests.
38+
39+
It is preferable to run tests against all supported minor versions of PHP (as described in `README.md` under Requirements), or at least the lowest and highest versions, prior to submitting a pull request. However, LaunchDarkly's CI tests will run automatically against all supported versions.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
LaunchDarkly SDK for PHP
22
===========================
33

4-
[![Circle CI](https://circleci.com/gh/launchdarkly/php-client.svg?style=svg)](https://circleci.com/gh/launchdarkly/php-client)
4+
[![Circle CI](https://circleci.com/gh/launchdarkly/php-server-sdk.svg?style=svg)](https://circleci.com/gh/launchdarkly/php-server-sdk)
55

66
Requirements
77
------------
@@ -56,7 +56,7 @@ Require Guzzle as a dependency:
5656

5757
It will then be used as the default way of fetching flags.
5858

59-
With Guzzle, you could persist your cache somewhere other than the default in-memory store, like Memcached or Redis. You could then specify your cache when initializing the client with the [cache option](https://github.com/launchdarkly/php-client/blob/master/src/LaunchDarkly/LDClient.php#L44).
59+
With Guzzle, you could persist your cache somewhere other than the default in-memory store, like Memcached or Redis. You could then specify your cache when initializing the client with the [cache option](https://github.com/launchdarkly/php-server-sdk/blob/master/src/LaunchDarkly/LDClient.php#L44).
6060

6161
$client = new LaunchDarkly\LDClient("YOUR_SDK_KEY", array("cache" => $cacheStorage));
6262

@@ -127,7 +127,7 @@ The LaunchDarkly Relay Proxy ([ld-relay](https://github.com/launchdarkly/ld-rela
127127
Using flag data from a file
128128
---------------------------
129129

130-
For testing purposes, the SDK can be made to read feature flag state from a file or files instead of connecting to LaunchDarkly. See [`LaunchDarkly\Integrations\Files`](https://github.com/launchdarkly/php-client/blob/master/src/LaunchDarkly/Integrations/Files.php) and ["Reading flags from a file"](https://docs.launchdarkly.com/docs/reading-flags-from-a-file).
130+
For testing purposes, the SDK can be made to read feature flag state from a file or files instead of connecting to LaunchDarkly. See [`LaunchDarkly\Integrations\Files`](https://github.com/launchdarkly/php-server-sdk/blob/master/src/LaunchDarkly/Integrations/Files.php) and ["Reading flags from a file"](https://docs.launchdarkly.com/docs/reading-flags-from-a-file).
131131

132132
Testing
133133
-------
@@ -142,7 +142,7 @@ Check out our [documentation](http://docs.launchdarkly.com) for in-depth instruc
142142
Contributing
143143
------------
144144

145-
We encourage pull-requests and other contributions from the community. We've also published an [SDK contributor's guide](http://docs.launchdarkly.com/docs/sdk-contributors-guide) that provides a detailed explanation of how our SDKs work.
145+
We encourage pull-requests and other contributions from the community. We've also published an [SDK contributor's guide](http://docs.launchdarkly.com/docs/sdk-contributors-guide) that provides a detailed explanation of how our SDKs work. See [CONTRIBUTING](CONTRIBUTING.md) for more developer information about this project.
146146

147147
About LaunchDarkly
148148
------------------

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"launchdarkly",
66
"launchdarkly php"
77
],
8-
"homepage": "https://github.com/launchdarkly/php-client",
8+
"homepage": "https://github.com/launchdarkly/php-server-sdk",
99
"license": "Apache-2.0",
1010
"authors": [
1111
{

scripts/release.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# When done you should commit and push the changes made.
1111

1212
set -uxe
13-
echo "Starting php-client release (version update only)"
13+
echo "Starting php-server-sdk release (version update only)"
1414

1515
VERSION=$1
1616

@@ -22,4 +22,4 @@ LDCLIENT_PHP_TEMP=./LDClient.php.tmp
2222
sed "s/const VERSION = '.*'/const VERSION = '${VERSION}'/g" $LDCLIENT_PHP > $LDCLIENT_PHP_TEMP
2323
mv $LDCLIENT_PHP_TEMP $LDCLIENT_PHP
2424

25-
echo "Done with php-client release (version update only)"
25+
echo "Done with php-server-sdk release (version update only)"

tests/ConsulFeatureRequesterTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ class ConsulFeatureRequesterTest extends FeatureRequesterTestBase
1515

1616
public static function setUpBeforeClass()
1717
{
18-
$sf = new ServiceFactory();
19-
self::$kvClient = $sf->get('kv');
18+
if (!static::isSkipDatabaseTests()) {
19+
$sf = new ServiceFactory();
20+
self::$kvClient = $sf->get('kv');
21+
}
22+
}
23+
24+
protected function isDatabaseTest()
25+
{
26+
return true;
2027
}
2128

2229
protected function makeRequester()

tests/DynamoDbFeatureRequesterTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ class DynamoDbFeatureRequesterTest extends FeatureRequesterTestBase
1515

1616
public static function setUpBeforeClass()
1717
{
18-
self::$dynamoDbClient = new DynamoDbClient(self::makeDynamoDbOptions());
19-
self::createTableIfNecessary();
18+
if (!static::isSkipDatabaseTests()) {
19+
self::$dynamoDbClient = new DynamoDbClient(self::makeDynamoDbOptions());
20+
self::createTableIfNecessary();
21+
}
22+
}
23+
24+
protected function isDatabaseTest()
25+
{
26+
return true;
2027
}
2128

2229
private static function makeDynamoDbOptions()

tests/FeatureRequesterTestBase.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,21 @@ class FeatureRequesterTestBase extends \PHPUnit_Framework_TestCase
99
{
1010
public function setUp()
1111
{
12-
$this->deleteExistingData();
12+
if ($this->isDatabaseTest() && static::isSkipDatabaseTests()) {
13+
$this->markTestSkipped('skipping database tests');
14+
} else {
15+
$this->deleteExistingData();
16+
}
17+
}
18+
19+
protected static function isSkipDatabaseTests()
20+
{
21+
return isset($_ENV['LD_SKIP_DATABASE_TESTS']) && $_ENV['LD_SKIP_DATABASE_TESTS'];
22+
}
23+
24+
protected function isDatabaseTest()
25+
{
26+
return false;
1327
}
1428

1529
protected function deleteExistingData()

tests/RedisFeatureRequesterTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ class RedisFeatureRequesterTest extends FeatureRequesterTestBase
1414

1515
public static function setUpBeforeClass()
1616
{
17-
self::$predisClient = new Client(array());
17+
if (!static::isSkipDatabaseTests()) {
18+
self::$predisClient = new Client(array());
19+
}
20+
}
21+
22+
protected function isDatabaseTest()
23+
{
24+
return true;
1825
}
1926

2027
protected function makeRequester()

0 commit comments

Comments
 (0)