Skip to content

Commit

Permalink
Bump PHPUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Feb 26, 2023
1 parent b60eb31 commit 596b1a1
Show file tree
Hide file tree
Showing 16 changed files with 59 additions and 65 deletions.
8 changes: 4 additions & 4 deletions composer.json
Expand Up @@ -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": {
Expand Down
10 changes: 8 additions & 2 deletions phpunit.xml
Expand Up @@ -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"
>

<testsuites>
Expand All @@ -14,7 +20,7 @@
</testsuite>
</testsuites>

<coverage pathCoverage="true" cacheDirectory="build/php-code-coverage-cache">
<coverage pathCoverage="true">
<include>
<directory suffix=".php">src</directory>
</include>
Expand Down
5 changes: 2 additions & 3 deletions tests/BoxListTest.php
Expand Up @@ -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
{
/**
Expand Down
15 changes: 7 additions & 8 deletions tests/EfficiencyTest.php
Expand Up @@ -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,
Expand Down Expand Up @@ -95,7 +94,7 @@ public function testCanPackRepresentativeLargerSamples(
self::assertEquals($expectedWeightVariance3D, $packedBoxes3D->getWeightVariance());
}

public function getSamples(): array
public static function getSamples(): array
{
$expected = ['2D' => [], '3D' => []];

Expand Down
5 changes: 2 additions & 3 deletions tests/ItemListTest.php
Expand Up @@ -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
{
/**
Expand Down
5 changes: 2 additions & 3 deletions tests/OrientatedItemTest.php
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions tests/PackedBoxListTest.php
Expand Up @@ -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
{
/**
Expand Down
5 changes: 2 additions & 3 deletions tests/PackedBoxTest.php
Expand Up @@ -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
{
/**
Expand Down
5 changes: 2 additions & 3 deletions tests/PackedItemTest.php
Expand Up @@ -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
{
/**
Expand Down
7 changes: 4 additions & 3 deletions tests/PackerTest.php
Expand Up @@ -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;
Expand Down Expand Up @@ -210,8 +211,8 @@ public function testIssue168(): void

/**
* From issue #182.
* @group efficiency
*/
#[Group('efficiency')]
public function testIssue182A(): void
{
$packer = new Packer();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -678,8 +679,8 @@ public function testUnpackableItemsHandledWhenNotThrowing(): void

/**
* From issue #182.
* @group efficiency
*/
#[Group('efficiency')]
public function testIssue182B(): void
{
$packer = new Packer();
Expand Down
28 changes: 14 additions & 14 deletions tests/PublishedTestCasesTest.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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();
Expand All @@ -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 = [];

Expand Down
5 changes: 1 addition & 4 deletions tests/Test/ConstrainedPlacementByCountTestItem.php
Expand Up @@ -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 <x> batteries per box.
Expand Down
5 changes: 1 addition & 4 deletions tests/Test/PackedBoxByReferenceSorter.php
Expand Up @@ -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
{
Expand Down
3 changes: 2 additions & 1 deletion tests/VolumePackerTest.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions tests/WeightRedistributorTest.php
Expand Up @@ -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
{
/**
Expand All @@ -38,8 +38,8 @@ public function testWeightRedistributionActivatesOrNot(): void

/**
* From issue #166.
* @group efficiency
*/
#[Group('efficiency')]
public function testIssue166(): void
{
$packer = new Packer();
Expand Down
5 changes: 2 additions & 3 deletions tests/WorkingVolumeTest.php
Expand Up @@ -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;
Expand Down

0 comments on commit 596b1a1

Please sign in to comment.