Skip to content

Commit 0ce2875

Browse files
authored
update shared tests (#6)
1 parent 69a1882 commit 0ce2875

File tree

5 files changed

+24
-12
lines changed

5 files changed

+24
-12
lines changed

.circleci/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ workflows:
99
- linux-test:
1010
name: PHP 7.4
1111
docker-image: cimg/php:7.4
12+
- linux-test:
13+
name: PHP 8.0
14+
docker-image: cimg/php:8.0
1215

1316
jobs:
1417
linux-test:

php-server-sdk-shared-tests/.circleci/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ workflows:
99
- linux-test:
1010
name: PHP 7.4
1111
docker-image: cimg/php:7.4
12+
- linux-test:
13+
name: PHP 8.0
14+
docker-image: cimg/php:8.0
1215

1316
jobs:
1417
linux-test:

php-server-sdk-shared-tests/composer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2+
"repositories": [
3+
{
4+
"type": "git",
5+
"url": "https://github.com/launchdarkly/php-server-sdk-private.git"
6+
}
7+
],
28
"name": "launchdarkly/server-sdk-shared-tests",
39
"description": "Shared unit test code for LaunchDarkly PHP SDK",
410
"license": "Apache-2.0",
@@ -12,7 +18,7 @@
1218
"php": ">=7.3"
1319
},
1420
"require-dev": {
15-
"launchdarkly/server-sdk": ">=3.9",
21+
"launchdarkly/server-sdk": "4.0.x-dev",
1622
"phpunit/phpunit": "^9"
1723
},
1824
"autoload": {

php-server-sdk-shared-tests/src/DatabaseFeatureRequesterTestBase.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace LaunchDarkly\SharedTest;
44

5-
use LaunchDarkly\FeatureFlag;
65
use LaunchDarkly\FeatureRequester;
7-
use LaunchDarkly\Segment;
6+
use LaunchDarkly\Impl\Model\FeatureFlag;
7+
use LaunchDarkly\Impl\Model\Segment;
88
use PHPUnit\Framework\TestCase;
99

1010
/**
1111
* A base class providing standardized PHPUnit tests for database integrations.
1212
*/
13-
class DatabaseFeatureRequesterTestBase extends \PHPUnit\Framework\TestCase
13+
class DatabaseFeatureRequesterTestBase extends TestCase
1414
{
1515
const TEST_PREFIX = 'testprefix';
1616

php-server-sdk-shared-tests/tests/DatabaseFeatureRequesterTestBaseTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
namespace LaunchDarkly\SharedTest\Tests;
44

5-
use LaunchDarkly\FeatureFlag;
65
use LaunchDarkly\FeatureRequester;
7-
use LaunchDarkly\Segment;
6+
use LaunchDarkly\Impl\Model\FeatureFlag;
7+
use LaunchDarkly\Impl\Model\Segment;
88
use LaunchDarkly\SharedTest\DatabaseFeatureRequesterTestBase;
99

1010
class FakeDatabase
1111
{
1212
public static $data = [];
1313

14-
public static function getItem($prefix, $namespace, $key)
14+
public static function getItem(string $prefix, string $namespace, string $key): ?array
1515
{
1616
$dataSet = self::$data[$prefix] ?? null;
1717
if ($dataSet) {
@@ -24,7 +24,7 @@ public static function getItem($prefix, $namespace, $key)
2424
return null;
2525
}
2626

27-
public static function getAllItems($prefix, $namespace)
27+
public static function getAllItems(string $prefix, string $namespace): array
2828
{
2929
$itemsOut = [];
3030
$dataSet = self::$data[$prefix] ?? [];
@@ -35,7 +35,7 @@ public static function getAllItems($prefix, $namespace)
3535
return $itemsOut;
3636
}
3737

38-
public static function putSerializedItem($prefix, $namespace, $key, $json)
38+
public static function putSerializedItem(string $prefix, string $namespace, string $key, string $json): void
3939
{
4040
if (!isset(self::$data[$prefix])) {
4141
self::$data[$prefix] = [];
@@ -56,7 +56,7 @@ public function __construct($prefix)
5656
$this->prefix = $prefix;
5757
}
5858

59-
public function getFeature($key)
59+
public function getFeature(string $key): ?FeatureFlag
6060
{
6161
$json = FakeDatabase::getItem($this->prefix, 'features', $key);
6262
if ($json) {
@@ -66,7 +66,7 @@ public function getFeature($key)
6666
return null;
6767
}
6868

69-
public function getSegment($key)
69+
public function getSegment(string $key): ?Segment
7070
{
7171
$json = FakeDatabase::getItem($this->prefix, 'segments', $key);
7272
if ($json) {
@@ -76,7 +76,7 @@ public function getSegment($key)
7676
return null;
7777
}
7878

79-
public function getAllFeatures()
79+
public function getAllFeatures(): array
8080
{
8181
$jsonList = FakeDatabase::getAllItems($this->prefix, 'features');
8282
$itemsOut = [];

0 commit comments

Comments
 (0)