Skip to content

Commit 54b9ab5

Browse files
authored
Merge pull request #142 from magento-commerce/MCLOUD-10319
MCLOUD-10319: Stabilize static tests
2 parents 0789599 + aa8f3d6 commit 54b9ab5

File tree

6 files changed

+58
-33
lines changed

6 files changed

+58
-33
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"consolidation/robo": "^1.2 || ^3.0",
4646
"php-mock/php-mock-phpunit": "^2.0",
4747
"phpmd/phpmd": "@stable",
48-
"phpstan/phpstan": "^0.12",
48+
"phpstan/phpstan": "^1.10",
4949
"phpunit/php-code-coverage": "^7.0 || ^9.2",
5050
"phpunit/phpunit": "^8.5 || ^9.5",
5151
"squizlabs/php_codesniffer": "^3.0",

src/Filesystem/DirectoryList.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ public function getPath(string $code, bool $relativePath = false): string
8080
throw new \RuntimeException("Code {$code} is not registered");
8181
}
8282

83-
if (!array_key_exists(static::PATH, $directories[$code])) {
83+
if (!array_key_exists(self::PATH, $directories[$code])) {
8484
throw new \RuntimeException(
85-
sprintf('Config var "%s" does not exists', static::PATH)
85+
sprintf('Config var "%s" does not exists', self::PATH)
8686
);
8787
}
8888

@@ -113,7 +113,7 @@ public function getMagentoRoot(): string
113113
*/
114114
public function getInit(): string
115115
{
116-
return $this->getPath(static::DIR_INIT);
116+
return $this->getPath(self::DIR_INIT);
117117
}
118118

119119
/**
@@ -122,7 +122,7 @@ public function getInit(): string
122122
*/
123123
public function getVar(): string
124124
{
125-
return $this->getPath(static::DIR_VAR);
125+
return $this->getPath(self::DIR_VAR);
126126
}
127127

128128
/**
@@ -131,7 +131,7 @@ public function getVar(): string
131131
*/
132132
public function getLog(): string
133133
{
134-
return $this->getPath(static::DIR_LOG);
134+
return $this->getPath(self::DIR_LOG);
135135
}
136136

137137
/**
@@ -140,7 +140,7 @@ public function getLog(): string
140140
*/
141141
public function getGeneratedCode(): string
142142
{
143-
return $this->getPath(static::DIR_GENERATED_CODE);
143+
return $this->getPath(self::DIR_GENERATED_CODE);
144144
}
145145

146146
/**
@@ -149,7 +149,7 @@ public function getGeneratedCode(): string
149149
*/
150150
public function getGeneratedMetadata(): string
151151
{
152-
return $this->getPath(static::DIR_GENERATED_METADATA);
152+
return $this->getPath(self::DIR_GENERATED_METADATA);
153153
}
154154

155155
/**
@@ -161,15 +161,15 @@ public function getGeneratedMetadata(): string
161161
public function getWritableDirectories(): array
162162
{
163163
$writableDirs = [
164-
static::DIR_ETC,
165-
static::DIR_MEDIA,
166-
static::DIR_LOG,
167-
static::DIR_VIEW_PREPROCESSED,
164+
self::DIR_ETC,
165+
self::DIR_MEDIA,
166+
self::DIR_LOG,
167+
self::DIR_VIEW_PREPROCESSED,
168168
];
169169

170170
if ($this->magentoVersion->satisfies('2.1.*')) {
171-
$writableDirs[] = static::DIR_GENERATED_METADATA;
172-
$writableDirs[] = static::DIR_GENERATED_CODE;
171+
$writableDirs[] = self::DIR_GENERATED_METADATA;
172+
$writableDirs[] = self::DIR_GENERATED_CODE;
173173
}
174174

175175
return array_map(function ($path) {
@@ -186,10 +186,10 @@ public function getWritableDirectories(): array
186186
public function getMountPoints(): array
187187
{
188188
$mountPoints = [
189-
static::DIR_ETC,
190-
static::DIR_VAR,
191-
static::DIR_MEDIA,
192-
static::DIR_STATIC
189+
self::DIR_ETC,
190+
self::DIR_VAR,
191+
self::DIR_MEDIA,
192+
self::DIR_STATIC
193193
];
194194

195195
return array_map(function ($path) {
@@ -203,13 +203,13 @@ public function getMountPoints(): array
203203
private function getDefaultDirectories(): array
204204
{
205205
$config = [
206-
static::DIR_INIT => [static::PATH => 'init'],
207-
static::DIR_VAR => [static::PATH => 'var'],
208-
static::DIR_LOG => [static::PATH => 'var/log'],
209-
static::DIR_ETC => [static::PATH => 'app/etc'],
210-
static::DIR_MEDIA => [static::PATH => 'pub/media'],
211-
static::DIR_STATIC => [static::PATH => 'pub/static'],
212-
static::DIR_VIEW_PREPROCESSED => [static::PATH => 'var/view_preprocessed'],
206+
self::DIR_INIT => [self::PATH => 'init'],
207+
self::DIR_VAR => [self::PATH => 'var'],
208+
self::DIR_LOG => [self::PATH => 'var/log'],
209+
self::DIR_ETC => [self::PATH => 'app/etc'],
210+
self::DIR_MEDIA => [self::PATH => 'pub/media'],
211+
self::DIR_STATIC => [self::PATH => 'pub/static'],
212+
self::DIR_VIEW_PREPROCESSED => [self::PATH => 'var/view_preprocessed'],
213213
];
214214

215215
return $config;
@@ -224,11 +224,11 @@ private function getDefaultVariadicDirectories(): array
224224
$config = [];
225225

226226
if ($this->magentoVersion->satisfies('2.1.*')) {
227-
$config[static::DIR_GENERATED_CODE] = [static::PATH => 'var/generation'];
228-
$config[static::DIR_GENERATED_METADATA] = [static::PATH => 'var/di'];
227+
$config[self::DIR_GENERATED_CODE] = [self::PATH => 'var/generation'];
228+
$config[self::DIR_GENERATED_METADATA] = [self::PATH => 'var/di'];
229229
} else {
230-
$config[static::DIR_GENERATED_CODE] = [static::PATH => 'generated/code'];
231-
$config[static::DIR_GENERATED_METADATA] = [static::PATH => 'generated/metadata'];
230+
$config[self::DIR_GENERATED_CODE] = [self::PATH => 'generated/code'];
231+
$config[self::DIR_GENERATED_METADATA] = [self::PATH => 'generated/metadata'];
232232
}
233233

234234
return $config;

src/Test/Unit/Config/AdminDataTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
use Magento\MagentoCloud\Config\AdminData;
1111
use Magento\MagentoCloud\Config\EnvironmentDataInterface;
12-
use PHPStan\Testing\TestCase;
1312
use PHPUnit\Framework\MockObject\MockObject;
13+
use PHPUnit\Framework\TestCase;
1414

1515
/**
1616
* @inheritDoc

src/Test/Unit/Config/EnvironmentDataTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
use Magento\MagentoCloud\Filesystem\Driver\File;
1818
use Magento\MagentoCloud\Filesystem\FileSystemException;
1919
use phpmock\phpunit\PHPMock;
20-
use PHPStan\Testing\TestCase;
2120
use PHPUnit\Framework\MockObject\MockObject;
21+
use PHPUnit\Framework\TestCase;
2222

2323
/**
2424
* @inheritDoc

src/Util/StaticContentCompressor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private function getCompressionCommand(
153153
): string {
154154
$compressionLevel = $compressionLevel > 0 && $compressionLevel <= 9
155155
? $compressionLevel
156-
: static::DEFAULT_COMPRESSION_LEVEL;
156+
: self::DEFAULT_COMPRESSION_LEVEL;
157157

158158
return sprintf(
159159
'%s -k 30 %s %s -c %s',

tests/static/phpstan.neon

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,38 @@ parameters:
22
level: 5
33
paths:
44
- ../../src
5-
excludes_analyse:
5+
excludePaths:
66
- ../../src/Test/*
77
reportUnmatchedIgnoredErrors: false
8+
treatPhpDocTypesAsCertain: false
89
ignoreErrors:
910
- message: "#.*ComponentRegistrar.*#"
1011
path: ../../src/StaticContent/ThemeResolver.php
1112
- message: "#Strict comparison using === between bool and null will always evaluate to false.#"
1213
path: ../../src/Filesystem/Driver/File.php
1314
- message: "#should return int but returns null#"
1415
path: ../../src/Command/DbDump.php
16+
- message: '#Call to an undefined method Symfony\\Component\\Console\\Helper\\HelperInterface\:\:ask\(\)\.#'
17+
paths:
18+
- ../../src/Command/BackupRestore.php
19+
- ../../src/Command/DbDump.php
20+
- message: '#Access to private constant#'
21+
path: ../../src/App/Logger/Gelf/TransportFactory.php
22+
- message: '#Property Magento\\MagentoCloud\\App\\Logger\\LineFormatterFactory\:\:\$container is never read, only written\.#'
23+
path: ../../src/App/Logger/LineFormatterFactory.php
24+
- message: '#Property Magento\\MagentoCloud\\Command\\ConfigShow\:\:\$logger is never read, only written\.#'
25+
path: ../../src/Command/ConfigShow.php
26+
- message: '#Property Magento\\MagentoCloud\\Command\\ConfigShow\\Renderer\:\:\$logger is never read, only written\.#'
27+
path: ../../src/Command/ConfigShow/Renderer.php
28+
- message: '#Property Magento\\MagentoCloud\\Command\\CronUnlock\:\:\$magentoVersion is never read, only written\.#'
29+
path: ../../src/Command/CronUnlock.php
30+
- message: '#Property Magento\\MagentoCloud\\Filesystem\\RecoverableDirectoryList\:\:\$environment is never read, only written\.#'
31+
path: ../../src/Filesystem/RecoverableDirectoryList.php
32+
- message: '#Property Magento\\MagentoCloud\\Step\\Deploy\\InstallUpdate\\ConfigUpdate\\CronConsumersRunner\:\:\$environment is never read, only written\.#'
33+
path: ../../src/Step/Deploy/InstallUpdate/ConfigUpdate/CronConsumersRunner.php
34+
- message: '#Property Magento\\MagentoCloud\\Step\\Deploy\\InstallUpdate\\ConfigUpdate\\Urls\\Database\:\:\$environment is never read, only written\.#'
35+
path: ../../src/Step/Deploy/InstallUpdate/ConfigUpdate/Urls/Database.php
36+
- message: '#on null in isset\(\) does not exist#'
37+
path: ../../src/Service/Validator.php
38+
- message: '#Expression on left side of \?\? is not nullable#'
39+
path: ../../src/Util/UrlManager.php

0 commit comments

Comments
 (0)