Skip to content

Commit

Permalink
Merge 2ff1fa7 into 9666a62
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraM authored Jan 15, 2024
2 parents 9666a62 + 2ff1fa7 commit aca4e79
Show file tree
Hide file tree
Showing 29 changed files with 168 additions and 81 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
time: "04:00"
17 changes: 8 additions & 9 deletions .github/workflows/php.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['7.1', '7.2', '7.3', '7.4']
php-version: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
dependencies: ['']
include:
- { php-version: '7.1', dependencies: '--prefer-lowest' }
- { php-version: '8.0', dependencies: '--ignore-platform-req=php' }
- { php-version: '7.3', dependencies: '--prefer-lowest' }

name: PHP ${{ matrix.php-version }} ${{ matrix.dependencies }} (unit tests)

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: shivammathur/setup-php@v2
with:
Expand Down Expand Up @@ -59,12 +58,12 @@ jobs:
name: "Integration tests"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.3'
extensions: mbstring, intl, zip
coverage: xdebug
tools: composer:v2
Expand Down Expand Up @@ -92,12 +91,12 @@ jobs:
name: "Code style and static analysis"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.3'
extensions: mbstring, intl

- name: Cache Composer dependencies
Expand All @@ -122,7 +121,7 @@ jobs:
name: "Markdown link check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-verbose-mode: 'yes'
2 changes: 1 addition & 1 deletion .github/workflows/pr-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: Block fixup commits

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Block fixup commit merge
uses: 13rac1/block-fixup-merge-action@v2.0.0
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<!-- There is always Unreleased section on the top. Subsections (Added, Changed, Fixed, Removed) should be added as needed. -->

## Unreleased
### Changed
- Require PHP ^7.3

## 4.1.0 - 2021-08-19
### Added
Expand Down
23 changes: 12 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
],
"require": {
"php": "^7.1 || ^8.0",
"php": "^7.3 || ^8.0",
"ext-hash": "*",
"ext-json": "*",
"beberlei/assert": "^2.8 || ^3.0",
Expand All @@ -28,17 +28,18 @@
},
"require-dev": {
"ergebnis/composer-normalize": "^2.4",
"lmc/coding-standard": "^1.3 || ^2.0",
"http-interop/http-factory-guzzle": "^1.2",
"lmc/coding-standard": "^3.0.0",
"php-coveralls/php-coveralls": "^2.4",
"php-http/guzzle6-adapter": "^1.1.1 || ^2.0",
"php-http/mock-client": "^1.0",
"php-mock/php-mock-phpunit": "^2.1.2",
"php-parallel-lint/php-parallel-lint": "^1.1",
"phpstan/extension-installer": "^1.0.5",
"phpstan/phpstan": "^0.12.48",
"phpstan/phpstan-phpunit": "^0.12.16",
"phpunit/phpunit": "^7.5.20 || ^8.0 || ^9.0",
"symfony/var-dumper": "^3.3 || ^4.0 || ^5.0"
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^9.6.15",
"symfony/var-dumper": "^4.0 || ^5.0"
},
"minimum-stability": "stable",
"autoload": {
Expand All @@ -54,9 +55,9 @@
},
"config": {
"allow-plugins": {
"composer/package-versions-deprecated": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"ergebnis/composer-normalize": true,
"php-http/discovery": true,
"phpstan/extension-installer": true
},
"sort-packages": true
Expand All @@ -68,15 +69,15 @@
"@test"
],
"analyze": [
"vendor/bin/ecs check src/ tests/ --ansi",
"vendor/bin/ecs check src/ tests/ ecs.php --ansi",
"vendor/bin/phpstan analyze -c phpstan.neon --ansi"
],
"fix": [
"@composer normalize",
"./vendor/bin/ecs check ./src/ ./tests/ --ansi --fix"
"./vendor/bin/ecs check ./src/ ./tests/ ecs.php --ansi --fix"
],
"lint": [
"vendor/bin/parallel-lint -j 10 ./src ./tests",
"vendor/bin/parallel-lint -j 10 ./src ./tests ecs.php",
"@composer validate",
"@composer normalize --dry-run"
],
Expand Down
12 changes: 0 additions & 12 deletions easy-coding-standard.yaml

This file was deleted.

32 changes: 32 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php declare(strict_types=1);

use Lmc\CodingStandard\Sniffs\Naming\ClassNameSuffixByParentSniff;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
use Symplify\EasyCodingStandard\ValueObject\Option;

return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(
Option::SKIP,
[
ClassNameSuffixByParentSniff::class => ['src/Model/Command/*.php'],
]
);

$containerConfigurator->import(__DIR__ . '/vendor/lmc/coding-standard/ecs.php');

$services = $containerConfigurator->services();

// All tests must have @test annotation instead of "test" prefix.
$services->set(PhpUnitTestAnnotationFixer::class)
->call('configure', [['style' => 'annotation']]);

// Force line length
$services->set(LineLengthFixer::class)
->call(
'configure',
[['line_length' => 120, 'break_long_lines' => true, 'inline_short_lines' => false]]
);
};
4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ parameters:
- '#Unsafe usage of new static\(\)#'
- message: '#expects class-string#'
path: tests/
- message: '#parameter \$factoryArguments with no typehint specified#'
path: tests/unit/RequestBuilder/RequestBuilderFactoryTest.php
- message: '#Unsafe access to private constant .+ through static::#'
path: tests/

checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
Expand Down
17 changes: 9 additions & 8 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./vendor/autoload.php"
colors="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="unit">
Expand All @@ -13,11 +14,11 @@
</testsuite>
</testsuites>

<filter>
<whitelist>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</include>
</coverage>

<php>
<!-- E_ALL = 30719 -->
Expand Down
1 change: 1 addition & 0 deletions src/Http/ResponseDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function decode(ResponseInterface $httpResponse, string $responseClass =

$responseId = $httpResponse->getHeader(RequestManager::RESPONSE_ID_HEADER)[0] ?? null;

/** @phpstan-ignore-next-line */
return new $responseClass(
(int) $responseData->commands->number_of_commands,
(int) $responseData->commands->number_of_successful_commands,
Expand Down
7 changes: 5 additions & 2 deletions src/Model/Command/UserMerge.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ public static function mergeInto(string $targetUserId, string $sourceUserIdToBeD
*
* @return static
*/
public static function mergeFromSourceToTargetUser(string $sourceUserIdToBeDeleted, string $targetUserId, int $timestamp = null): self
{
public static function mergeFromSourceToTargetUser(
string $sourceUserIdToBeDeleted,
string $targetUserId,
int $timestamp = null
): self {
return new static($targetUserId, $sourceUserIdToBeDeleted, $timestamp);
}

Expand Down
9 changes: 7 additions & 2 deletions src/Model/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ class Request
/** @var string */
private $responseClass;

public function __construct(string $path, string $method, array $data = [], string $requestId = null, string $responseClass = Response::class)
{
public function __construct(
string $path,
string $method,
array $data = [],
string $requestId = null,
string $responseClass = Response::class
) {
$this->path = $path;
$this->method = $method;
$this->data = $data;
Expand Down
12 changes: 7 additions & 5 deletions src/Model/Response/RecommendationsResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,27 @@ class RecommendationsResponse extends Response

public function getInteraction(): CommandResponse
{
return $this->getCommandResponse(static::INTERACTION_INDEX);
return $this->getCommandResponse(self::INTERACTION_INDEX);
}

public function getUserMerge(): CommandResponse
{
return $this->getCommandResponse(static::USER_MERGE_INDEX);
return $this->getCommandResponse(self::USER_MERGE_INDEX);
}

public function getRecommendation(): CommandResponse
{
return $this->getCommandResponse(static::RECOMMENDATION_INDEX);
return $this->getCommandResponse(self::RECOMMENDATION_INDEX);
}

protected function decodeRawCommandResponses(array $commandResponses): array
{
$decodedResponses = [];
foreach ($commandResponses as $index => $rawCommandResponse) {
if ($index === static::RECOMMENDATION_INDEX) {
$decodedResponses[] = RecommendationCommandResponse::createFromRawCommandResponseObject($rawCommandResponse);
if ($index === self::RECOMMENDATION_INDEX) {
$decodedResponses[] = RecommendationCommandResponse::createFromRawCommandResponseObject(
$rawCommandResponse
);
} else {
$decodedResponses[] = CommandResponse::createFromRawCommandResponseObject($rawCommandResponse);
}
Expand Down
7 changes: 6 additions & 1 deletion src/RequestBuilder/CampaignRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public function build(): Request
}
Assertion::batchSize($this->commands);

return new Request(static::ENDPOINT_PATH, RequestMethodInterface::METHOD_POST, $this->commands, $this->requestId);
return new Request(
static::ENDPOINT_PATH,
RequestMethodInterface::METHOD_POST,
$this->commands,
$this->requestId
);
}
}
7 changes: 6 additions & 1 deletion src/RequestBuilder/EventsRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ public function build(): Request
}
Assertion::batchSize($this->commands);

return new Request(static::ENDPOINT_PATH, RequestMethodInterface::METHOD_POST, $this->commands, $this->requestId);
return new Request(
static::ENDPOINT_PATH,
RequestMethodInterface::METHOD_POST,
$this->commands,
$this->requestId
);
}
}
15 changes: 12 additions & 3 deletions tests/integration/IntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@ protected static function createMatejInstance(): Matej
protected function assertResponseCommandStatuses(Response $response, string ...$expectedCommandStatuses): void
{
$this->assertSame(count($expectedCommandStatuses), $response->getNumberOfCommands());
$this->assertSame(count(array_intersect($expectedCommandStatuses, ['OK'])), $response->getNumberOfSuccessfulCommands());
$this->assertSame(count(array_intersect($expectedCommandStatuses, ['INVALID'])), $response->getNumberOfFailedCommands());
$this->assertSame(count(array_intersect($expectedCommandStatuses, ['SKIPPED'])), $response->getNumberOfSkippedCommands());
$this->assertSame(
count(array_intersect($expectedCommandStatuses, ['OK'])),
$response->getNumberOfSuccessfulCommands()
);
$this->assertSame(
count(array_intersect($expectedCommandStatuses, ['INVALID'])),
$response->getNumberOfFailedCommands()
);
$this->assertSame(
count(array_intersect($expectedCommandStatuses, ['SKIPPED'])),
$response->getNumberOfSkippedCommands()
);

$commandResponses = $response->getCommandResponses();
foreach ($expectedCommandStatuses as $key => $expectedStatus) {
Expand Down
Loading

0 comments on commit aca4e79

Please sign in to comment.