diff --git a/composer.json b/composer.json
index 9bbc2bba..988afc5e 100644
--- a/composer.json
+++ b/composer.json
@@ -17,11 +17,11 @@
"psr/log": "^1.0||^2.0||^3.0"
},
"require-dev": {
- "behat/behat": "^3.11",
- "dvdoug/behat-code-coverage": "^5.2.2",
- "friendsofphp/php-cs-fixer": "^3.13",
+ "behat/behat": "^3.12",
+ "dvdoug/behat-code-coverage": "^5.3",
+ "friendsofphp/php-cs-fixer": "^3.14",
"monolog/monolog": "^3.2",
- "phpunit/phpunit": "^9.5.26"
+ "phpunit/phpunit": "^10.0"
},
"config": {
"preferred-install": {
diff --git a/phpunit.xml b/phpunit.xml
index 5a2e4f60..48e5a3c9 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -5,7 +5,13 @@
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
- cacheResultFile="build/phpunit-cache/results"
+ cacheDirectory="build/phpunit-cache"
+ displayDetailsOnIncompleteTests="true"
+ displayDetailsOnSkippedTests="true"
+ displayDetailsOnTestsThatTriggerDeprecations="true"
+ displayDetailsOnTestsThatTriggerErrors="true"
+ displayDetailsOnTestsThatTriggerWarnings="true"
+ displayDetailsOnTestsThatTriggerNotices="true"
>
@@ -14,7 +20,7 @@
-
+
src
diff --git a/tests/BoxListTest.php b/tests/BoxListTest.php
index 9abb2feb..93a5c21f 100644
--- a/tests/BoxListTest.php
+++ b/tests/BoxListTest.php
@@ -9,13 +9,12 @@
namespace DVDoug\BoxPacker;
use DVDoug\BoxPacker\Test\TestBox;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use function iterator_to_array;
-/**
- * @covers \DVDoug\BoxPacker\BoxList
- */
+#[CoversClass(BoxList::class)]
class BoxListTest extends TestCase
{
/**
diff --git a/tests/EfficiencyTest.php b/tests/EfficiencyTest.php
index 4834933b..99e2d115 100644
--- a/tests/EfficiencyTest.php
+++ b/tests/EfficiencyTest.php
@@ -10,21 +10,20 @@
use DVDoug\BoxPacker\Test\TestBox;
use DVDoug\BoxPacker\Test\TestItem;
+use PHPUnit\Framework\Attributes\CoversNothing;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use function fclose;
use function fgetcsv;
use function fopen;
-/**
- * @coversNothing
- */
+#[CoversNothing]
class EfficiencyTest extends TestCase
{
- /**
- * @dataProvider getSamples
- * @group efficiency
- */
+ #[DataProvider('getSamples')]
+ #[Group('efficiency')]
public function testCanPackRepresentativeLargerSamples(
array $boxes,
array $items,
@@ -95,7 +94,7 @@ public function testCanPackRepresentativeLargerSamples(
self::assertEquals($expectedWeightVariance3D, $packedBoxes3D->getWeightVariance());
}
- public function getSamples(): array
+ public static function getSamples(): array
{
$expected = ['2D' => [], '3D' => []];
diff --git a/tests/ItemListTest.php b/tests/ItemListTest.php
index 1f07b753..003a8f93 100644
--- a/tests/ItemListTest.php
+++ b/tests/ItemListTest.php
@@ -9,13 +9,12 @@
namespace DVDoug\BoxPacker;
use DVDoug\BoxPacker\Test\TestItem;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use function iterator_to_array;
-/**
- * @covers \DVDoug\BoxPacker\ItemList
- */
+#[CoversClass(ItemList::class)]
class ItemListTest extends TestCase
{
/**
diff --git a/tests/OrientatedItemTest.php b/tests/OrientatedItemTest.php
index 4df91eb2..a053298a 100644
--- a/tests/OrientatedItemTest.php
+++ b/tests/OrientatedItemTest.php
@@ -9,14 +9,13 @@
namespace DVDoug\BoxPacker;
use DVDoug\BoxPacker\Test\TestItem;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use function json_decode;
use function json_encode;
-/**
- * @covers \DVDoug\BoxPacker\OrientatedItem
- */
+#[CoversClass(OrientatedItem::class)]
class OrientatedItemTest extends TestCase
{
public function testSerialize(): void
diff --git a/tests/PackedBoxListTest.php b/tests/PackedBoxListTest.php
index 7769cee9..2bc5d560 100644
--- a/tests/PackedBoxListTest.php
+++ b/tests/PackedBoxListTest.php
@@ -10,13 +10,12 @@
use DVDoug\BoxPacker\Test\TestBox;
use DVDoug\BoxPacker\Test\TestItem;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use function json_encode;
-/**
- * @covers \DVDoug\BoxPacker\PackedBoxList
- */
+#[CoversClass(PackedBoxList::class)]
class PackedBoxListTest extends TestCase
{
/**
diff --git a/tests/PackedBoxTest.php b/tests/PackedBoxTest.php
index 484c1464..8f3b98fe 100644
--- a/tests/PackedBoxTest.php
+++ b/tests/PackedBoxTest.php
@@ -11,14 +11,13 @@
use DVDoug\BoxPacker\Test\LimitedSupplyTestBox;
use DVDoug\BoxPacker\Test\TestBox;
use DVDoug\BoxPacker\Test\TestItem;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use ReflectionProperty;
use function json_encode;
-/**
- * @covers \DVDoug\BoxPacker\PackedBox
- */
+#[CoversClass(PackedBox::class)]
class PackedBoxTest extends TestCase
{
/**
diff --git a/tests/PackedItemTest.php b/tests/PackedItemTest.php
index b214a7a3..e8e59648 100644
--- a/tests/PackedItemTest.php
+++ b/tests/PackedItemTest.php
@@ -10,13 +10,12 @@
use DVDoug\BoxPacker\Test\TestItem;
use DVDoug\BoxPacker\Test\THPackTestItem;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use function json_encode;
-/**
- * @covers \DVDoug\BoxPacker\PackedItem
- */
+#[CoversClass(PackedItem::class)]
class PackedItemTest extends TestCase
{
/**
diff --git a/tests/PackerTest.php b/tests/PackerTest.php
index a7d7e162..8d51ea3b 100644
--- a/tests/PackerTest.php
+++ b/tests/PackerTest.php
@@ -14,6 +14,7 @@
use DVDoug\BoxPacker\Test\PackedBoxByReferenceSorter;
use DVDoug\BoxPacker\Test\TestBox;
use DVDoug\BoxPacker\Test\TestItem;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use function iterator_to_array;
@@ -210,8 +211,8 @@ public function testIssue168(): void
/**
* From issue #182.
- * @group efficiency
*/
+ #[Group('efficiency')]
public function testIssue182A(): void
{
$packer = new Packer();
@@ -389,8 +390,8 @@ public function testIssue196(): void
/**
* From PR #198, tests with an atypically large number of boxes.
- * @group efficiency
*/
+ #[Group('efficiency')]
public function testNumberOfBoxesTorture(): void
{
$packer = new Packer();
@@ -678,8 +679,8 @@ public function testUnpackableItemsHandledWhenNotThrowing(): void
/**
* From issue #182.
- * @group efficiency
*/
+ #[Group('efficiency')]
public function testIssue182B(): void
{
$packer = new Packer();
diff --git a/tests/PublishedTestCasesTest.php b/tests/PublishedTestCasesTest.php
index d678ca5c..df63cab3 100644
--- a/tests/PublishedTestCasesTest.php
+++ b/tests/PublishedTestCasesTest.php
@@ -10,6 +10,8 @@
use DVDoug\BoxPacker\Test\TestBox;
use DVDoug\BoxPacker\Test\THPackTestItem;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use function explode;
@@ -58,19 +60,18 @@ public static function setUpBeforeClass(): void
/**
* H.T. Loh & A.Y.C. Nee, 1992, A packing algorithm for hexahedral
* boxes, Proc. Industrial Automation 92 Conf. Singapore, 115-126.
- *
- * @dataProvider lohAndNeeData
- * @group efficiency
*/
+ #[DataProvider('lohAndNeeData')]
+ #[Group('efficiency')]
public function testLohAndNee($problem, $box, $items): void
{
- $this->runPublishedTestcase($problem, $box, $items);
+ self::runPublishedTestcase($problem, $box, $items);
}
- public function lohAndNeeData(): array
+ public static function lohAndNeeData(): array
{
$data = [];
- $fileData = $this->thpackDecode('thpack8.txt');
+ $fileData = self::thpackDecode('thpack8.txt');
foreach ($fileData as &$problem) {
$problem[0] = "Loh and Nee #{$problem[0]}";
$data[$problem[0]] = $problem;
@@ -82,21 +83,20 @@ public function lohAndNeeData(): array
/**
* E.E. Bischoff and M.S.W. Ratcliff, "Issues in the development of
* Approaches to Container Loading", OMEGA, vol.23, no.4, (1995).
- *
- * @dataProvider bischoffData
- * @group efficiency
*/
+ #[DataProvider('bischoffData')]
+ #[Group('efficiency')]
public function testBischoff($problem, $box, $items): void
{
- $this->runPublishedTestcase($problem, $box, $items);
+ self::runPublishedTestcase($problem, $box, $items);
}
- public function bischoffData(): array
+ public static function bischoffData(): array
{
$data = [];
for ($i = 1; $i <= 7; ++$i) {
- $fileData = $this->thpackDecode("thpack{$i}.txt");
+ $fileData = self::thpackDecode("thpack{$i}.txt");
foreach ($fileData as &$problem) {
$problem[0] = "Bischoff #{$problem[3]}-{$problem[0]}";
$data[$problem[0]] = $problem;
@@ -106,7 +106,7 @@ public function bischoffData(): array
return $data;
}
- public function runPublishedTestcase($problem, Box $box, ItemList $items): void
+ public static function runPublishedTestcase($problem, Box $box, ItemList $items): void
{
$packer = new VolumePacker($box, $items);
$packedBox = $packer->pack();
@@ -116,7 +116,7 @@ public function runPublishedTestcase($problem, Box $box, ItemList $items): void
self::assertEquals(self::$expectedResults[$problem], $volumeUtilisation);
}
- protected function thpackDecode($filename): array
+ protected static function thpackDecode($filename): array
{
$data = [];
diff --git a/tests/Test/ConstrainedPlacementByCountTestItem.php b/tests/Test/ConstrainedPlacementByCountTestItem.php
index 4b6ac855..38e1a5e7 100644
--- a/tests/Test/ConstrainedPlacementByCountTestItem.php
+++ b/tests/Test/ConstrainedPlacementByCountTestItem.php
@@ -19,10 +19,7 @@
class ConstrainedPlacementByCountTestItem extends TestItem implements ConstrainedPlacementItem
{
- /**
- * @var int
- */
- public static $limit = 3;
+ public static int $limit = 3;
/**
* Hook for user implementation of item-specific constraints, e.g. max batteries per box.
diff --git a/tests/Test/PackedBoxByReferenceSorter.php b/tests/Test/PackedBoxByReferenceSorter.php
index 8831b656..fc6eca73 100644
--- a/tests/Test/PackedBoxByReferenceSorter.php
+++ b/tests/Test/PackedBoxByReferenceSorter.php
@@ -13,10 +13,7 @@
class PackedBoxByReferenceSorter implements PackedBoxSorter
{
- /**
- * @var string
- */
- public static $reference = '';
+ public static string $reference = '';
public function compare(PackedBox $boxA, PackedBox $boxB): int
{
diff --git a/tests/VolumePackerTest.php b/tests/VolumePackerTest.php
index ef730ce9..918d5b9f 100644
--- a/tests/VolumePackerTest.php
+++ b/tests/VolumePackerTest.php
@@ -12,6 +12,7 @@
use DVDoug\BoxPacker\Test\ConstrainedPlacementNoStackingTestItem;
use DVDoug\BoxPacker\Test\TestBox;
use DVDoug\BoxPacker\Test\TestItem;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use function array_fill;
@@ -327,8 +328,8 @@ public function testIssue174(): void
/**
* From issue #172.
- * @group efficiency
*/
+ #[Group('efficiency')]
public function testIssue172A(): void
{
$box = new TestBox('Box', 800, 1200, 1300, 0, 800, 1200, 1300, 500000);
diff --git a/tests/WeightRedistributorTest.php b/tests/WeightRedistributorTest.php
index db9700e1..b8147282 100644
--- a/tests/WeightRedistributorTest.php
+++ b/tests/WeightRedistributorTest.php
@@ -11,13 +11,13 @@
use DVDoug\BoxPacker\Test\ConstrainedPlacementNoStackingTestItem;
use DVDoug\BoxPacker\Test\TestBox;
use DVDoug\BoxPacker\Test\TestItem;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use function iterator_to_array;
-/**
- * @covers \DVDoug\BoxPacker\WeightRedistributor
- */
+#[CoversClass(WeightRedistributor::class)]
class WeightRedistributorTest extends TestCase
{
/**
@@ -38,8 +38,8 @@ public function testWeightRedistributionActivatesOrNot(): void
/**
* From issue #166.
- * @group efficiency
*/
+ #[Group('efficiency')]
public function testIssue166(): void
{
$packer = new Packer();
diff --git a/tests/WorkingVolumeTest.php b/tests/WorkingVolumeTest.php
index dea7429d..d6ce0de9 100644
--- a/tests/WorkingVolumeTest.php
+++ b/tests/WorkingVolumeTest.php
@@ -8,14 +8,13 @@
namespace DVDoug\BoxPacker;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use function json_decode;
use function json_encode;
-/**
- * @covers \DVDoug\BoxPacker\WorkingVolume
- */
+#[CoversClass(WorkingVolume::class)]
class WorkingVolumeTest extends TestCase
{
private WorkingVolume $volume;