Skip to content

Commit 0240845

Browse files
authored
Use the assert-package-constraint step provided by third party (#79)
1 parent dd0f54f commit 0240845

File tree

2 files changed

+1
-33
lines changed

2 files changed

+1
-33
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"symfony/security-guard": "^4.0 || ^5.0",
2525
"symfony/validator": "*",
2626
"twig/twig": "^2.10 || ^3.0",
27-
"weirdan/codeception-psalm-module": "~0.8"
27+
"weirdan/codeception-psalm-module": "~0.9"
2828
},
2929
"autoload": {
3030
"psr-4": {

src/Test/CodeceptionModule.php

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
namespace Psalm\SymfonyPsalmPlugin\Test;
66

77
use Codeception\Module as BaseModule;
8-
use Composer\InstalledVersions;
9-
use Composer\Semver\VersionParser;
108
use InvalidArgumentException;
11-
use PackageVersions\Versions;
12-
use PHPUnit\Framework\SkippedTestError;
13-
use RuntimeException;
149
use Twig\Cache\FilesystemCache;
1510
use Twig\Environment;
1611
use Twig\Extension\AbstractExtension;
@@ -61,33 +56,6 @@ public function haveTheTemplateCompiled(string $templateName, string $cacheDirec
6156
$twigEnvironment->load($templateName);
6257
}
6358

64-
/**
65-
* @Given I have the :package package satisfying the :versionConstraint
66-
*/
67-
public function haveADependencySatisfied(string $package, string $versionConstraint): void
68-
{
69-
$parser = new VersionParser();
70-
/** @psalm-suppress UndefinedClass Composer\InstalledVersions is undefined when using Composer 1.x */
71-
/** @psalm-suppress DeprecatedClass PackageVersions\Versions is used for Composer 1.x compatibility */
72-
if (class_exists(InstalledVersions::class)) {
73-
/** @var bool $isSatisfied */
74-
$isSatisfied = InstalledVersions::satisfies($parser, $package, $versionConstraint);
75-
} elseif (class_exists(Versions::class)) {
76-
$version = (string) Versions::getVersion($package);
77-
78-
if (false === strpos($version, '@')) {
79-
throw new RuntimeException('$version must contain @');
80-
}
81-
82-
$isSatisfied = $parser->parseConstraints(explode('@', $version)[0])
83-
->matches($parser->parseConstraints($versionConstraint));
84-
}
85-
86-
if (!isset($isSatisfied) || !$isSatisfied) {
87-
throw new SkippedTestError("This scenario requires $package to match $versionConstraint");
88-
}
89-
}
90-
9159
private static function getEnvironment(string $rootDirectory, string $cacheDirectory): Environment
9260
{
9361
if (!file_exists($rootDirectory.DIRECTORY_SEPARATOR.self::TWIG_TEMPLATES_DIR)) {

0 commit comments

Comments
 (0)