Skip to content

Commit 6dbda8b

Browse files
authored
Merge pull request #38 from MacPaw/develop
New Release
2 parents b6bf30d + 6ae3139 commit 6dbda8b

File tree

8 files changed

+58
-4
lines changed

8 files changed

+58
-4
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ jobs:
2626
include:
2727
- php: '8.0'
2828
symfony-versions: '^6.0'
29+
coverage: 'none'
2930
- php: '8.1'
3031
symfony-versions: '^6.0'
32+
coverage: 'none'
3133
- description: 'Log Code Coverage'
3234
php: '8.1'
3335
coverage: 'xdebug'

.github/workflows/static-analysis.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,19 @@ jobs:
3737

3838
- name: Run script
3939
run: vendor/bin/phpstan analyse
40+
41+
composer-validate:
42+
name: Composer validate
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v2
47+
48+
- name: Setup PHP
49+
uses: shivammathur/setup-php@v2
50+
51+
- name: Install dependencies
52+
run: composer install --no-progress --no-interaction --prefer-dist
53+
54+
- name: Run script
55+
run: composer composer-validate

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
}
5353
},
5454
"scripts": {
55+
"composer-validate": [
56+
"composer validate"
57+
],
5558
"cs": [
5659
"vendor/bin/phpcs"
5760
],

src/Check/DoctrineCheck.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public function check(): array
4242
}
4343

4444
try {
45-
$entityManager->getConnection()->ping();
45+
$con = $entityManager->getConnection();
46+
$con->executeQuery($con->getDatabasePlatform()->getDummySelectSQL())->free();
4647
} catch (Throwable $e) {
4748
return array_merge($result, [self::CHECK_RESULT_KEY => false]);
4849
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SymfonyHealthCheckBundle\Tests\Integration\Mock;
6+
7+
class AbstractPlatformMock
8+
{
9+
public function getDummySelectSQL(): string
10+
{
11+
$expression = func_num_args() > 0 ? func_get_arg(0) : '1';
12+
13+
return sprintf('SELECT %s', $expression);
14+
}
15+
}

tests/Integration/Mock/ConnectionMock.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66

77
class ConnectionMock
88
{
9-
public function ping(): bool
9+
public function getDatabasePlatform(): AbstractPlatformMock
1010
{
11-
return true;
11+
return new AbstractPlatformMock();
12+
}
13+
14+
public function executeQuery(): ExecuteQueryMock
15+
{
16+
return new ExecuteQueryMock();
1217
}
1318
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SymfonyHealthCheckBundle\Tests\Integration\Mock;
6+
7+
class ExecuteQueryMock
8+
{
9+
public function free(): void
10+
{
11+
}
12+
}

tests/Integration/Unit/Check/DoctrineCheckTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function testDoctrineFailPing(): void
104104
->willReturn($connectionMock);
105105

106106
$connectionMock
107-
->method('ping')
107+
->method('getDatabasePlatform')
108108
->with()
109109
->will(self::throwException(new Exception()));
110110

0 commit comments

Comments
 (0)