Skip to content
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: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ workflows:
- linux-test:
name: PHP 7.4
docker-image: cimg/php:7.4
- linux-test:
name: PHP 8.0
docker-image: cimg/php:8.0

jobs:
linux-test:
Expand Down
3 changes: 3 additions & 0 deletions php-server-sdk-shared-tests/.circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ workflows:
- linux-test:
name: PHP 7.4
docker-image: cimg/php:7.4
- linux-test:
name: PHP 8.0
docker-image: cimg/php:8.0

jobs:
linux-test:
Expand Down
8 changes: 7 additions & 1 deletion php-server-sdk-shared-tests/composer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"repositories": [
{
"type": "git",
"url": "https://github.com/launchdarkly/php-server-sdk-private.git"
}
],
"name": "launchdarkly/server-sdk-shared-tests",
"description": "Shared unit test code for LaunchDarkly PHP SDK",
"license": "Apache-2.0",
Expand All @@ -12,7 +18,7 @@
"php": ">=7.3"
},
"require-dev": {
"launchdarkly/server-sdk": ">=3.9",
"launchdarkly/server-sdk": "4.0.x-dev",
"phpunit/phpunit": "^9"
},
"autoload": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace LaunchDarkly\SharedTest;

use LaunchDarkly\FeatureFlag;
use LaunchDarkly\FeatureRequester;
use LaunchDarkly\Segment;
use LaunchDarkly\Impl\Model\FeatureFlag;
use LaunchDarkly\Impl\Model\Segment;
use PHPUnit\Framework\TestCase;

/**
* A base class providing standardized PHPUnit tests for database integrations.
*/
class DatabaseFeatureRequesterTestBase extends \PHPUnit\Framework\TestCase
class DatabaseFeatureRequesterTestBase extends TestCase
{
const TEST_PREFIX = 'testprefix';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace LaunchDarkly\SharedTest\Tests;

use LaunchDarkly\FeatureFlag;
use LaunchDarkly\FeatureRequester;
use LaunchDarkly\Segment;
use LaunchDarkly\Impl\Model\FeatureFlag;
use LaunchDarkly\Impl\Model\Segment;
use LaunchDarkly\SharedTest\DatabaseFeatureRequesterTestBase;

class FakeDatabase
{
public static $data = [];

public static function getItem($prefix, $namespace, $key)
public static function getItem(string $prefix, string $namespace, string $key): ?array
{
$dataSet = self::$data[$prefix] ?? null;
if ($dataSet) {
Expand All @@ -24,7 +24,7 @@ public static function getItem($prefix, $namespace, $key)
return null;
}

public static function getAllItems($prefix, $namespace)
public static function getAllItems(string $prefix, string $namespace): array
{
$itemsOut = [];
$dataSet = self::$data[$prefix] ?? [];
Expand All @@ -35,7 +35,7 @@ public static function getAllItems($prefix, $namespace)
return $itemsOut;
}

public static function putSerializedItem($prefix, $namespace, $key, $json)
public static function putSerializedItem(string $prefix, string $namespace, string $key, string $json): void
{
if (!isset(self::$data[$prefix])) {
self::$data[$prefix] = [];
Expand All @@ -56,7 +56,7 @@ public function __construct($prefix)
$this->prefix = $prefix;
}

public function getFeature($key)
public function getFeature(string $key): ?FeatureFlag
{
$json = FakeDatabase::getItem($this->prefix, 'features', $key);
if ($json) {
Expand All @@ -66,7 +66,7 @@ public function getFeature($key)
return null;
}

public function getSegment($key)
public function getSegment(string $key): ?Segment
{
$json = FakeDatabase::getItem($this->prefix, 'segments', $key);
if ($json) {
Expand All @@ -76,7 +76,7 @@ public function getSegment($key)
return null;
}

public function getAllFeatures()
public function getAllFeatures(): array
{
$jsonList = FakeDatabase::getAllItems($this->prefix, 'features');
$itemsOut = [];
Expand Down