diff --git a/.github/workflows/tag_meged_pull_request.yml b/.github/workflows/tag_meged_pull_request.yml index 5739c59..044bba3 100644 --- a/.github/workflows/tag_meged_pull_request.yml +++ b/.github/workflows/tag_meged_pull_request.yml @@ -23,7 +23,7 @@ jobs: tools: composer:v2 - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/test_pull_request.yml b/.github/workflows/test_pull_request.yml index 698327c..b72af4f 100644 --- a/.github/workflows/test_pull_request.yml +++ b/.github/workflows/test_pull_request.yml @@ -15,7 +15,7 @@ jobs: tools: composer:v2 - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -63,12 +63,12 @@ jobs: tools: composer:v2 - name: Set up Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: '14.x' - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -126,12 +126,12 @@ jobs: tools: composer:v2 - name: Set up Node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: '14.x' - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -139,7 +139,7 @@ jobs: run: composer install --no-interaction - name: Update PHPUnit for Code Coverage - run: composer require phpunit/phpunit:^9.6 phploc/phploc:* sebastian/version:* --with-all-dependencies + run: composer require phpunit/phpunit:^10.5 sebastian/version:* --with-all-dependencies - name: PHP Lint run: ./vendor/bin/parallel-lint src tests examples @@ -147,4 +147,4 @@ jobs: - name: Unit tests run: | mkdir -p build/logs - ./vendor/bin/phpunit ./tests/ --coverage-clover build/logs/clover.xml + XDEBUG_MODE=coverage ./vendor/bin/phpunit ./tests/ --coverage-clover build/logs/clover.xml --coverage-filter=./src/ diff --git a/.gitignore b/.gitignore index 6989baa..5819720 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ - +composer.lock +.php-version /vendor /.phpunit.cache .phpunit.result.cache diff --git a/README.md b/README.md index d6fa733..b38c67a 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ composer require macocci7/php-boxplot ```php =8.1", + "intervention/image": "^3.5", + "macocci7/php-frequency-table": "1.3.0", "fakerphp/faker": "^1.22", "nette/neon": "^3.4" }, "require-dev": { "squizlabs/php_codesniffer": "^3.7", - "phpunit/phpunit": "^9.6", + "phpunit/phpunit": "^10.5", "phpmd/phpmd": "^2.15", "phpstan/phpstan": "^1.10", - "phploc/phploc": "^7.0", "php-parallel-lint/php-parallel-lint": "^1.3" }, "license": "MIT", diff --git a/examples/AdjustDisplayByArray.php b/examples/AdjustDisplayByArray.php index 29e5fed..359e422 100644 --- a/examples/AdjustDisplayByArray.php +++ b/examples/AdjustDisplayByArray.php @@ -1,6 +1,6 @@ + diff --git a/tests/AnalyzerTest.php b/tests/AnalyzerTest.php index fd05406..557d276 100644 --- a/tests/AnalyzerTest.php +++ b/tests/AnalyzerTest.php @@ -4,14 +4,13 @@ namespace Macocci7\PhpBoxplot; -require('vendor/autoload.php'); - +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Macocci7\PhpBoxplot\Analyzer; /** - * @SuppressWarnings(PHPMD.CamelCaseMethodName) * @SuppressWarnings(PHPMD.TooManyPublicMethods) + * @SuppressWarnings(PHPMD.CamelCaseMethodName) */ final class AnalyzerTest extends TestCase { @@ -25,9 +24,7 @@ public static function provide_limit_throw_exception_with_invalid_params(): arra ]; } - /** - * @dataProvider provide_limit_throw_exception_with_invalid_params - */ + #[DataProvider('provide_limit_throw_exception_with_invalid_params')] public function test_limit_throw_exception_with_invalid_params(int|float $lower, int|float $upper): void { $a = new Analyzer(); @@ -46,9 +43,7 @@ public static function provide_limit_can_set_limit_correctly(): array ]; } - /** - * @dataProvider provide_limit_can_set_limit_correctly - */ + #[DataProvider('provide_limit_can_set_limit_correctly')] public function test_limit_can_set_limit_correctly(int|float $lower, int|float $upper): void { $a = new Analyzer(); @@ -75,9 +70,7 @@ public static function provide_getMean_can_get_mean_correctly(): array ]; } - /** - * @dataProvider provide_getMean_can_get_mean_correctly - */ + #[DataProvider('provide_getMean_can_get_mean_correctly')] public function test_getMean_can_get_mean_correctly(array $data, int|float|null $expect): void { $bp = new Boxplot(); @@ -94,9 +87,7 @@ public static function provide_getUcl_can_get_ucl_correctly(): array ]; } - /** - * @dataProvider provide_getUcl_can_get_ucl_correctly - */ + #[DataProvider('provide_getUcl_can_get_ucl_correctly')] public function test_getUcl_can_get_ucl_correctly(array $data, float|null $expect): void { $a = new Analyzer(); @@ -117,9 +108,7 @@ public static function provide_getLcl_can_get_lcl_correctly(): array ]; } - /** - * @dataProvider provide_getLcl_can_get_lcl_correctly - */ + #[DataProvider('provide_getLcl_can_get_lcl_correctly')] public function test_getLcl_can_get_lcl_correctly(array $data, float|null $expect): void { $a = new Analyzer(); @@ -143,9 +132,7 @@ public static function provide_getOutliers_can_get_outliers_correctly(): array ]; } - /** - * @dataProvider provide_getOutliers_can_get_outliers_correctly - */ + #[DataProvider('provide_getOutliers_can_get_outliers_correctly')] public function test_getOutliers_can_get_outliers_correctly(array $data, array|null $expect): void { $a = new Analyzer(); diff --git a/tests/Helpers/ConfigTest.php b/tests/Helpers/ConfigTest.php index 5034e15..fb9f8c6 100644 --- a/tests/Helpers/ConfigTest.php +++ b/tests/Helpers/ConfigTest.php @@ -4,13 +4,12 @@ namespace Macocci7\PhpBoplot\Helpers; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Macocci7\PhpBoxplot\Helpers\Config; use Nette\Neon\Neon; /** - * @SuppressWarnings(PHPMD.TooManyMethods) - * @SuppressWarnings(PHPMD.TooManyPublicMethods) * @SuppressWarnings(PHPMD.CamelCaseMethodName) */ final class ConfigTest extends TestCase @@ -59,9 +58,7 @@ public static function provide_className_can_return_class_name_correctly(): arra ]; } - /** - * @dataProvider provide_className_can_return_class_name_correctly - */ + #[DataProvider('provide_className_can_return_class_name_correctly')] public function test_className_can_return_class_name_correctly(string $class, string $expect): void { $this->assertSame($expect, Config::className($class)); @@ -91,9 +88,7 @@ public static function provide_support_object_like_keys_correctly(): array ]; } - /** - * @dataProvider provide_support_object_like_keys_correctly - */ + #[DataProvider('provide_support_object_like_keys_correctly')] public function get_can_support_object_like_keys_correctly(string $key, array|null $expect): void { $this->assertSame($expect, Config::get($key)); diff --git a/tests/Traits/JudgeTraitTest.php b/tests/Traits/JudgeTraitTest.php index 6819e2b..0dd3709 100644 --- a/tests/Traits/JudgeTraitTest.php +++ b/tests/Traits/JudgeTraitTest.php @@ -4,12 +4,12 @@ namespace Macocci7\PhpBoxplot\Traits; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use Macocci7\PhpBoxplot\Traits\JudgeTrait; use Nette\Neon\Neon; /** - * @SuppressWarnings(PHPMD.TooManyMethods) * @SuppressWarnings(PHPMD.TooManyPublicMethods) * @SuppressWarnings(PHPMD.CamelCaseMethodName) */ @@ -40,9 +40,7 @@ public static function provide_isIntAll_can_judge_correctly(): array ]; } - /** - * @dataProvider provide_isIntAll_can_judge_correctly - */ + #[DataProvider('provide_isIntAll_can_judge_correctly')] public function test_isIntAll_can_judge_correctly(array $items, bool $expect): void { $this->assertSame($expect, self::isIntAll($items)); @@ -71,9 +69,7 @@ public static function provide_isNumber_can_judge_correctly(): array ]; } - /** - * @dataProvider provide_isNumber_can_judge_correctly - */ + #[DataProvider('provide_isNumber_can_judge_correctly')] public function test_isNumber_can_judge_correctly(mixed $item, bool $expect): void { $this->assertSame($expect, self::isNumber($item)); @@ -102,9 +98,7 @@ public static function provide_isNumbersAll_can_judge_correctly(): array ]; } - /** - * @dataProvider provide_isNumbersAll_can_judge_correctly - */ + #[DataProvider('provide_isNumbersAll_can_judge_correctly')] public function test_isNumbersAll_can_judge_correctly(mixed $items, bool $expect): void { $this->assertSame($expect, self::isNumbersAll($items)); @@ -135,9 +129,7 @@ public static function provide_isColorCode_can_judge_correctly(): array ]; } - /** - * @dataProvider provide_isColorCode_can_judge_correctly - */ + #[DataProvider('provide_isColorCode_can_judge_correctly')] public function test_isColorCode_can_judge_correctly(string $color, bool $expect): void { $this->assertSame($expect, self::isColorCode($color)); @@ -159,9 +151,7 @@ public static function provide_isColorCodeAll_can_judge_correctly(): array ]; } - /** - * @dataProvider provide_isColorCodeAll_can_judge_correctly - */ + #[DataProvider('provide_isColorCodeAll_can_judge_correctly')] public function test_isColorCodeAll_can_judge_correctly(array $params, bool $expect): void { $this->assertSame($expect, self::isColorCodeAll($params)); @@ -248,9 +238,7 @@ public static function provide_isValidType_can_judge_correctly(): array ]; } - /** - * @dataProvider provide_isValidType_can_judge_correctly - */ + #[DataProvider('provide_isValidType_can_judge_correctly')] public function test_isValidType_can_judge_correctly(mixed $input, string $def, bool $expect): void { $this->assertSame($expect, self::isValidType($input, $def)); @@ -286,9 +274,7 @@ public static function provide_isValidData_can_judge_correctly(): array ]; } - /** - * @dataProvider provide_isValidData_can_judge_correctly - */ + #[DataProvider('provide_isValidData_can_judge_correctly')] public function test_isValidData_can_judge_correctly(mixed $data, bool $expect): void { $this->assertSame($expect, self::isValidData($data)); @@ -366,9 +352,7 @@ public static function provide_isValidDataset_can_judge_correctly(): array ]; } - /** - * @dataProvider provide_isValidDataset_can_judge_correctly - */ + #[DataProvider('provide_isValidDataset_can_judge_correctly')] public function test_isValidDataset_can_judge_correctly(mixed $dataset, bool $expect): void { $this->assertSame($expect, self::isValidDataset($dataset));