Skip to content
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
3 changes: 2 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
34 changes: 18 additions & 16 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://docs.phpunit.de/en/12.3/ -->
<!-- https://docs.phpunit.de/en/12.5/ -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd"
bootstrap="tests/bootstrap.php"
colors="true"
beStrictAboutChangesToGlobalState="true"
displayDetailsOnAllIssues="true"
testdoxSummary="true"
testdox="true"
cacheDirectory=".phpunit.cache">
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/Compiler/HttpClientCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/Service/SchemaCopy/Copier/SchemaCopier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions tests/App/.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions tests/App/config/packages/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
2 changes: 1 addition & 1 deletion tests/App/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ services:
-
version: 'latest'
region: 'eu-west-1'
endpoint: 'http://localhost:4566'
endpoint: '%dynamodb_url%'
credentials:
key: 'test'
secret: 'test'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/KununuTestingBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion tests/Unit/Service/OrchestratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
Expand All @@ -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,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
});

Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/Service/SchemaCopy/Copier/SchemaCopierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -37,7 +37,7 @@ public static function createAdapterDataProvider(): array
{
return [
'mysql' => [
MySQL80Platform::class,
MySQLPlatform::class,
'MySql',
],
'invalid' => [
Expand Down
Loading