Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Internal] support of phpunit 10, drop support for phpunit 8 #205

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ jobs:
php bin/console messenger:setup-transports --no-interaction
php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration -q
php bin/console doctrine:fixtures:load --no-interaction
vendor/bin/phpunit --testdox -v --no-coverage
vendor/bin/phpunit --testdox --no-coverage
echo "::endgroup::"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ composer-normalize
###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
.phpunit.cache
###< phpunit/phpunit ###

###> friendsofphp/php-cs-fixer ###
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"jms/serializer": "^3.11",
"jms/serializer-bundle": "^4.2",
"phpdocumentor/reflection-docblock": "^5.2",
"phpunit/phpunit": "^8.0 || ^9.0",
"phpunit/phpunit": "^9.0 || ^10.0",
"psr/http-message": "^1.0",
"psr/log": "@stable",
"ramsey/uuid": "^4.2",
Expand Down
874 changes: 412 additions & 462 deletions composer.lock

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions packages/application/Tests/Command/CronDumpToFileCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@
use Draw\Component\Application\Cron\CronManager;
use Draw\Component\Tester\Application\CommandDataTester;
use Draw\Component\Tester\Application\CommandTestTrait;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

/**
* @covers \Draw\Component\Application\Cron\Command\CronDumpToFileCommand
*/
#[CoversClass(CronDumpToFileCommand::class)]
class CronDumpToFileCommandTest extends TestCase
{
use CommandTestTrait;

/**
* @var CronManager&MockObject
*/
private CronManager $cronManager;
private CronManager&MockObject $cronManager;

public function createCommand(): Command
{
Expand All @@ -36,12 +32,12 @@ public function getCommandName(): string
return 'draw:cron:dump-to-file';
}

public function provideTestArgument(): iterable
public static function provideTestArgument(): iterable
{
yield ['filePath', InputArgument::REQUIRED];
}

public function provideTestOption(): iterable
public static function provideTestOption(): iterable
{
yield ['override', null, InputOption::VALUE_NONE];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
use Draw\Component\Tester\DoctrineOrmTrait;
use Draw\Contracts\Application\ConfigurationRegistryInterface;
use Draw\Contracts\Application\Exception\ConfigurationIsNotAccessibleException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;

/**
* @covers \Draw\Component\Application\Configuration\DoctrineConfigurationRegistry
*/
#[CoversClass(DoctrineConfigurationRegistry::class)]
class DoctrineConfigurationRegistryTest extends TestCase
{
use DoctrineOrmTrait;
Expand Down Expand Up @@ -119,9 +120,7 @@ public function testHasNotSet(): void
static::assertFalse($this->object->has('value'));
}

/**
* @depends testHasNotSet
*/
#[Depends('testHasNotSet')]
public function testGetDefault(): void
{
static::assertNull($this->object->get('value'));
Expand All @@ -136,43 +135,33 @@ public function testSet(): void
$this->addToAssertionCount(1);
}

/**
* @depends testSet
*/
#[Depends('testSet')]
public function testHasSet(): void
{
static::assertTrue($this->object->has('value'));
}

/**
* @depends testHasSet
*/
#[Depends('testHasSet')]
public function testGetSet(): void
{
static::assertSame('the-value', $this->object->get('value'));
}

/**
* @depends testHasSet
*/
#[Depends('testHasSet')]
public function testDelete(): void
{
$this->object->delete('value');

$this->addToAssertionCount(1);
}

/**
* @depends testDelete
*/
#[Depends('testDelete')]
public function testHasAfterDelete(): void
{
static::assertFalse($this->object->has('value'));
}

/**
* @depends testGetSet
*/
#[Depends('testGetSet')]
public function testGetValueChangeFromOtherScope(): void
{
$this->object->set('value', 'the-value');
Expand All @@ -191,9 +180,7 @@ public function testGetValueChangeFromOtherScope(): void
static::assertSame('new-value', $this->object->get('value'));
}

/**
* @depends testGetSet
*/
#[Depends('testGetSet')]
public function testGetValueInvalidState(): void
{
$this->object->set('value', 'the-value');
Expand All @@ -214,7 +201,7 @@ public function testGetValueInvalidState(): void
static::assertSame('new-value', $this->object->get('value'));
}

public function provideTestSetGetKeepType(): iterable
public static function provideTestSetGetKeepType(): iterable
{
yield 'string' => [
'value',
Expand All @@ -237,9 +224,7 @@ public function provideTestSetGetKeepType(): iterable
];
}

/**
* @dataProvider provideTestSetGetKeepType
*/
#[DataProvider('provideTestSetGetKeepType')]
public function testSetGetKeepType(mixed $value): void
{
$this->object->set('value', $value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace Draw\Component\Application\Tests\Configuration\Entity;

use Draw\Component\Application\Configuration\Entity\Config;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \Draw\Component\Application\Configuration\Entity\Config
*/
#[CoversClass(Config::class)]
class ConfigTest extends TestCase
{
private Config $entity;
Expand Down
5 changes: 2 additions & 3 deletions packages/application/Tests/Cron/CronManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

use Draw\Component\Application\Cron\CronManager;
use Draw\Component\Application\Cron\Job;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \Draw\Component\Application\Cron\CronManager
*/
#[CoversClass(CronManager::class)]
class CronManagerTest extends TestCase
{
private CronManager $service;
Expand Down
5 changes: 2 additions & 3 deletions packages/application/Tests/Cron/JobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace Draw\Component\Application\Tests\Cron;

use Draw\Component\Application\Cron\Job;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \Draw\Component\Application\Cron\Job
*/
#[CoversClass(Job::class)]
class JobTest extends TestCase
{
private const DEFAULT_NAME = 'name';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@
use Draw\Component\Application\Versioning\VersionManager;
use Draw\Component\Tester\Application\CommandDataTester;
use Draw\Component\Tester\Application\CommandTestTrait;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Command\Command;

/**
* @covers \Draw\Component\Application\Versioning\Command\UpdateDeployedVersionCommand
*/
#[CoversClass(UpdateDeployedVersionCommand::class)]
class UpdateDeployedVersionCommandTest extends TestCase
{
use CommandTestTrait;

/**
* @var VersionManager&MockObject
*/
private VersionManager $versionManager;
private VersionManager&MockObject $versionManager;

public function createCommand(): Command
{
Expand All @@ -34,12 +30,12 @@ public function getCommandName(): string
return 'draw:application:update-deployed-version';
}

public function provideTestArgument(): iterable
public static function provideTestArgument(): iterable
{
return [];
}

public function provideTestOption(): iterable
public static function provideTestOption(): iterable
{
return [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
namespace Draw\Component\Application\Tests\Versioning\Event;

use Draw\Component\Application\Versioning\Event\FetchRunningVersionEvent;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Contracts\EventDispatcher\Event;

/**
* @covers \Draw\Component\Application\Versioning\Event\FetchRunningVersionEvent
*/
#[CoversClass(FetchRunningVersionEvent::class)]
class FetchRunningVersionEventTest extends TestCase
{
private FetchRunningVersionEvent $event;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
use Draw\Component\Application\Versioning\Event\FetchRunningVersionEvent;
use Draw\Component\Application\Versioning\EventListener\FetchRunningVersionListener;
use Draw\Component\Core\Reflection\ReflectionAccessor;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* @covers \Draw\Component\Application\Versioning\EventListener\FetchRunningVersionListener
*/
#[CoversClass(FetchRunningVersionListener::class)]
class FetchRunningVersionListenerTest extends TestCase
{
private FetchRunningVersionListener $service;
Expand Down
15 changes: 4 additions & 11 deletions packages/application/Tests/Versioning/VersionManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,19 @@
use Draw\Component\Core\Reflection\ReflectionAccessor;
use Draw\Contracts\Application\ConfigurationRegistryInterface;
use Draw\Contracts\Application\VersionVerificationInterface;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

/**
* @covers \Draw\Component\Application\Versioning\VersionManager
*/
#[CoversClass(VersionManager::class)]
class VersionManagerTest extends TestCase
{
private VersionManager $service;

/**
* @var ConfigurationRegistryInterface&MockObject
*/
private ConfigurationRegistryInterface $configurationRegistry;
private ConfigurationRegistryInterface&MockObject $configurationRegistry;

/**
* @var EventDispatcherInterface&MockObject
*/
private EventDispatcherInterface $eventDispatcher;
private MockObject&EventDispatcherInterface $eventDispatcher;

protected function setUp(): void
{
Expand Down
2 changes: 1 addition & 1 deletion packages/application/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"symfony/event-dispatcher": "^5.4.3"
},
"require-dev": {
"phpunit/phpunit": "^8.0 || ^9.0",
"phpunit/phpunit": "^9.0 || ^10.0",
"draw/tester": "^0.10",
"symfony/cache": "^5.4.3",
"symfony/console": "^5.4.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@
use Draw\Component\Core\Reflection\ReflectionAccessor;
use Draw\Component\Tester\Application\CommandDataTester;
use Draw\Component\Tester\Application\CommandTestTrait;
use Draw\Component\Tester\MockTrait;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

/**
* @covers \Draw\Component\AwsToolKit\Command\CloudWatchLogsDownloadCommand
*/
#[CoversClass(CloudWatchLogsDownloadCommand::class)]
class CloudWatchLogsDownloadCommandTest extends TestCase
{
use CommandTestTrait;
use MockTrait;

/**
* @var CloudWatchLogsClient&MockObject
*/
private CloudWatchLogsClient $cloudWatchLogsClient;
private CloudWatchLogsClient&MockObject $cloudWatchLogsClient;

public function createCommand(): Command
{
Expand All @@ -44,14 +42,14 @@ public function getCommandName(): string
return 'draw:aws:cloud-watch-logs:download';
}

public function provideTestArgument(): iterable
public static function provideTestArgument(): iterable
{
yield ['logGroupName', InputArgument::REQUIRED, null];
yield ['logStreamName', InputArgument::REQUIRED, null];
yield ['output', InputArgument::REQUIRED, null];
}

public function provideTestOption(): iterable
public static function provideTestOption(): iterable
{
yield ['startTime', null, InputOption::VALUE_REQUIRED, '- 1 days'];
yield ['endTime', null, InputOption::VALUE_REQUIRED, 'now'];
Expand Down Expand Up @@ -102,9 +100,11 @@ public function testExecuteNewFile(): void
$this->cloudWatchLogsClient
->expects(static::exactly(2))
->method('getLogEvents')
->withConsecutive(
[$logEvents],
[$logEvents + ['nextToken' => 'next-token']]
->with(
...static::withConsecutive(
[$logEvents],
[$logEvents + ['nextToken' => 'next-token']]
)
)
->willReturnOnConsecutiveCalls(
[
Expand Down
Loading
Loading