Skip to content

Commit

Permalink
Merge branch 'refs/heads/update-ci' into migrate-to-openapi
Browse files Browse the repository at this point in the history
# Conflicts:
#	tests/ClientTest.php
#	tests/Endpoint/CategoryEndpointTest.php
#	tests/Factory/CategoryFactoryTest.php
#	tests/Factory/TokenFactoryTest.php
  • Loading branch information
vstelmakh committed May 7, 2024
2 parents ea26ff7 + 8935f2c commit ee3fca5
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 40 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ jobs:
coverage: xdebug

- name: Git checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Validate composer.json and composer.lock
run: composer validate

- name: Prepare Composer cache vars
id: composer
run: |
echo "::set-output name=cache_dir::$(composer config cache-files-dir)"
echo "::set-output name=cache_key::composer-$(date +'%Y-%m-%d')-${{ matrix.php }}${{ matrix.composer }}-"
echo "cache_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
echo "cache_key=composer-$(date +'%Y-%m-%d')-${{ matrix.php }}${{ matrix.composer }}-" >> $GITHUB_OUTPUT
- name: Cache Composer dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer.outputs.cache_dir }}
key: ${{ steps.composer.outputs.cache_key }}${{ hashFiles('**/composer.json') }}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require-dev": {
"phpstan/phpstan": "^1.9",
"squizlabs/php_codesniffer": "^3.7",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^10.5|11.0.*"
},
"suggest": {
"ext-curl": "To send requests using cURL"
Expand Down
7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ parameters:
- tests

reportUnmatchedIgnoredErrors: false
ignoreErrors:
-
message: '#return type has no value type specified in iterable type array.#'
path: tests/*Test.php
-
message: '#with no value type specified in iterable type array.#'
path: tests/*Test.php
35 changes: 23 additions & 12 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true"
cacheResult="true"
cacheResultFile="var/phpunit.result.cache"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
cacheDirectory="var/phpunit"
failOnRisky="true"
failOnDeprecation="true"
failOnWarning="true"
failOnNotice="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerErrors="true"
>
<php>
<ini name="display_errors" value="1" />
<ini name="error_reporting" value="-1" />
</php>

<testsuites>
<testsuite name="default">
<directory suffix="Test.php">tests</directory>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<coverage>
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory suffix=".php">src</directory>
<directory>src</directory>
</include>
</coverage>
</source>
</phpunit>
11 changes: 3 additions & 8 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Kyto\Alibaba\Client;
use Kyto\Alibaba\Exception\ResponseException;
use Kyto\Alibaba\Util\Clock;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Contracts\HttpClient\HttpClientInterface;
Expand Down Expand Up @@ -37,10 +38,7 @@ public function tearDown(): void
);
}

/**
* @dataProvider requestDataProvider
* @param mixed[] $responseData
*/
#[DataProvider('requestDataProvider')]
public function testRequest(bool $isSuccess, string $endpoint, array $responseData): void
{
$timestamp = '2024-04-30 18:17:25';
Expand Down Expand Up @@ -86,10 +84,7 @@ public function testRequest(bool $isSuccess, string $endpoint, array $responseDa
self::assertSame($responseData, $actual);
}

/**
* @return mixed[]
*/
public function requestDataProvider(): array
public static function requestDataProvider(): array
{
return [
'success' => [true, '/some/endpoint', ['successful' => 'response']],
Expand Down
11 changes: 3 additions & 8 deletions tests/Factory/CategoryFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Kyto\Alibaba\Factory\CategoryFactory;
use Kyto\Alibaba\Model\Category;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class CategoryFactoryTest extends TestCase
Expand All @@ -24,20 +25,14 @@ public function tearDown(): void
);
}

/**
* @dataProvider createCategoryDataProvider
* @param mixed[] $data
*/
#[DataProvider('createCategoryDataProvider')]
public function testCreateCategory(array $data, Category $expected): void
{
$actual = $this->categoryFactory->createCategory($data);
self::assertEquals($expected, $actual);
}

/**
* @return \Generator<mixed>
*/
public function createCategoryDataProvider(): \Generator
public static function createCategoryDataProvider(): \Generator
{
$data = [
'result' => [
Expand Down
10 changes: 3 additions & 7 deletions tests/Util/ClockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Kyto\Alibaba\Tests\Util;

use Kyto\Alibaba\Util\Clock;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class ClockTest extends TestCase
Expand All @@ -23,9 +24,7 @@ public function tearDown(): void
);
}

/**
* @dataProvider nowDataProvider
*/
#[DataProvider('nowDataProvider')]
public function testNow(?string $timezoneName, ?\DateTimeZone $timezone): void
{
$actual = $this->clock->now($timezoneName);
Expand All @@ -37,10 +36,7 @@ public function testNow(?string $timezoneName, ?\DateTimeZone $timezone): void
);
}

/**
* @return mixed[]
*/
public function nowDataProvider(): array
public static function nowDataProvider(): array
{
return [
'default timezone' => [null, null],
Expand Down

0 comments on commit ee3fca5

Please sign in to comment.