Skip to content

Commit

Permalink
Merge pull request #69 from samsonasik/update-to-latest-phpunit-10
Browse files Browse the repository at this point in the history
Update to use PHPUnit 10 syntax
  • Loading branch information
gsteel authored Nov 5, 2024
2 parents f313c82 + 8af33ba commit 83f8dad
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 124 deletions.
3 changes: 3 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@
<MixedAssignment>
<code><![CDATA[$plugin]]></code>
</MixedAssignment>
<PossiblyUnusedMethod>
<code><![CDATA[pluginProvider]]></code>
</PossiblyUnusedMethod>
</file>
<file src="test/PaginatorTest.php">
<ArgumentTypeCoercion>
Expand Down
10 changes: 3 additions & 7 deletions test/Adapter/ArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@

use Laminas\Paginator\Adapter;
use Laminas\Paginator\Adapter\ArrayAdapter;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;

use function assert;
use function range;

/**
* @group Laminas_Paginator
* @covers Laminas\Paginator\Adapter\ArrayAdapter<extended>
*/
#[Group('Laminas_Paginator')]
class ArrayTest extends TestCase
{
private ?ArrayAdapter $adapter;
Expand Down Expand Up @@ -64,9 +62,7 @@ public function testReturnsCorrectCount(): void
$this->assertEquals(101, $this->adapter->count());
}

/**
* @group Laminas-4151
*/
#[Group('Laminas-4151')]
public function testEmptySet(): void
{
$this->adapter = new Adapter\ArrayAdapter([]);
Expand Down
9 changes: 4 additions & 5 deletions test/Adapter/DbSelectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Laminas\Db\Sql\Sql;
use Laminas\Paginator\Adapter\DbSelect;
use Laminas\Paginator\Adapter\Exception\MissingRowCountColumnException;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use PHPUnit_Framework_MockObject_MockObject;

Expand Down Expand Up @@ -62,7 +63,7 @@ public function setUp(): void
$mockPlatform->expects($this->any())->method('getName')->will($this->returnValue('platform'));

$this->mockSql = $this->getMockBuilder(Sql::class)
->setMethods(['prepareStatementForSqlObject', 'execute'])
->onlyMethods(['prepareStatementForSqlObject', 'execute'])
->setConstructorArgs(
[
$this->getMockForAbstractClass(
Expand Down Expand Up @@ -137,10 +138,8 @@ public function testCustomCount(): void
$this->assertEquals(7, $count);
}

/**
* @group 6817
* @group 6812
*/
#[Group('6817')]
#[Group('6812')]
public function testReturnValueIsArray(): void
{
$this->assertIsArray($this->dbSelect->getItems(0, 10));
Expand Down
18 changes: 5 additions & 13 deletions test/Adapter/IteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Laminas\Paginator\Paginator;
use Laminas\Paginator\SerializableLimitIterator;
use LimitIterator;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use Traversable;

Expand All @@ -19,10 +20,7 @@
use function serialize;
use function unserialize;

/**
* @group Laminas_Paginator
* @covers Laminas\Paginator\Adapter\Iterator<extended>
*/
#[Group('Laminas_Paginator')]
class IteratorTest extends TestCase
{
private ?Adapter\Iterator $adapter;
Expand Down Expand Up @@ -90,9 +88,7 @@ public function testThrowsExceptionIfNotCountable(): void
new Adapter\Iterator($iterator);
}

/**
* @group Laminas-4151
*/
#[Group('Laminas-4151')]
public function testDoesNotThrowOutOfBoundsExceptionIfIteratorIsEmpty(): void
{
$paginator = new Paginator(new Adapter\Iterator(new ArrayIterator([])));
Expand All @@ -103,9 +99,7 @@ public function testDoesNotThrowOutOfBoundsExceptionIfIteratorIsEmpty(): void
self::assertSame([], $items);
}

/**
* @group Laminas-8084
*/
#[Group('Laminas-8084')]
public function testGetItemsSerializable(): void
{
assert($this->adapter instanceof Adapter\Iterator);
Expand All @@ -121,9 +115,7 @@ public function testGetItemsSerializable(): void
);
}

/**
* @group Laminas-4151
*/
#[Group('Laminas-4151')]
public function testEmptySet(): void
{
$iterator = new ArrayIterator([]);
Expand Down
14 changes: 4 additions & 10 deletions test/Adapter/NullFillTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@

use Laminas\Paginator;
use Laminas\Paginator\Adapter;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;

use function array_fill;
use function assert;

/**
* @group Laminas_Paginator
* @covers Laminas\Paginator\Adapter\NullFill<extended>
*/
#[Group('Laminas_Paginator')]
class NullFillTest extends TestCase
{
private ?Adapter\NullFill $adapter;
Expand Down Expand Up @@ -52,9 +50,7 @@ public function testReturnsCorrectCount(): void
$this->assertEquals(101, $this->adapter->count());
}

/**
* @group Laminas-3873
*/
#[Group('Laminas-3873')]
public function testAdapterReturnsCorrectValues(): void
{
$paginator = new Paginator\Paginator(new Adapter\NullFill(2));
Expand All @@ -76,9 +72,7 @@ public function testAdapterReturnsCorrectValues(): void
$this->assertEquals(19, $pages->lastItemNumber);
}

/**
* @group Laminas-4151
*/
#[Group('Laminas-4151')]
public function testEmptySet(): void
{
$this->adapter = new Adapter\NullFill(0);
Expand Down
9 changes: 3 additions & 6 deletions test/AdapterPluginManagerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Laminas\Paginator\AdapterPluginManager;
use Laminas\Paginator\AdapterPluginManagerFactory;
use Laminas\ServiceManager\ServiceLocatorInterface;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;
Expand All @@ -32,9 +33,7 @@ public function testFactoryReturnsPluginManager(): void
$this->assertInstanceOf(AdapterPluginManager::class, $adapters);
}

/**
* @depends testFactoryReturnsPluginManager
*/
#[Depends('testFactoryReturnsPluginManager')]
public function testFactoryConfiguresPluginManagerUnderContainerInterop(): void
{
$container = $this->createMock(ContainerInterface::class);
Expand All @@ -58,9 +57,7 @@ public function testFactoryConfiguresPluginManagerUnderContainerInterop(): void
$this->assertSame($adapter, $adapters->get('test'));
}

/**
* @depends testFactoryReturnsPluginManager
*/
#[Depends('testFactoryReturnsPluginManager')]
public function testFactoryConfiguresPluginManagerUnderServiceManagerV2(): void
{
$container = $this->createMock(ServiceLocatorInterface::class);
Expand Down
8 changes: 4 additions & 4 deletions test/AdapterPluginManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
use ArrayIterator;
use Laminas\Paginator\Adapter;
use Laminas\Paginator\AdapterPluginManager;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Psr\Container\ContainerInterface;

use function range;

/**
* @covers \Laminas\Paginator\AdapterPluginManager
*/
#[CoversClass(AdapterPluginManager::class)]
class AdapterPluginManagerTest extends TestCase
{
/** @var AdapterPluginManager */
Expand Down Expand Up @@ -48,9 +48,9 @@ public static function pluginProvider(): iterable
}

/**
* @dataProvider pluginProvider
* @psalm-param class-string $expectedType
*/
#[DataProvider('pluginProvider')]
public function testCanRetrieveAdapterPlugin(string $pluginName, array $options, string $expectedType): void
{
$plugin = $this->adapterPluginManager->get($pluginName, $options);
Expand Down
6 changes: 2 additions & 4 deletions test/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
use Laminas\Paginator\Adapter\Iterator;
use Laminas\Paginator\Exception\InvalidArgumentException;
use LaminasTest\Paginator\TestAsset\TestArrayAggregate;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;

use function count;
use function sprintf;

/**
* @group Laminas_Paginator
* @covers Laminas\Paginator\Factory<extended>
*/
#[Group('Laminas_Paginator')]
class FactoryTest extends TestCase
{
public function testCanFactoryPaginatorWithStringAdapterObject(): void
Expand Down
Loading

0 comments on commit 83f8dad

Please sign in to comment.