Skip to content

Commit

Permalink
Fix phpunit deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
SerafimArts committed Aug 1, 2024
1 parent 2754534 commit 3acc377
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 32 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
}
],
"require": {
"php": "^7.4|^8.0",
"php": "^8.1",
"ext-spl": "*",
"phplrt/lexer": "^3.6"
"phplrt/lexer": "^4.0"
},
"autoload": {
"psr-4": {
"Phplrt\\Buffer\\": "src"
}
},
"require-dev": {
"phpunit/phpunit": "^9.6|^10.0",
"phpunit/phpunit": "^10.5|^11.0",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-strict-rules": "^1.6"
Expand All @@ -38,8 +38,8 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.x-dev",
"dev-main": "3.x-dev"
"dev-master": "4.x-dev",
"dev-main": "4.x-dev"
}
},
"config": {
Expand Down
37 changes: 10 additions & 27 deletions tests/Unit/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Phplrt\Buffer\Tests\TestCase as BaseTestCase;
use Phplrt\Contracts\Lexer\TokenInterface;
use Phplrt\Lexer\Token\Token;
use PHPUnit\Framework\Attributes\DataProvider;

abstract class TestCase extends BaseTestCase
{
Expand Down Expand Up @@ -46,9 +47,7 @@ private static function createTokens(int $count): \Generator
}
}

/**
* @dataProvider buffersDataProvider
*/
#[DataProvider('buffersDataProvider')]
public function testIsIterable(BufferInterface $buffer): void
{
foreach ($buffer as $index => $token) {
Expand All @@ -57,39 +56,31 @@ public function testIsIterable(BufferInterface $buffer): void
}
}

/**
* @dataProvider buffersDataProvider
*/
#[DataProvider('buffersDataProvider')]
public function testKeysDoNotIntersect(BufferInterface $buffer): void
{
$buffer = \iterator_to_array($buffer, true);

$this->assertCount(10, $buffer);
}

/**
* @dataProvider buffersDataProvider
*/
#[DataProvider('buffersDataProvider')]
public function testCurrentSameWithIteratorState(BufferInterface $buffer): void
{
foreach ($buffer as $token) {
$this->assertSame($token, $buffer->current());
}
}

/**
* @dataProvider buffersDataProvider
*/
#[DataProvider('buffersDataProvider')]
public function testKeySameWithIteratorState(BufferInterface $buffer): void
{
foreach ($buffer as $index => $token) {
$this->assertSame($index, $buffer->key());
}
}

/**
* @dataProvider buffersDataProvider
*/
#[DataProvider('buffersDataProvider')]
public function testRewindable(BufferInterface $buffer): void
{
$needle = $buffer->current();
Expand All @@ -102,9 +93,7 @@ public function testRewindable(BufferInterface $buffer): void
$this->assertSame($needle, $buffer->current());
}

/**
* @dataProvider buffersDataProvider
*/
#[DataProvider('buffersDataProvider')]
public function testSeekAhead(BufferInterface $buffer): void
{
$buffer->seek(static::$bufferSize - 1);
Expand All @@ -118,27 +107,21 @@ public function testSeekAhead(BufferInterface $buffer): void
$this->assertSame($buffer->current(), $needle);
}

/**
* @dataProvider buffersDataProvider
*/
#[DataProvider('buffersDataProvider')]
public function testSeekOverflow(BufferInterface $buffer): void
{
$this->expectException(\OutOfRangeException::class);
$buffer->seek(static::$bufferSize + 1000);
}

/**
* @dataProvider buffersDataProvider
*/
#[DataProvider('buffersDataProvider')]
public function testSeekUnderflow(BufferInterface $buffer): void
{
$this->expectException(\OutOfRangeException::class);
$buffer->seek(static::$bufferSize + 1000);
}

/**
* @dataProvider buffersDataProvider
*/
#[DataProvider('buffersDataProvider')]
public function testSeekable(BufferInterface $buffer): void
{
$needle = [];
Expand Down

0 comments on commit 3acc377

Please sign in to comment.