Skip to content

Commit 164202d

Browse files
committed
💚 add phpstan to pipeline
1 parent 82b4c15 commit 164202d

File tree

7 files changed

+67
-13
lines changed

7 files changed

+67
-13
lines changed

.gitattributes

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
.gitattributes export-ignore
2-
.github export-ignore
3-
.gitignore export-ignore
4-
.php_cs export-ignore
5-
phpunit.xml.dist export-ignore
6-
README.md export-ignore
7-
UPGRADE.md export-ignore
8-
docs/ export-ignore
9-
tests/ export-ignore
1+
/.git* export-ignore
2+
/.php_cs export-ignore
3+
/phpstan* export-ignore
4+
/phpunit.xml.dist export-ignore
5+
/README.md export-ignore
6+
/UPGRADE.md export-ignore
7+
/docs/ export-ignore
8+
/tests/ export-ignore

.github/workflows/build.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,26 @@ on:
55
push: ~
66

77
jobs:
8+
phpstan:
9+
runs-on: ubuntu-20.04
10+
name: PHPStan
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
- name: PHPStan
15+
uses: docker://oskarstark/phpstan-ga
16+
env:
17+
REQUIRE_DEV: true
18+
with:
19+
args: analyse
20+
cs-fixer:
21+
runs-on: ubuntu-20.04
22+
name: PHP-CS-Fixer
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v2
26+
- name: Fix CS
27+
uses: docker://oskarstark/php-cs-fixer-ga
828
tests:
929
runs-on: ubuntu-20.04
1030
strategy:

.php_cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
$finder = PhpCsFixer\Finder::create()
55
->in([__DIR__.'/src', __DIR__.'/tests'])
6+
->notPath('FakeFixtureDependent.php')
67
;
78

89
return PhpCsFixer\Config::create()

phpstan-baseline.neon

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#"
5+
count: 1
6+
path: src/DependencyInjection/Configuration.php
7+
8+
-
9+
message: "#^Parameter \\$manager of method Beelab\\\\TestBundle\\\\Tests\\\\FakeFixture\\:\\:load\\(\\) has invalid typehint type Doctrine\\\\Common\\\\Persistence\\\\ObjectManager\\.$#"
10+
count: 1
11+
path: tests/FakeFixture.php
12+
13+
-
14+
message: "#^Parameter \\$manager of method Beelab\\\\TestBundle\\\\Tests\\\\FakeFixtureDependent\\:\\:load\\(\\) has invalid typehint type Doctrine\\\\Common\\\\Persistence\\\\ObjectManager\\.$#"
15+
count: 1
16+
path: tests/FakeFixtureDependent.php
17+

phpstan.neon

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
parameters:
2+
level: 5
3+
paths:
4+
- src
5+
- tests
6+
excludePaths:
7+
analyse:
8+
- tests/FakeFixture.php
9+
- tests/FakeFixtureDependent.php
10+
includes:
11+
- phpstan-baseline.neon

src/Test/WebTestCase.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,14 @@ protected function loadFixtures(
203203
} else {
204204
$manager = self::$em;
205205
}
206-
$manager->getConnection()->exec('SET foreign_key_checks = 0');
206+
$manager->getConnection()->executeStatement('SET foreign_key_checks = 0');
207207
$loader = new Loader(static::$container);
208208
foreach ($fixtures as $fixture) {
209209
$this->loadFixtureClass($loader, $namespace.$fixture);
210210
}
211211
$executor = new ORMExecutor($manager, new ORMPurger());
212212
$executor->execute($loader->getFixtures(), $append);
213-
$manager->getConnection()->exec('SET foreign_key_checks = 1');
213+
$manager->getConnection()->executeStatement('SET foreign_key_checks = 1');
214214
}
215215

216216
/**
@@ -220,6 +220,7 @@ protected function loadFixtures(
220220
protected static function assertMailSent(int $num, string $message = ''): void
221221
{
222222
if (false !== $profile = self::$client->getProfile()) {
223+
/** @var \Symfony\Bundle\SwiftmailerBundle\DataCollector\MessageDataCollector $collector */
223224
$collector = $profile->getCollector('swiftmailer');
224225
self::assertEquals($num, $collector->getMessageCount(), $message);
225226
} else {

tests/Test/WebTestCaseTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ public function testSaveOutput(): void
8282
$method->setAccessible(true);
8383
$method->invoke(self::$mock, false);
8484

85-
self::assertNotNull($file = $vfs->getChild('public/test.html'));
85+
/** @var \org\bovigo\vfs\vfsStreamFile $file */
86+
$file = $vfs->getChild('public/test.html');
87+
self::assertNotNull($file);
8688
self::assertEquals('Response content', $file->getContent());
8789
}
8890

@@ -204,7 +206,7 @@ public function testLoadFixtureClass(): void
204206
public function testLoadFixtures(): void
205207
{
206208
self::markTestIncomplete('Need to mock `loadFixtureClass` method correctly');
207-
209+
/*
208210
self::$mock
209211
->expects(self::exactly(2))
210212
->method('loadFixtureClass');
@@ -228,6 +230,7 @@ public function testLoadFixtures(): void
228230
$method = new \ReflectionMethod(self::$mock, 'loadFixtures');
229231
$method->setAccessible(true);
230232
$method->invoke(self::$mock, ['Fixture1', 'Fixture2'], 'My\\NameSpace\\', 'my.manager');
233+
*/
231234
}
232235

233236
public function testAjax(): void
@@ -254,6 +257,7 @@ public function testCommandTest(): void
254257
public function testAssertMailSent(): void
255258
{
256259
self::markTestIncomplete('cannot mock static call to "assertEquals"');
260+
/*
257261
$swiftmailerProfiler = $this->createMock(MessageDataCollector::class);
258262
$swiftmailerProfiler
259263
->expects(self::once())
@@ -278,6 +282,7 @@ public function testAssertMailSent(): void
278282
$method = new \ReflectionMethod(self::$mock, 'assertMailSent');
279283
$method->setAccessible(true);
280284
$method->invoke(self::$mock, 1);
285+
*/
281286
}
282287

283288
public function testClickLinkByData(): void

0 commit comments

Comments
 (0)