Skip to content

Commit bf033d5

Browse files
alongoszadamwojsViniToukonradoboza
authored
IBX-8471: Upgraded codebase to Symfony 7 (#66)
* [Composer] Bumped 3rd party packages compatible with for Symfony 7 * IBX-9811: Upgraded metrics queries to doctrine/dbal v3 * IBX-9811: Adapted RepositorySystemInfoCollector to doctrine/dbal v3 * [Tests] Adapted \Ibexa\Tests\Bundle\SystemInfo\SystemInfo\Collector\RepositorySystemInfoCollectorTest::testCollect * [Tests] Updated tests/bundle/SystemInfo/Collector/RepositorySystemInfoCollectorTest.php --------- Co-authored-by: Adam Wójs <[email protected]> Co-authored-by: Dawid Parafiński <[email protected]> Co-authored-by: Konrad Oboza <[email protected]>
1 parent 6a719cf commit bf033d5

File tree

9 files changed

+18
-21
lines changed

9 files changed

+18
-21
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"ibexa/search": "~5.0.x-dev",
2929
"ibexa/test-core": "~5.0.x-dev",
3030
"ibexa/user": "~5.0.x-dev",
31-
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
31+
"matthiasnoback/symfony-dependency-injection-test": "^5.0",
3232
"phpstan/phpstan": "^2.0",
3333
"phpstan/phpstan-phpunit": "^2.0",
3434
"phpstan/phpstan-symfony": "^2.0",

phpstan.neon

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,3 @@ parameters:
1010
- src
1111
- tests
1212
treatPhpDocTypesAsCertain: false
13-
ignoreErrors:
14-
-
15-
message: "#^Cannot call method (fetchOne|fetchColumn|fetchAllAssociative|fetchAssociative|fetchAllKeyValue|fetchFirstColumn)\\(\\) on Doctrine\\\\DBAL\\\\ForwardCompatibility\\\\Result\\|int\\|string\\.$#"

src/bundle/SystemInfo/Collector/RepositorySystemInfoCollector.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ public function __construct(Connection $db, MetricsProvider $metricsProvider)
4545
*/
4646
public function collect(): RepositorySystemInfo
4747
{
48+
$params = $this->connection->getParams();
49+
4850
return new RepositorySystemInfo([
4951
'type' => $this->connection->getDatabasePlatform()->getName(),
5052
'name' => $this->connection->getDatabase(),
51-
'host' => $this->connection->getHost(),
52-
'username' => $this->connection->getUsername(),
53+
'host' => $params['host'] ?? '',
54+
'username' => $params['user'] ?? '',
5355
'repositoryMetrics' => $this->populateRepositoryMetricsData(),
5456
]);
5557
}

src/lib/Storage/Metrics/ContentTypesCountMetrics.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ public function getValue(): int
3232
$queryBuilder->expr()->eq(self::VERSION_COLUMN, Type::STATUS_DEFINED)
3333
);
3434

35-
return (int) $queryBuilder->execute()->fetchColumn();
35+
return (int) $queryBuilder->executeQuery()->fetchFirstColumn();
3636
}
3737
}

src/lib/Storage/Metrics/DraftsCountMetrics.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ public function getValue(): int
4444
)
4545
->setParameter('status', ContentInfo::STATUS_DRAFT, ParameterType::INTEGER);
4646

47-
return (int) $queryBuilder->execute()->fetchColumn();
47+
return (int) $queryBuilder->executeQuery()->fetchFirstColumn();
4848
}
4949
}

src/lib/Storage/Metrics/PublishedContentObjectsCountMetrics.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ public function getValue(): int
3232
$queryBuilder->expr()->eq(self::STATUS_COLUMN, ContentInfo::STATUS_PUBLISHED)
3333
);
3434

35-
return (int) $queryBuilder->execute()->fetchColumn();
35+
return (int) $queryBuilder->executeQuery()->fetchFirstColumn();
3636
}
3737
}

src/lib/Storage/Metrics/UsersCountMetrics.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ public function getValue(): int
2626
->select($this->getCountExpression(self::CONTENTOBJECT_ID_COLUMN))
2727
->from(self::USER_TABLE);
2828

29-
return (int) $queryBuilder->execute()->fetchColumn();
29+
return (int) $queryBuilder->executeQuery()->fetchFirstColumn();
3030
}
3131
}

src/lib/Storage/Metrics/VersionsCountMetrics.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ public function getValue(): int
2626
->select($this->getCountExpression(self::ID_COLUMN))
2727
->from(self::CONTENTOBJECT_VERSION_TABLE);
2828

29-
return (int) $queryBuilder->execute()->fetchColumn();
29+
return (int) $queryBuilder->executeQuery()->fetchFirstColumn();
3030
}
3131
}

tests/bundle/SystemInfo/Collector/RepositorySystemInfoCollectorTest.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,25 @@ public function testCollect(): void
6464
$this->dbalConnectionMock
6565
->expects(self::once())
6666
->method('getDatabasePlatform')
67-
->will(self::returnValue($this->dbalPlatformMock));
67+
->willReturn($this->dbalPlatformMock);
6868

6969
$this->dbalPlatformMock
7070
->expects(self::once())
7171
->method('getName')
72-
->will(self::returnValue($expected->type));
72+
->willReturn($expected->type);
7373

7474
$this->dbalConnectionMock
7575
->expects(self::once())
7676
->method('getDatabase')
77-
->will(self::returnValue($expected->name));
77+
->willReturn($expected->name);
7878

7979
$this->dbalConnectionMock
8080
->expects(self::once())
81-
->method('getHost')
82-
->will(self::returnValue($expected->host));
83-
84-
$this->dbalConnectionMock
85-
->expects(self::once())
86-
->method('getUsername')
87-
->will(self::returnValue($expected->username));
81+
->method('getParams')
82+
->willReturn([
83+
'host' => $expected->host,
84+
'user' => $expected->username,
85+
]);
8886

8987
$this->metricsProviderMock
9088
->expects(self::exactly(5))

0 commit comments

Comments
 (0)