Skip to content

Commit 7f8c19c

Browse files
authored
Workflow tests (#16)
1 parent 689caba commit 7f8c19c

File tree

7 files changed

+94
-11
lines changed

7 files changed

+94
-11
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Flagsmith PHP Pull Request
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, ready_for_review]
6+
branches:
7+
- main
8+
- release**
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
name: Flag engine Unit tests
14+
15+
strategy:
16+
max-parallel: 4
17+
matrix:
18+
php-version: ['7.4', '8.0', '8.1'] # TODO add '8.2' once available
19+
20+
steps:
21+
- name: Cloning repo
22+
uses: actions/checkout@v2
23+
# with:
24+
# fetch-depth: 0
25+
# submodules: recursive
26+
27+
- name: Setup PHP
28+
uses: shivammathur/setup-php@v2
29+
with:
30+
version: '{{ matrix.php-version }}'
31+
tools: php-cs-fixer, phpunit
32+
33+
- name: Get composer cache directory
34+
id: composer-cache
35+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
36+
37+
- name: Cache dependencies
38+
uses: actions/cache@v2
39+
with:
40+
path: ${{ steps.composer-cache.outputs.dir }}
41+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
42+
restore-keys: ${{ runner.os }}-composer-
43+
44+
- name: Install dependencies
45+
run: composer install --prefer-dist
46+
47+
- name: Check coding style
48+
run: ./vendor/bin/php-cs-fixer fix -vvv --config=.php-cs-fixer.php --dry-run --diff
49+
50+
- name: Running tests
51+
run: ./vendor/bin/phpunit tests/

.php-cs-fixer.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude(
5+
[
6+
'vendor',
7+
]
8+
)
9+
->in(__DIR__);
10+
11+
$config = new PhpCsFixer\Config();
12+
13+
return $config
14+
->setRules(
15+
[
16+
'@PSR12' => true,
17+
'single_quote' => true,
18+
'no_trailing_comma_in_singleline_array' => true,
19+
'array_indentation' => true,
20+
'phpdoc_indent' => true,
21+
]
22+
)
23+
->setFinder($finder);

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
},
1919
"require-dev": {
2020
"guzzlehttp/guzzle": "^7.3",
21-
"guzzlehttp/psr7": "^2.1.0"
21+
"guzzlehttp/psr7": "^2.1.0",
22+
"phpunit/phpunit": "^9.5",
23+
"friendsofphp/php-cs-fixer": "^3.6"
2224
},
2325
"autoload": {
2426
"psr-4": {

examples/index.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
2+
23
require_once './vendor/autoload.php';
34

4-
use \Flagsmith\Flagsmith;
5+
use Flagsmith\Flagsmith;
56
use Http\Discovery\Psr17FactoryDiscovery;
67
use Http\Discovery\Psr18ClientDiscovery;
78

@@ -30,8 +31,3 @@
3031
var_dump($response->getBody()->getContents());
3132

3233
// TODO - write more API examples once they are implemented.
33-
34-
35-
36-
37-

src/Cache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function setMultiple(array $values): bool
123123
public function getMultiple(array $keys, $default = null)
124124
{
125125
return $this->cache->getMultiple(
126-
array_map(fn($key) => $this->getKeyWithPrefix($key), $keys),
126+
array_map(fn ($key) => $this->getKeyWithPrefix($key), $keys),
127127
$default
128128
);
129129
}

src/Flagsmith.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function getIdentityByIndentity(Identity $identity): Identity
206206
[
207207
'identifier' => $identity->getId(),
208208
'traits' => array_map(
209-
fn(IdentityTrait $trait) => [
209+
fn (IdentityTrait $trait) => [
210210
'trait_key' => $trait->getKey(),
211211
'trait_value' => $trait->getValue(),
212212
],
@@ -351,7 +351,7 @@ public function setTraitsByIdentity(Identity $identity): bool
351351
'PUT',
352352
'traits/bulk/',
353353
array_map(
354-
fn(IdentityTrait $trait) => [
354+
fn (IdentityTrait $trait) => [
355355
'identity' => ['identifier' => $identity->getId()],
356356
'trait_key' => $trait->getKey(),
357357
'trait_value' => $trait->getValue(),
@@ -526,7 +526,7 @@ private function call(string $method, string $uri, array $body = []): array
526526
if ($method !== 'GET') {
527527
$request = $request->withBody($stream);
528528
}
529-
529+
530530
try {
531531
$response = $this->client->sendRequest($request);
532532
} catch (RequestExceptionInterface $e) {

tests/Engine/EngineTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
use PHPUnit\Framework\TestCase;
4+
5+
class EngineTest extends TestCase
6+
{
7+
public function testAssertion()
8+
{
9+
$this->assertTrue(true);
10+
}
11+
}

0 commit comments

Comments
 (0)