Skip to content

Commit

Permalink
Bump PHPUnit version to 10 (#340)
Browse files Browse the repository at this point in the history
* Bump PHPUnit version

* Update rule sets to PHP 8 + PHPUnit 10
  • Loading branch information
W0rma authored Aug 3, 2024
1 parent 628425a commit 7b63a73
Show file tree
Hide file tree
Showing 37 changed files with 140 additions and 302 deletions.
6 changes: 3 additions & 3 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PHP71Migration:risky' => true,
'@PHP73Migration' => true,
'@PHPUnit75Migration:risky' => true,
'@PHP80Migration:risky' => true,
'@PHP81Migration' => true,
'@PHPUnit100Migration:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => true,
'declare_strict_types' => false,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fancy paginator component

## Running unit tests

PHPUnit 9 or newer is required.
PHPUnit 10 or 11 is required.
To setup and run tests follow these steps:

- go to the root directory of components
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"doctrine/orm": "^2.13 || ^3.0",
"doctrine/phpcr-odm": "^1.8 || ^2.0",
"jackalope/jackalope-doctrine-dbal": "^1.12 || ^2.0",
"phpunit/phpunit": "^9.6",
"phpunit/phpunit": "^10.5 || ^11.3",
"propel/propel1": "^1.7",
"ruflin/elastica": "^7.0",
"solarium/solarium": "^6.0",
Expand Down
5 changes: 2 additions & 3 deletions tests/Test/Pager/Pagination/AbstractPaginationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
use Knp\Component\Pager\Event\Subscriber\Paginate\ArraySubscriber;
use Knp\Component\Pager\Paginator;
use Knp\Component\Pager\PaginatorInterface;
use PHPUnit\Framework\Attributes\Test;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Test\Mock\PaginationSubscriber as MockPaginationSubscriber;
use Test\Tool\BaseTestCase;

final class AbstractPaginationTest extends BaseTestCase
{
/**
* @test
*/
#[Test]
public function shouldCustomizeParameterNames(): void
{
$dispatcher = new EventDispatcher;
Expand Down
5 changes: 2 additions & 3 deletions tests/Test/Pager/Pagination/CustomParameterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@

use Knp\Component\Pager\ArgumentAccess\ArgumentAccessInterface;
use Knp\Component\Pager\Paginator;
use PHPUnit\Framework\Attributes\Test;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Test\Mock\CustomParameterSubscriber;
use Test\Mock\PaginationSubscriber as MockPaginationSubscriber;
use Test\Tool\BaseTestCase;

final class CustomParameterTest extends BaseTestCase
{
/**
* @test
*/
#[Test]
public function shouldGiveCustomParametersToPaginationView(): void
{
$dispatcher = new EventDispatcher;
Expand Down
9 changes: 3 additions & 6 deletions tests/Test/Pager/Pagination/DefaultLimitOptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
namespace Test\Pager\Pagination;

use Knp\Component\Pager\PaginatorInterface;
use PHPUnit\Framework\Attributes\Test;
use Test\Tool\BaseTestCase;

final class DefaultLimitOptionTest extends BaseTestCase
{
/**
* @test
*/
#[Test]
public function shouldBeAbleToHandleNullLimit(): void
{
$p = $this->getPaginatorInstance();
Expand All @@ -20,9 +19,7 @@ public function shouldBeAbleToHandleNullLimit(): void
$this->assertEquals(PaginatorInterface::DEFAULT_LIMIT_VALUE, $pagination['numItemsPerPage']);
}

/**
* @test
*/
#[Test]
public function shouldBeAbleToOverwriteDefaultLimit(): void
{
$p = $this->getPaginatorInstance();
Expand Down
13 changes: 4 additions & 9 deletions tests/Test/Pager/Pagination/PaginationInterfaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Test\Pager\Pagination;

use Knp\Component\Pager\Pagination\PaginationInterface;
use PHPUnit\Framework\Attributes\Test;
use Test\Tool\BaseTestCase;

final class PaginationInterfaceTest extends BaseTestCase
Expand All @@ -14,27 +15,21 @@ protected function setUp(): void
$this->reflection = new \ReflectionClass(PaginationInterface::class);
}

/**
* @test
*/
#[Test]
public function shouldBeCountable(): void
{
$this->assertTrue($this->reflection->implementsInterface(\Countable::class));
}

/**
* @test
*/
#[Test]
public function shouldBeTraversable(): void
{
$this->assertTrue($this->reflection->implementsInterface(\Traversable::class));
$this->assertFalse($this->reflection->implementsInterface(\Iterator::class));
$this->assertFalse($this->reflection->implementsInterface(\IteratorAggregate::class));
}

/**
* @test
*/
#[Test]
public function shouldBeArrayAccessible(): void
{
$this->assertTrue($this->reflection->implementsInterface(\ArrayAccess::class));
Expand Down
9 changes: 3 additions & 6 deletions tests/Test/Pager/Pagination/PaginatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

use Knp\Component\Pager\Exception\PageLimitInvalidException;
use Knp\Component\Pager\Exception\PageNumberInvalidException;
use PHPUnit\Framework\Attributes\Test;
use Test\Tool\BaseTestCase;

final class PaginatorTest extends BaseTestCase
{
/**
* @test
*/
#[Test]
public function shouldThrowExceptionIfPageIsInvalid(): void
{
$this->expectException(PageNumberInvalidException::class);
Expand All @@ -19,9 +18,7 @@ public function shouldThrowExceptionIfPageIsInvalid(): void
$paginator->paginate(['a', 'b'], 0, 10);
}

/**
* @test
*/
#[Test]
public function shouldThrowExceptionIfLimitIsInvalid(): void
{
$this->expectException(PageLimitInvalidException::class);
Expand Down
21 changes: 6 additions & 15 deletions tests/Test/Pager/Pagination/PreventPageOutOfRangeOptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

use Knp\Component\Pager\Exception\PageNumberOutOfRangeException;
use Knp\Component\Pager\PaginatorInterface;
use PHPUnit\Framework\Attributes\Test;
use Test\Tool\BaseTestCase;

final class PreventPageOutOfRangeOptionTest extends BaseTestCase
{
/**
* @test
*/
#[Test]
public function shouldBeAbleToHandleOutOfRangePageNumberAsArgument(): void
{
$p = $this->getPaginatorInstance();
Expand All @@ -31,9 +30,7 @@ public function shouldBeAbleToHandleOutOfRangePageNumberAsArgument(): void
$p->paginate($items, 10, 10, [PaginatorInterface::PAGE_OUT_OF_RANGE => PaginatorInterface::PAGE_OUT_OF_RANGE_THROW_EXCEPTION]);
}

/**
* @test
*/
#[Test]
public function shouldBeAbleToHandleOutOfRangePageNumberAsArgumentWithEmptyList(): void
{
$p = $this->getPaginatorInstance();
Expand All @@ -54,9 +51,7 @@ public function shouldBeAbleToHandleOutOfRangePageNumberAsArgumentWithEmptyList(
$p->paginate($items, 10, 10, [PaginatorInterface::PAGE_OUT_OF_RANGE => PaginatorInterface::PAGE_OUT_OF_RANGE_THROW_EXCEPTION]);
}

/**
* @test
*/
#[Test]
public function shouldBeAbleToHandleOutOfRangePageNumberAsDefaultOption(): void
{
$p = $this->getPaginatorInstance();
Expand All @@ -83,9 +78,7 @@ public function shouldBeAbleToHandleOutOfRangePageNumberAsDefaultOption(): void
$p->paginate($items, 10, 10);
}

/**
* @test
*/
#[Test]
public function shouldBeAbleToGetMaxPageWhenExceptionIsThrown(): void
{
$p = $this->getPaginatorInstance();
Expand All @@ -98,9 +91,7 @@ public function shouldBeAbleToGetMaxPageWhenExceptionIsThrown(): void
}
}

/**
* @test
*/
#[Test]
public function shouldBeAbleToTreatFirstPageAsValidWithEmptyList(): void
{
$p = $this->getPaginatorInstance();
Expand Down
17 changes: 5 additions & 12 deletions tests/Test/Pager/Pagination/SlidingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace Test\Pager\Pagination;

use PHPUnit\Framework\Attributes\Test;
use Test\Tool\BaseTestCase;

final class SlidingTest extends BaseTestCase
{
/**
* @test
*/
#[Test]
public function shouldBeAbleToProducePagination(): void
{
$p = $this->getPaginatorInstance();
Expand All @@ -35,9 +34,7 @@ public function shouldBeAbleToProducePagination(): void
$this->assertEquals(10, $pagination['lastItemNumber']);
}

/**
* @test
*/
#[Test]
public function shouldBeAbleToProduceWiderPagination(): void
{
$p = $this->getPaginatorInstance();
Expand All @@ -62,9 +59,7 @@ public function shouldBeAbleToProduceWiderPagination(): void
$this->assertEquals(20, $pagination['lastItemNumber']);
}

/**
* @test
*/
#[Test]
public function shouldHandleOddAndEvenRange(): void
{
$p = $this->getPaginatorInstance();
Expand All @@ -88,9 +83,7 @@ public function shouldHandleOddAndEvenRange(): void
$this->assertEquals(5, $pagination['lastPageInRange']);
}

/**
* @test
*/
#[Test]
public function shouldNotFallbackToPageInCaseIfExceedsItemLimit(): void
{
$p = $this->getPaginatorInstance();
Expand Down
5 changes: 2 additions & 3 deletions tests/Test/Pager/Pagination/TraversableItemsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace Test\Pager\Pagination;

use PHPUnit\Framework\Attributes\Test;
use Test\Tool\BaseTestCase;

final class TraversableItemsTest extends BaseTestCase
{
/**
* @test
*/
#[Test]
public function shouldBeAbleToUseTraversableItems(): void
{
$p = $this->getPaginatorInstance();
Expand Down
9 changes: 3 additions & 6 deletions tests/Test/Pager/PaginatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
namespace Test\Pager;

use Knp\Component\Pager\Event\Subscriber\Paginate\PaginationSubscriber;
use PHPUnit\Framework\Attributes\Test;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Test\Tool\BaseTestCase;

final class PaginatorTest extends BaseTestCase
{
/**
* @test
*/
#[Test]
public function shouldNotBeAbleToPaginateWithoutListeners(): void
{
$this->expectException(\RuntimeException::class);
Expand All @@ -19,9 +18,7 @@ public function shouldNotBeAbleToPaginateWithoutListeners(): void
$paginator->paginate([]);
}

/**
* @test
*/
#[Test]
public function shouldFailToPaginateUnsupportedValue(): void
{
$this->expectException(\RuntimeException::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
use Knp\Component\Pager\Event\Subscriber\Paginate\PaginationSubscriber;
use Knp\Component\Pager\Paginator;
use Knp\Component\Pager\PaginatorInterface;
use PHPUnit\Framework\Attributes\Test;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Test\Fixture\Entity\Article;
use Test\Tool\BaseTestCaseORM;

final class AllowListTest extends BaseTestCaseORM
{
/**
* @test
*/
#[Test]
public function shouldAllowListFiltrationFields(): void
{
$this->expectException(\UnexpectedValueException::class);
Expand Down Expand Up @@ -43,9 +42,7 @@ public function shouldAllowListFiltrationFields(): void
$p->paginate($query, 1, 10, \compact(PaginatorInterface::FILTER_FIELD_ALLOW_LIST));
}

/**
* @test
*/
#[Test]
public function shouldFilterWithoutSpecificAllowList(): void
{
$this->populate();
Expand All @@ -63,9 +60,7 @@ public function shouldFilterWithoutSpecificAllowList(): void
self::assertEquals('autumn', $items[0]->getTitle());
}

/**
* @test
*/
#[Test]
public function shouldFilterWithoutSpecificAllowList2(): void
{
$this->populate();
Expand Down
Loading

0 comments on commit 7b63a73

Please sign in to comment.