diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index f5b4894..5d9e959 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -161,6 +161,7 @@ jobs: MONOLITHIC_DATABASE_URL: mysql://root:${{ secrets.CI_DATABASE_PASSWORD }}@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/monolithic_db ELASTICSEARCH_URL: http://localhost:9200 OPENSEARCH_URL: http://localhost:9201 + DYNAMODB_URL: http://localhost:4566 DATABASE_SERVER_VERSION: ${{ matrix.mysql-version }} run: | vendor/bin/phpunit --colors=always --testdox \ @@ -194,7 +195,7 @@ jobs: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' tests-junit.xml - name: SonarCloud Scan - uses: SonarSource/sonarqube-scan-action@v6.0.0 + uses: SonarSource/sonarqube-scan-action@v7.0.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.gitignore b/.gitignore index aa2f6aa..4782f3f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ composer.lock tests/.results/ tests/App/.env.local tests/App/.env.test +tests/App/config/reference.php tests/App/var/ vendor/ phpunit.log diff --git a/composer.json b/composer.json index e1c9c19..b7ad44b 100644 --- a/composer.json +++ b/composer.json @@ -22,35 +22,35 @@ "php": ">=8.3", "ext-filter": "*", "kununu/collections": "^6.4", - "kununu/data-fixtures": "^13.1", - "symfony/config": "^6.4", - "symfony/dependency-injection": "^6.4", - "symfony/framework-bundle": "^6.4", - "symfony/http-kernel": "^6.4" + "kununu/data-fixtures": "^14.0", + "symfony/config": "^6.4 || ^7.4", + "symfony/dependency-injection": "^6.4 || ^7.4", + "symfony/framework-bundle": "^6.4 || ^7.4", + "symfony/http-kernel": "^6.4 || ^7.4" }, "require-dev": { "ext-json": "*", "ext-pdo": "*", "aws/aws-sdk-php": "^3.173", - "doctrine/dbal": "^3.8", + "doctrine/dbal": "^3.10 || ^4.4", "doctrine/doctrine-bundle": "~2.15.0", - "doctrine/doctrine-migrations-bundle": "^3.3", - "doctrine/orm": "^3.0", + "doctrine/doctrine-migrations-bundle": "^3.7", + "doctrine/orm": "^3.6", "elasticsearch/elasticsearch": "^7.10", "kununu/code-tools": "^3.1", - "matthiasnoback/symfony-dependency-injection-test": "^6.1", + "matthiasnoback/symfony-dependency-injection-test": "^6.2", "nyholm/psr7": "^1.8", - "opensearch-project/opensearch-php": "^2.0", + "opensearch-project/opensearch-php": "^2.5", "phpstan/phpstan": "^2.1", "phpstan/phpstan-phpunit": "^2.0", - "phpunit/phpunit": "^12.3", + "phpunit/phpunit": "^12.5", "psr/cache": "^2.0", - "rector/rector": "^2.0", + "rector/rector": "^2.3", "shipmonk/composer-dependency-analyser": "^1.8", - "symfony/browser-kit": "^6.4", - "symfony/dotenv": "^6.4", - "symfony/http-client": "^6.4", - "symfony/http-foundation": "^6.4" + "symfony/browser-kit": "^6.4 || ^7.4", + "symfony/dotenv": "^6.4 || ^7.4", + "symfony/http-client": "^6.4 || ^7.4", + "symfony/http-foundation": "^6.4 || ^7.4" }, "suggest": { "ext-pdo_mysql": "To run Integration Tests.", @@ -97,6 +97,7 @@ ], "phpstan": "phpstan", "rector": "rector process --dry-run --config rector-ci.php src/ tests/", + "rector-fix": "rector process --config rector-ci.php src/ tests/", "test": [ "rm -rf tests/App/var/*", "tests/App/bin/setup_databases.sh test", @@ -116,6 +117,7 @@ "integration-coverage": "Run all integration tests with coverage report", "phpstan": "Run PHPStan", "rector": "Run Rector in dry-run mode with CI rules", + "rector-fix": "Run Rector in fix mode with CI rules", "test": "Run all tests", "test-coverage": "Run all tests with coverage report", "unit": "Run all unit tests", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 839d18f..29bf314 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,10 +1,11 @@ - + diff --git a/src/DependencyInjection/Compiler/HttpClientCompilerPass.php b/src/DependencyInjection/Compiler/HttpClientCompilerPass.php index 67172e3..d181686 100644 --- a/src/DependencyInjection/Compiler/HttpClientCompilerPass.php +++ b/src/DependencyInjection/Compiler/HttpClientCompilerPass.php @@ -50,7 +50,7 @@ private function buildOrchestrator(ContainerBuilder $container, string $id): voi // Orchestrator definition for HttpClient with provided id orchestratorId: sprintf('%s.%s', self::SERVICE_PREFIX, $id), // Purger Definition for HttpClient with provided id - purgerDefinitionBuilder: fn(ContainerBuilder $container, string $baseId): array => [ + purgerDefinitionBuilder: static fn(ContainerBuilder $container, string $baseId): array => [ sprintf('%s.%s.purger', self::SERVICE_PREFIX, $baseId), new Definition( HttpClientPurger::class, @@ -60,7 +60,7 @@ private function buildOrchestrator(ContainerBuilder $container, string $id): voi ), ], // Executor Definition for HttpClient with provided id - executorDefinitionBuilder: fn(ContainerBuilder $container, string $baseId, string $purgerId): array => [ + executorDefinitionBuilder: static fn(ContainerBuilder $container, string $baseId, string $purgerId): array => [ sprintf('%s.%s.executor', self::SERVICE_PREFIX, $baseId), new Definition( HttpClientExecutor::class, diff --git a/src/Service/SchemaCopy/Copier/SchemaCopier.php b/src/Service/SchemaCopy/Copier/SchemaCopier.php index a7f7a02..b0c3219 100644 --- a/src/Service/SchemaCopy/Copier/SchemaCopier.php +++ b/src/Service/SchemaCopy/Copier/SchemaCopier.php @@ -24,7 +24,7 @@ public function copy(Connection $source, Connection $destination): void } $destinationAdapter->runCopy( - function() use ($sourceAdapter, $destinationAdapter, $destination): void { + static function() use ($sourceAdapter, $destinationAdapter, $destination): void { $destinationAdapter->purgeTablesAndViews(); foreach ($sourceAdapter->getTables() as $table) { diff --git a/tests/App/.env b/tests/App/.env index d633c9b..bcab5de 100644 --- a/tests/App/.env +++ b/tests/App/.env @@ -3,4 +3,5 @@ PERSISTENCE_DATABASE_URL="mysql://root:symfony@127.0.0.1:3306/persistence_db" MONOLITHIC_DATABASE_URL="mysql://root:symfony@127.0.0.1:3306/monolithic_db" ELASTICSEARCH_URL="http://127.0.0.1:9200" OPENSEARCH_URL="http://127.0.0.1:9200" +DYNAMODB_URL="http://127.0.0.1:4566" DATABASE_SERVER_VERSION=5.7.42 diff --git a/tests/App/config/packages/parameters.yaml b/tests/App/config/packages/parameters.yaml index 7991930..e29d795 100644 --- a/tests/App/config/packages/parameters.yaml +++ b/tests/App/config/packages/parameters.yaml @@ -5,4 +5,5 @@ parameters: def_database_url: '%env(resolve:DEF_DATABASE_URL)%' persistence_database_url: '%env(resolve:PERSISTENCE_DATABASE_URL)%' monolithic_database_url: '%env(resolve:MONOLITHIC_DATABASE_URL)%' + dynamodb_url: '%env(resolve:DYNAMODB_URL)%' dummy_param: 'i am a parameter' diff --git a/tests/App/config/services.yaml b/tests/App/config/services.yaml index 67234b6..1203ace 100644 --- a/tests/App/config/services.yaml +++ b/tests/App/config/services.yaml @@ -36,7 +36,7 @@ services: - version: 'latest' region: 'eu-west-1' - endpoint: 'http://localhost:4566' + endpoint: '%dynamodb_url%' credentials: key: 'test' secret: 'test' diff --git a/tests/Unit/DependencyInjection/Compiler/BaseCompilerPassTestCase.php b/tests/Unit/DependencyInjection/Compiler/BaseCompilerPassTestCase.php index 13e80dd..0fd63a7 100644 --- a/tests/Unit/DependencyInjection/Compiler/BaseCompilerPassTestCase.php +++ b/tests/Unit/DependencyInjection/Compiler/BaseCompilerPassTestCase.php @@ -100,12 +100,12 @@ protected function getMockKununuTestingExtension(string $alias = KununuTestingEx $mock = $this->createMock(ExtensionInterface::class); $mock - ->expects($this->any()) + ->expects($this->atLeastOnce()) ->method('getAlias') ->willReturn($alias); $mock - ->expects($this->any()) + ->expects($this->atLeastOnce()) ->method('getNamespace') ->willReturn(false); diff --git a/tests/Unit/DependencyInjection/Compiler/CachePoolCompilerPassTest.php b/tests/Unit/DependencyInjection/Compiler/CachePoolCompilerPassTest.php index 5b16859..f91c8f0 100644 --- a/tests/Unit/DependencyInjection/Compiler/CachePoolCompilerPassTest.php +++ b/tests/Unit/DependencyInjection/Compiler/CachePoolCompilerPassTest.php @@ -9,14 +9,16 @@ use Kununu\TestingBundle\Command\LoadCacheFixturesCommand; use Kununu\TestingBundle\DependencyInjection\Compiler\CachePoolCompilerPass; use Kununu\TestingBundle\DependencyInjection\KununuTestingExtension; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; +#[AllowMockObjectsWithoutExpectations] final class CachePoolCompilerPassTest extends BaseLoadFixturesCommandCompilerPassTestCase { private const array CACHE_POOL_IDS = [ - 'cache_pool.service_1' => [ + 'cache_pool.service_1' => [ 'creates_command' => true, ], 'cache_pool.service_2' => [], diff --git a/tests/Unit/DependencyInjection/Compiler/ConnectionCompilerPassTest.php b/tests/Unit/DependencyInjection/Compiler/ConnectionCompilerPassTest.php index 19102fd..40f8aa6 100644 --- a/tests/Unit/DependencyInjection/Compiler/ConnectionCompilerPassTest.php +++ b/tests/Unit/DependencyInjection/Compiler/ConnectionCompilerPassTest.php @@ -8,7 +8,9 @@ use Kununu\TestingBundle\Command\LoadConnectionFixturesCommand; use Kununu\TestingBundle\DependencyInjection\Compiler\AbstractConnectionCompilerPass; use Kununu\TestingBundle\DependencyInjection\Compiler\ConnectionCompilerPass; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; +#[AllowMockObjectsWithoutExpectations] final class ConnectionCompilerPassTest extends BaseConnectionCompilerPassTestCase { protected function getCompilerInstance(): AbstractConnectionCompilerPass diff --git a/tests/Unit/DependencyInjection/Compiler/CopyConnectionSchemaCommandCompilerPassTest.php b/tests/Unit/DependencyInjection/Compiler/CopyConnectionSchemaCommandCompilerPassTest.php index 32d486c..e300e3a 100644 --- a/tests/Unit/DependencyInjection/Compiler/CopyConnectionSchemaCommandCompilerPassTest.php +++ b/tests/Unit/DependencyInjection/Compiler/CopyConnectionSchemaCommandCompilerPassTest.php @@ -5,8 +5,10 @@ use Kununu\TestingBundle\Command\CopyConnectionSchemaCommand; use Kununu\TestingBundle\DependencyInjection\Compiler\CopyConnectionSchemaCommandCompilerPass; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use Symfony\Component\DependencyInjection\ContainerBuilder; +#[AllowMockObjectsWithoutExpectations] final class CopyConnectionSchemaCommandCompilerPassTest extends BaseCompilerPassTestCase { private const string COMMAND_ID = 'kununu_testing:connections:schema:copy.command'; diff --git a/tests/Unit/DependencyInjection/Compiler/DynamoDbCompilerPassTest.php b/tests/Unit/DependencyInjection/Compiler/DynamoDbCompilerPassTest.php index c120774..a71cb43 100644 --- a/tests/Unit/DependencyInjection/Compiler/DynamoDbCompilerPassTest.php +++ b/tests/Unit/DependencyInjection/Compiler/DynamoDbCompilerPassTest.php @@ -9,10 +9,12 @@ use Kununu\TestingBundle\Command\LoadDynamoDbFixturesCommand; use Kununu\TestingBundle\DependencyInjection\Compiler\DynamoDbCompilerPass; use Kununu\TestingBundle\DependencyInjection\KununuTestingExtension; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; +#[AllowMockObjectsWithoutExpectations] final class DynamoDbCompilerPassTest extends BaseLoadFixturesCommandCompilerPassTestCase { private const array DYNAMO_DB_SERVICES = [ diff --git a/tests/Unit/DependencyInjection/Compiler/ElasticsearchCompilerPassTest.php b/tests/Unit/DependencyInjection/Compiler/ElasticsearchCompilerPassTest.php index c862dc3..ca23ec2 100644 --- a/tests/Unit/DependencyInjection/Compiler/ElasticsearchCompilerPassTest.php +++ b/tests/Unit/DependencyInjection/Compiler/ElasticsearchCompilerPassTest.php @@ -9,7 +9,9 @@ use Kununu\TestingBundle\Command\LoadElasticsearchFixturesCommand; use Kununu\TestingBundle\DependencyInjection\Compiler\AbstractSearchEngineCompilerPass; use Kununu\TestingBundle\DependencyInjection\Compiler\ElasticsearchCompilerPass; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; +#[AllowMockObjectsWithoutExpectations] final class ElasticsearchCompilerPassTest extends BaseSearchEngineCompilerPassTestCase { protected function getCompilerInstance(): AbstractSearchEngineCompilerPass diff --git a/tests/Unit/DependencyInjection/Compiler/HttpClientCompilerPassTest.php b/tests/Unit/DependencyInjection/Compiler/HttpClientCompilerPassTest.php index dcebea2..0f59017 100644 --- a/tests/Unit/DependencyInjection/Compiler/HttpClientCompilerPassTest.php +++ b/tests/Unit/DependencyInjection/Compiler/HttpClientCompilerPassTest.php @@ -8,9 +8,11 @@ use Kununu\DataFixtures\Purger\HttpClientPurger; use Kununu\TestingBundle\DependencyInjection\Compiler\HttpClientCompilerPass; use Kununu\TestingBundle\DependencyInjection\KununuTestingExtension; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; +#[AllowMockObjectsWithoutExpectations] final class HttpClientCompilerPassTest extends BaseCompilerPassTestCase { private const array HTTP_CLIENT_IDS = [ diff --git a/tests/Unit/DependencyInjection/Compiler/NonTransactionalConnectionCompilerPassTest.php b/tests/Unit/DependencyInjection/Compiler/NonTransactionalConnectionCompilerPassTest.php index dcb3df2..3e00958 100644 --- a/tests/Unit/DependencyInjection/Compiler/NonTransactionalConnectionCompilerPassTest.php +++ b/tests/Unit/DependencyInjection/Compiler/NonTransactionalConnectionCompilerPassTest.php @@ -8,7 +8,9 @@ use Kununu\TestingBundle\Command\LoadNonTransactionalConnectionFixturesCommand; use Kununu\TestingBundle\DependencyInjection\Compiler\AbstractConnectionCompilerPass; use Kununu\TestingBundle\DependencyInjection\Compiler\NonTransactionalConnectionCompilerPass; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; +#[AllowMockObjectsWithoutExpectations] final class NonTransactionalConnectionCompilerPassTest extends BaseConnectionCompilerPassTestCase { protected function getCompilerInstance(): AbstractConnectionCompilerPass diff --git a/tests/Unit/DependencyInjection/Compiler/OpenSearchCompilerPassTest.php b/tests/Unit/DependencyInjection/Compiler/OpenSearchCompilerPassTest.php index 0fdc6d6..2b01db3 100644 --- a/tests/Unit/DependencyInjection/Compiler/OpenSearchCompilerPassTest.php +++ b/tests/Unit/DependencyInjection/Compiler/OpenSearchCompilerPassTest.php @@ -9,7 +9,9 @@ use Kununu\TestingBundle\Command\LoadOpenSearchFixturesCommand; use Kununu\TestingBundle\DependencyInjection\Compiler\AbstractSearchEngineCompilerPass; use Kununu\TestingBundle\DependencyInjection\Compiler\OpenSearchCompilerPass; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; +#[AllowMockObjectsWithoutExpectations] final class OpenSearchCompilerPassTest extends BaseSearchEngineCompilerPassTestCase { protected function getCompilerInstance(): AbstractSearchEngineCompilerPass diff --git a/tests/Unit/KununuTestingBundleTest.php b/tests/Unit/KununuTestingBundleTest.php index d3fbb3e..7f26250 100644 --- a/tests/Unit/KununuTestingBundleTest.php +++ b/tests/Unit/KununuTestingBundleTest.php @@ -13,10 +13,10 @@ use Kununu\TestingBundle\DependencyInjection\Compiler\OpenSearchCompilerPass; use Kununu\TestingBundle\KununuTestingBundle; use PHPUnit\Framework\MockObject\MockObject; -use PHPUnit\Framework\TestCase; +use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; -final class KununuTestingBundleTest extends TestCase +final class KununuTestingBundleTest extends KernelTestCase { public function testBuildContainerExpectedCompilerPasses(): void { @@ -27,7 +27,7 @@ public function testBuildContainerExpectedCompilerPasses(): void ->expects($this->exactly(8)) ->method('addCompilerPass') ->willReturnCallback( - function($subject) use ($container, &$executedCompilerPasses): MockObject&ContainerBuilder { + static function($subject) use ($container, &$executedCompilerPasses): MockObject&ContainerBuilder { $executedCompilerPasses[] = $subject::class; return $container; diff --git a/tests/Unit/Service/OrchestratorTest.php b/tests/Unit/Service/OrchestratorTest.php index 7010d58..e19b819 100644 --- a/tests/Unit/Service/OrchestratorTest.php +++ b/tests/Unit/Service/OrchestratorTest.php @@ -8,10 +8,12 @@ use Kununu\DataFixtures\FixtureInterface; use Kununu\DataFixtures\Loader\LoaderInterface; use Kununu\TestingBundle\Service\Orchestrator; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +#[AllowMockObjectsWithoutExpectations] final class OrchestratorTest extends TestCase { #[DataProvider('executesAsExpectedDataProvider')] @@ -25,7 +27,7 @@ public function testThatExecutesAsExpected(bool $append): void ->expects($this->exactly(2)) ->method('loadFromClassName') ->with( - $this->callback(fn(string $class): bool => match ($class) { + $this->callback(static fn(string $class): bool => match ($class) { $fixture1Class, $fixture2Class => true, default => false, }) diff --git a/tests/Unit/Service/SchemaCopy/Adapter/MySqlAdapterTest.php b/tests/Unit/Service/SchemaCopy/Adapter/MySqlAdapterTest.php index af75cdf..2aa8c7d 100644 --- a/tests/Unit/Service/SchemaCopy/Adapter/MySqlAdapterTest.php +++ b/tests/Unit/Service/SchemaCopy/Adapter/MySqlAdapterTest.php @@ -7,8 +7,10 @@ use Kununu\TestingBundle\Service\SchemaCopy\Adapter\MySqlAdapter; use Kununu\TestingBundle\Service\SchemaCopy\SchemaCopyAdapterInterface; use Kununu\TestingBundle\Tests\Unit\Service\SchemaCopy\SchemaCopyTestCase; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\MockObject\MockObject; +#[AllowMockObjectsWithoutExpectations] final class MySqlAdapterTest extends SchemaCopyTestCase { private MockObject&Connection $connection; @@ -36,7 +38,7 @@ public function testRunCopy(): void $value = false; - $this->adapter->runCopy(function() use (&$value): void { + $this->adapter->runCopy(static function() use (&$value): void { $value = true; }); diff --git a/tests/Unit/Service/SchemaCopy/Copier/SchemaCopierTest.php b/tests/Unit/Service/SchemaCopy/Copier/SchemaCopierTest.php index 5ab0840..9c5e48a 100644 --- a/tests/Unit/Service/SchemaCopy/Copier/SchemaCopierTest.php +++ b/tests/Unit/Service/SchemaCopy/Copier/SchemaCopierTest.php @@ -12,8 +12,10 @@ use Kununu\TestingBundle\Service\SchemaCopy\SchemaCopyInterface; use Kununu\TestingBundle\Tests\Unit\Service\SchemaCopy\SchemaCopyTestCase; use LogicException; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\MockObject\MockObject; +#[AllowMockObjectsWithoutExpectations] final class SchemaCopierTest extends SchemaCopyTestCase { private MockObject&Connection $source; diff --git a/tests/Unit/Service/SchemaCopy/Factory/AdapterFactoryTest.php b/tests/Unit/Service/SchemaCopy/Factory/AdapterFactoryTest.php index 89c9da3..f6abbc5 100644 --- a/tests/Unit/Service/SchemaCopy/Factory/AdapterFactoryTest.php +++ b/tests/Unit/Service/SchemaCopy/Factory/AdapterFactoryTest.php @@ -5,7 +5,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Platforms\AbstractPlatform; -use Doctrine\DBAL\Platforms\MySQL80Platform; +use Doctrine\DBAL\Platforms\MySQLPlatform; use Kununu\TestingBundle\Service\SchemaCopy\Exception\UnsupportedDatabasePlatformException; use Kununu\TestingBundle\Service\SchemaCopy\Factory\AdapterFactory; use PHPUnit\Framework\Attributes\DataProvider; @@ -18,9 +18,9 @@ public function testCreateAdapter(string $platformClass, ?string $expectedType): { $connection = $this->createMock(Connection::class); $connection - ->expects($this->any()) + ->expects($this->atLeastOnce()) ->method('getDatabasePlatform') - ->willReturn($this->createMock($platformClass)); + ->willReturn($this->createStub($platformClass)); if (null === $expectedType) { $this->expectException(UnsupportedDatabasePlatformException::class); @@ -37,7 +37,7 @@ public static function createAdapterDataProvider(): array { return [ 'mysql' => [ - MySQL80Platform::class, + MySQLPlatform::class, 'MySql', ], 'invalid' => [ diff --git a/tests/Unit/Service/SchemaCopy/SchemaCopyTestCase.php b/tests/Unit/Service/SchemaCopy/SchemaCopyTestCase.php index 9875621..7ca637b 100644 --- a/tests/Unit/Service/SchemaCopy/SchemaCopyTestCase.php +++ b/tests/Unit/Service/SchemaCopy/SchemaCopyTestCase.php @@ -4,7 +4,7 @@ namespace Kununu\TestingBundle\Tests\Unit\Service\SchemaCopy; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Platforms\MySQL80Platform; +use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\DBAL\Result; use Kununu\TestingBundle\Service\SchemaCopy\SchemaCopyAdapterInterface; use LogicException; @@ -30,9 +30,9 @@ protected function createConnection(): MockObject&Connection { $connection = $this->createMock(Connection::class); $connection - ->expects($this->any()) + ->expects($this->atMost(1)) ->method('getDatabasePlatform') - ->willReturn($this->createMock(MySQL80Platform::class)); + ->willReturn($this->createStub(MySQLPlatform::class)); return $connection; } @@ -44,7 +44,7 @@ protected function mockExecuteQuery(MockObject&Connection $connection, array $re $connection ->expects($this->exactly(count($statements))) ->method('executeQuery') - ->willReturnCallback(fn(string $statement): Result => match (true) { + ->willReturnCallback(static fn(string $statement): Result => match (true) { isset($map[$statement]) => $map[$statement], default => throw new LogicException(sprintf('Statement "%s" not found', $statement)), }); @@ -57,7 +57,7 @@ protected function mockExecuteStatement(MockObject&Connection $connection, strin $connection ->expects($this->exactly(count($statements))) ->method('executeStatement') - ->willReturnCallback(fn(string $statement): int => match (true) { + ->willReturnCallback(static fn(string $statement): int => match (true) { isset($map[$statement]) => $map[$statement], default => throw new LogicException(sprintf('Statement "%s" not found', $statement)), }); diff --git a/tests/Unit/Test/RequestBuilderTest.php b/tests/Unit/Test/RequestBuilderTest.php index ddaa9b5..1b63657 100644 --- a/tests/Unit/Test/RequestBuilderTest.php +++ b/tests/Unit/Test/RequestBuilderTest.php @@ -233,11 +233,11 @@ public function testBuildRequestWithUri(): void public function testBuildRequestWithFiles(): void { - $request = RequestBuilder::aGetRequest()->withFiles([self::createMock(UploadedFile::class)]); + $request = RequestBuilder::aGetRequest()->withFiles([$file = self::createStub(UploadedFile::class)]); [, , , $files] = $request->build(); - self::assertEquals([self::createMock(UploadedFile::class)], $files); + self::assertEquals([$file], $files); } public function testBuildRequestWithContent(): void diff --git a/tests/setupLocalTests.sh b/tests/setupLocalTests.sh index 922a6d5..fa1e9e1 100755 --- a/tests/setupLocalTests.sh +++ b/tests/setupLocalTests.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1 -if ! [ -f App/.env.test ]; then +if ! [[ -f App/.env.test ]]; then echo "Could not found local test env configurations!" echo "Copy tests/App/.env to tests/App/.env.test & tests/App/.env.local and setup according your local env." echo "Then run this script again!!"