From 3d8284e73823bf974b4771fe978c7db1eea5b057 Mon Sep 17 00:00:00 2001 From: Alexey Kopytko Date: Fri, 27 Nov 2020 07:56:09 +0900 Subject: [PATCH] Prep work to migrate to PHPUnit 9.x --- .appveyor.yml | 45 ------- .circleci/config.yml | 29 ----- .composer-require-checker.json | 1 + .github/workflows/ci.yml | 123 ++++++++++++++++++ .github/workflows/{sca.yaml => sca.yml} | 4 +- .github/workflows/{yaml.yaml => yaml.yml} | 13 +- .php_cs.dist | 2 +- .travis.yml | 55 +------- .yamllint.yml | 6 + composer.json | 1 + ...TravisTest.php => CiConfigurationTest.php} | 42 ++++-- tests/AutoReview/ProjectCodeTest.php | 6 +- tests/Cache/FileHandlerTest.php | 8 +- tests/ConfigTest.php | 8 +- tests/Console/Command/DescribeCommandTest.php | 10 +- tests/Console/Command/FixCommandTest.php | 2 +- tests/Console/ConfigurationResolverTest.php | 12 +- tests/Console/Output/ErrorOutputTest.php | 10 +- tests/DocBlock/AnnotationTest.php | 4 +- tests/DocBlock/DocBlockTest.php | 12 +- tests/Error/ErrorsManagerTest.php | 6 +- tests/FileReaderTest.php | 2 +- tests/FileRemovalTest.php | 14 +- tests/FinderTest.php | 2 +- .../Fixer/Alias/NoMixedEchoPrintFixerTest.php | 2 +- .../Alias/RandomApiMigrationFixerTest.php | 4 +- .../ArrayNotation/ArraySyntaxFixerTest.php | 2 +- tests/Fixer/Basic/BracesFixerTest.php | 2 +- .../Basic/NonPrintableCharacterFixerTest.php | 2 +- .../CastNotation/CastSpacesFixerTest.php | 4 +- .../ClassDefinitionFixerTest.php | 4 +- .../FinalInternalClassFixerTest.php | 2 +- .../OrderedClassElementsFixerTest.php | 2 +- ...ingleClassElementPerStatementFixerTest.php | 2 +- .../VisibilityRequiredFixerTest.php | 4 +- .../Fixer/Comment/HeaderCommentFixerTest.php | 4 +- .../NoBreakCommentFixerTest.php | 4 +- .../ControlStructure/YodaStyleFixerTest.php | 2 +- .../FunctionDeclarationFixerTest.php | 2 +- .../NativeFunctionInvocationFixerTest.php | 2 +- .../ReturnTypeDeclarationFixerTest.php | 2 +- .../FunctionToConstantFixerTest.php | 4 +- .../LanguageConstruct/IsNullFixerTest.php | 2 +- .../BinaryOperatorSpacesFixerTest.php | 12 +- tests/Fixer/Operator/ConcatSpaceFixerTest.php | 4 +- .../PhpUnit/PhpUnitConstructFixerTest.php | 2 +- .../PhpUnitDedicateAssertFixerTest.php | 2 +- .../PhpUnit/PhpUnitNamespacedFixerTest.php | 2 +- .../Fixer/PhpUnit/PhpUnitStrictFixerTest.php | 2 +- ...UnitTestCaseStaticMethodCallsFixerTest.php | 4 +- ...pdocAddMissingParamAnnotationFixerTest.php | 2 +- .../Phpdoc/PhpdocNoAliasTagFixerTest.php | 12 +- .../PhpdocReturnSelfReferenceFixerTest.php | 2 +- tests/Fixer/Phpdoc/PhpdocTypesFixerTest.php | 2 +- .../Whitespace/NoExtraBlankLinesFixerTest.php | 2 +- .../NoSpacesAroundOffsetFixerTest.php | 2 +- .../AliasedFixerOptionTest.php | 2 +- .../AllowedValueSubsetTest.php | 2 +- tests/FixerConfiguration/FixerOptionTest.php | 2 +- tests/FixerFactoryTest.php | 2 +- .../PhpUnitTestCaseIndicatorTest.php | 2 +- tests/PregTest.php | 2 +- tests/RuleSet/RuleSetTest.php | 6 +- tests/RuleSet/RuleSetsTest.php | 6 +- tests/RuleSet/Sets/AbstractSetTest.php | 6 +- tests/Runner/FileFilterIteratorTest.php | 2 +- tests/Runner/RunnerTest.php | 6 +- tests/Smoke/CiIntegrationTest.php | 4 +- tests/Smoke/InstallViaComposerTest.php | 4 + tests/Smoke/PharTest.php | 2 +- tests/Test/AbstractFixerTestCase.php | 32 ++--- tests/Test/AbstractTransformerTestCase.php | 12 +- tests/TestCase.php | 2 + tests/Tokenizer/TokensTest.php | 14 +- tests/ToolInfoTest.php | 2 +- tests/WhitespacesFixerConfigTest.php | 2 +- 76 files changed, 334 insertions(+), 297 deletions(-) delete mode 100644 .appveyor.yml delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yml rename .github/workflows/{sca.yaml => sca.yml} (98%) rename .github/workflows/{yaml.yaml => yaml.yml} (66%) create mode 100644 .yamllint.yml rename tests/AutoReview/{TravisTest.php => CiConfigurationTest.php} (85%) diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index d577f8f2092..00000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,45 +0,0 @@ -build: false -version: dev-{build} -shallow_clone: false -clone_folder: C:\projects\php-cs-fixer - -environment: - matrix: - - php_ver: 7.3.1 - FAST_LINT_TEST_CASES: 1 - - php_ver: 5.6.40 - SKIP_LINT_TEST_CASES: 1 - -cache: - - '%APPDATA%\Composer' - - '%LOCALAPPDATA%\Composer' - - C:\tools\php -> .appveyor.yml - - C:\tools\composer.phar -> .appveyor.yml - -init: - - SET PATH=C:\tools\php;%PATH% - -install: - - ps: Set-Service wuauserv -StartupType Manual - - IF NOT EXIST C:\tools\php (choco install --yes --allow-empty-checksums php --version %php_ver% --params '/InstallDir:C:\tools\php') - - cd C:\tools\php - - copy php.ini-production php.ini - - echo date.timezone="UTC" >> php.ini - - echo memory_limit=512M >> php.ini - - echo extension_dir=ext >> php.ini - - echo extension=php_curl.dll >> php.ini - - echo extension=php_openssl.dll >> php.ini - - echo extension=php_mbstring.dll >> php.ini - - IF NOT EXIST C:\tools\composer.phar (cd C:\tools && appveyor DownloadFile https://getcomposer.org/composer-stable.phar -FileName composer.phar) - - cd C:\projects\php-cs-fixer - -before_test: - - cd C:\projects\php-cs-fixer - - php C:\tools\composer.phar update --optimize-autoloader --no-interaction --no-progress --prefer-stable --no-ansi - - php C:\tools\composer.phar info -D | sort - -test_script: - - cd C:\projects\php-cs-fixer - - vendor\bin\phpunit - - set PHP_CS_FIXER_FUTURE_MODE=1 - - php php-cs-fixer --diff --dry-run -v fix diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 25004b82378..00000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,29 +0,0 @@ -version: 2 - -jobs: - build: - macos: - # https://circleci.com/docs/2.0/testing-ios/#supported-xcode-versions - xcode: '12.2.0' - steps: - - checkout - - - restore_cache: - keys: - - cache-{{ checksum "composer.json" }} - - - run: brew update - - run: brew install php@7.4 - - run: echo "memory_limit = 512M" > $(brew --prefix)/etc/php/7.4/conf.d/memory.ini - - run: curl -sS https://getcomposer.org/installer | php - - run: php composer.phar install --optimize-autoloader --no-interaction --no-progress --no-suggest - - run: php composer.phar info -D | sort - - - save_cache: - key: cache-{{ checksum "composer.json" }} - paths: - - ~/.composer - - ~/Library/Caches/Homebrew - - - run: vendor/bin/phpunit - - run: PHP_CS_FIXER_FUTURE_MODE=1 php php-cs-fixer --diff --dry-run -v fix diff --git a/.composer-require-checker.json b/.composer-require-checker.json index 95281bb558b..5cfd3ba27fb 100644 --- a/.composer-require-checker.json +++ b/.composer-require-checker.json @@ -6,6 +6,7 @@ "PHPUnit\\Framework\\Constraint\\IsIdentical", "PHPUnit\\Framework\\TestCase", "PHPUnit\\Runner\\Version", + "PHPUnitGoodPractices\\Polyfill\\PolyfillTrait", "PHPUnitGoodPractices\\Traits\\ExpectationViaCodeOverAnnotationTrait", "PHPUnitGoodPractices\\Traits\\ExpectOverSetExceptionTrait", "PHPUnitGoodPractices\\Traits\\IdentityOverEqualityTrait", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..0700b9c4a7e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,123 @@ +name: CI + +on: + - pull_request + - push + +jobs: + tests: + strategy: + matrix: + include: + - operating-system: 'ubuntu-20.04' + php-version: '5.6' + composer-flags: '--prefer-stable --prefer-lowest' # should be checked on lowest supported PHP version + + - operating-system: 'ubuntu-20.04' + php-version: '7.0' + job-description: 'with Sf ^3' + execute-flex-with-symfony-version: '^3' # Explicit check for Sf 3.x compatibility + + - operating-system: 'ubuntu-20.04' + php-version: '7.1' + job-description: 'with Sf ^4' + execute-flex-with-symfony-version: '^4' # Explicit check for Sf 4.x compatibility + + - operating-system: 'ubuntu-20.04' + php-version: '7.2' + job-description: 'with Sf ^5' + execute-flex-with-symfony-version: '^5' # Explicit check for Sf 5.x compatibility + + - operating-system: 'ubuntu-20.04' + php-version: '7.3' + job-description: 'with legacy Tokenizer' # should be checked on any job, one is enough + PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER: 1 + SYMFONY_DEPRECATIONS_HELPER: 'disabled' + + - operating-system: 'ubuntu-20.04' + php-version: '7.4' + job-description: 'with migration rules' + execute-migration-rules: 'yes' # should be checked on highest supported PHP version + + - operating-system: 'ubuntu-20.04' + php-version: '8.0' + composer-flags: '--ignore-platform-req=php' # as this is a version not yet officially supported by PHP CS Fixer + PHP_CS_FIXER_IGNORE_ENV: 1 + + - operating-system: 'windows-latest' + php-version: '7.4' + job-description: 'on Windows' + FAST_LINT_TEST_CASES: 1 + + - operating-system: 'macos-latest' + php-version: '7.4' + job-description: 'on macOS' + + name: PHP ${{ matrix.php-version }} ${{ matrix.job-description }} + + runs-on: ${{ matrix.operating-system }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: none + tools: flex + env: + fail-fast: false # disabled as old PHP version cannot run flex + + - name: Get Composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}-${{ matrix.composer-flags }} + restore-keys: | + composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.*') }}- + composer-${{ runner.os }}-${{ matrix.php-version }}- + composer-${{ runner.os }}- + composer- + + - name: Configure Symfony Flex + run: | + composer config extra.symfony.require ${{ matrix.execute-flex-with-symfony-version }} + if: "matrix.execute-flex-with-symfony-version" + + - name: Install dependencies + uses: nick-invision/retry@v2 + with: + timeout_minutes: 5 + max_attempts: 5 + retry_wait_seconds: 30 + command: | + composer update --optimize-autoloader --no-interaction --no-progress ${{ matrix.composer-flags }} + composer info -D | sort + + - name: Execute migration rules + run: | + php php-cs-fixer fix --rules @PHP73Migration,@PHP71Migration:risky,blank_line_after_opening_tag -q + if: "matrix.execute-migration-rules == 'yes'" + + - name: Run tests + continue-on-error: ${{ matrix.php-version == '8.0' }} + env: + PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.PHP_CS_FIXER_IGNORE_ENV }} + FAST_LINT_TEST_CASES: ${{ matrix.FAST_LINT_TEST_CASES }} + PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER: ${{ matrix.PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER }} + SYMFONY_DEPRECATIONS_HELPER: ${{ matrix.SYMFONY_DEPRECATIONS_HELPER }} + run: | + vendor/bin/phpunit + + - name: Run PHP CS Fixer + env: + PHP_CS_FIXER_IGNORE_ENV: ${{ matrix.PHP_CS_FIXER_IGNORE_ENV }} + PHP_CS_FIXER_FUTURE_MODE: 1 + run: | + php php-cs-fixer --diff --dry-run -v fix diff --git a/.github/workflows/sca.yaml b/.github/workflows/sca.yml similarity index 98% rename from .github/workflows/sca.yaml rename to .github/workflows/sca.yml index 65583c0a4ed..a025cc48437 100644 --- a/.github/workflows/sca.yaml +++ b/.github/workflows/sca.yml @@ -1,5 +1,3 @@ -# yamllint disable rule:line-length - name: Static Code Analysis on: @@ -11,7 +9,7 @@ jobs: strategy: matrix: operating-system: - - ubuntu-latest + - ubuntu-20.04 php-version: - 7.4 diff --git a/.github/workflows/yaml.yaml b/.github/workflows/yaml.yml similarity index 66% rename from .github/workflows/yaml.yaml rename to .github/workflows/yaml.yml index bf40d4a1336..7b75ac07c27 100644 --- a/.github/workflows/yaml.yaml +++ b/.github/workflows/yaml.yml @@ -1,21 +1,22 @@ -# yamllint disable rule:line-length - name: YAML Validation on: pull_request: + paths: + - '**.y?ml' push: + paths: + - '**.y?ml' jobs: validate-yaml: name: Validate YAML - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - name: Checkout code uses: actions/checkout@v2 - - name: Run YAMLlint + - name: Run yamllint run: | - find . -path \*/vendor -prune -false -o -name \*.y*ml | xargs yamllint -d relaxed - + find . -path \*/vendor -prune -false -o -name \*.y*ml | xargs yamllint diff --git a/.php_cs.dist b/.php_cs.dist index 0866483433a..876be07460b 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -23,7 +23,7 @@ $config = PhpCsFixer\Config::create() ->setRiskyAllowed(true) ->setRules([ '@PHP56Migration' => true, - '@PHPUnit60Migration:risky' => true, + '@PHPUnit75Migration:risky' => true, '@PhpCsFixer' => true, '@PhpCsFixer:risky' => true, 'header_comment' => ['header' => $header], diff --git a/.travis.yml b/.travis.yml index 70df30dfaa3..1c0d6dcedb4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,50 +22,7 @@ before_install: jobs: include: - - &STANDARD_TEST_JOB - stage: Fast Test - php: 7.0 - install: - # Composer: enforce given Symfony components version - - if [ "$SYMFONY_VERSION" != "" ]; then composer global show symfony/flex -q || travis_retry composer global require $DEFAULT_COMPOSER_FLAGS symfony/flex; fi - - if [ "$SYMFONY_VERSION" != "" ]; then composer config extra.symfony.require $SYMFONY_VERSION || true; fi - - - travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS - - composer info -D | sort - script: - - vendor/bin/phpunit || travis_terminate 1 - - PHP_CS_FIXER_FUTURE_MODE=1 php php-cs-fixer --diff --dry-run -v fix - - - - <<: *STANDARD_TEST_JOB - stage: Test - php: 5.6 - env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" - - - - <<: *STANDARD_TEST_JOB - stage: Test - php: 7.1 - name: 7.1 | Symfony ~4.1.0 - env: SYMFONY_DEPRECATIONS_HELPER=disabled PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER=1 SYMFONY_VERSION="~4.1.0" - - - - <<: *STANDARD_TEST_JOB - stage: Test - php: 7.2 - name: 7.2 | Symfony ^5.0 - env: SYMFONY_DEPRECATIONS_HELPER=disabled PHP_CS_FIXER_TEST_USE_LEGACY_TOKENIZER=1 SYMFONY_VERSION="^5.0" - - - <<: *STANDARD_TEST_JOB - stage: Test - php: 7.3 - name: 7.3 | With migration rules - before_script: - - php php-cs-fixer fix --rules @PHP73Migration,@PHP71Migration:risky,blank_line_after_opening_tag -q || travis_terminate 1 - - - - <<: *STANDARD_TEST_JOB stage: Test php: 7.4 name: 7.4 | Collect coverage @@ -82,6 +39,9 @@ jobs: # Install PCOV - pecl install pcov + install: + - travis_retry composer update $DEFAULT_COMPOSER_FLAGS $COMPOSER_FLAGS + - composer info -D | sort before_script: # Make code compatible with PHPUnit 8 - PHP_CS_FIXER_FUTURE_MODE=1 php php-cs-fixer fix --rules=void_return -q tests || return 0 @@ -89,12 +49,6 @@ jobs: - vendor/bin/phpunit --testsuite coverage --exclude-group covers-nothing --coverage-clover build/logs/clover.xml || travis_terminate 1 - php vendor/bin/php-coveralls -v - - - <<: *STANDARD_TEST_JOB - stage: Test - php: nightly - env: COMPOSER_FLAGS="--ignore-platform-reqs" PHP_CS_FIXER_IGNORE_ENV=1 SYMFONY_DEPRECATIONS_HELPER=weak - - stage: Deployment php: 7.4 @@ -116,6 +70,3 @@ jobs: tags: true after_deploy: - ./dev-tools/trigger-website.sh ${TRAVIS_TOKEN} ${TRAVIS_TAG} - - allow_failures: - - php: nightly diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 00000000000..1e066d4b7e6 --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,6 @@ +extends: relaxed + +rules: + line-length: + max: 180 + level: warning diff --git a/composer.json b/composer.json index 65d669995ea..532f57cbcda 100644 --- a/composer.json +++ b/composer.json @@ -41,6 +41,7 @@ "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1", "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.1", + "phpunitgoodpractices/polyfill": "^1.5", "phpunitgoodpractices/traits": "^1.9.1", "symfony/phpunit-bridge": "^5.1", "symfony/yaml": "^3.0 || ^4.0 || ^5.0" diff --git a/tests/AutoReview/TravisTest.php b/tests/AutoReview/CiConfigurationTest.php similarity index 85% rename from tests/AutoReview/TravisTest.php rename to tests/AutoReview/CiConfigurationTest.php index 4c230d59d4a..40c0483bd3e 100644 --- a/tests/AutoReview/TravisTest.php +++ b/tests/AutoReview/CiConfigurationTest.php @@ -27,7 +27,7 @@ * @group auto-review * @group covers-nothing */ -final class TravisTest extends TestCase +final class CiConfigurationTest extends TestCase { public function testTestJobsRunOnEachPhp() { @@ -85,7 +85,10 @@ private static function assertUpcomingPhpVersionIsCoveredByCiJob($lastSupportedV new TraversableContains(sprintf('%.1fsnapshot', $lastSupportedVersion)), // if `$lastsupportedVersion` is not snapshot version, expect CI to run snapshot of next PHP version new TraversableContains('nightly'), - new TraversableContains(sprintf('%.1fsnapshot', $lastSupportedVersion + 0.1)) + new TraversableContains(sprintf('%.1fsnapshot', $lastSupportedVersion + 0.1)), + // GitHub CI uses just versions, without suffix, e.g. 8.1 for 8.1snapshot as of writing + new TraversableContains(sprintf('%.1f', $lastSupportedVersion + 0.1)), + new TraversableContains(sprintf('%.1f', round($lastSupportedVersion + 1))) )); } @@ -120,13 +123,10 @@ private function getAllPhpVersionsUsedByCiForDeployments() private function getAllPhpVersionsUsedByCiForTests() { - $jobs = array_filter($this->getTravisJobs(), function ($job) { - return false !== strpos($job['stage'], 'Test'); - }); - - return array_map(function ($job) { - return (string) $job['php']; - }, $jobs); + return array_merge( + $this->getPhpVersionsUsedByTravis(), + $this->getPhpVersionsUsedByGitHub() + ); } private function convertPhpVerIdToNiceVer($verId) @@ -181,4 +181,28 @@ private function getTravisJobs() return $yaml['jobs']['include']; } + + private function getPhpVersionsUsedByGitHub() + { + $yaml = Yaml::parse(file_get_contents(__DIR__.'/../../.github/workflows/ci.yml')); + + $phpVersions = isset($yaml['jobs']['tests']['strategy']['matrix']['php-version']) ? $yaml['jobs']['tests']['strategy']['matrix']['php-version'] : []; + + foreach ($yaml['jobs']['tests']['strategy']['matrix']['include'] as $job) { + $phpVersions[] = $job['php-version']; + } + + return $phpVersions; + } + + private function getPhpVersionsUsedByTravis() + { + $jobs = array_filter($this->getTravisJobs(), function ($job) { + return false !== strpos($job['stage'], 'Test'); + }); + + return array_map(function ($job) { + return (string) $job['php']; + }, $jobs); + } } diff --git a/tests/AutoReview/ProjectCodeTest.php b/tests/AutoReview/ProjectCodeTest.php index 3fbfc9c59aa..399e5e0148e 100644 --- a/tests/AutoReview/ProjectCodeTest.php +++ b/tests/AutoReview/ProjectCodeTest.php @@ -261,8 +261,8 @@ static function (\ReflectionMethod $reflectionMethod) use ($reflectionClass) { } foreach ($publicMethods as $method) { - static::assertRegExp( - '/^(test|provide|setUpBeforeClass$|tearDownAfterClass$)/', + static::assertMatchesRegularExpression( + '/^(test|expect|provide|setUpBeforeClass$|tearDownAfterClass$)/', $method->getName(), sprintf('Public method "%s::%s" is not properly named.', $reflectionClass->getName(), $method->getName()) ); @@ -285,7 +285,7 @@ public function testThatDataProvidersAreCorrectlyNamed($testClassName) } foreach ($usedDataProviderMethodNames as $dataProviderMethodName) { - static::assertRegExp('/^provide[A-Z]\S+Cases$/', $dataProviderMethodName, sprintf( + static::assertMatchesRegularExpression('/^provide[A-Z]\S+Cases$/', $dataProviderMethodName, sprintf( 'Data provider in "%s" with name "%s" is not correctly named.', $testClassName, $dataProviderMethodName diff --git a/tests/Cache/FileHandlerTest.php b/tests/Cache/FileHandlerTest.php index 78ecf3f38fc..a57958415b2 100644 --- a/tests/Cache/FileHandlerTest.php +++ b/tests/Cache/FileHandlerTest.php @@ -99,7 +99,7 @@ public function testWriteThrowsIOExceptionIfFileCanNotBeWritten() $file = __DIR__.'/non-existent-directory/.php_cs.cache'; $this->expectException(\Symfony\Component\Filesystem\Exception\IOException::class); - $this->expectExceptionMessageRegExp(sprintf( + $this->expectExceptionMessageMatches(sprintf( '#^Directory of cache file "%s" does not exists.#', preg_quote($file, '#') )); @@ -135,7 +135,7 @@ public function testWriteCacheToDirectory() $handler = new FileHandler($dir); $this->expectException(\Symfony\Component\Filesystem\Exception\IOException::class); - $this->expectExceptionMessageRegExp(sprintf( + $this->expectExceptionMessageMatches(sprintf( '#^%s$#', preg_quote('Cannot write cache file "'.realpath($dir).'" as the location exists as directory.', '#') )); @@ -153,7 +153,7 @@ public function testWriteCacheToNonWriteableFile() $handler = new FileHandler($file); $this->expectException(\Symfony\Component\Filesystem\Exception\IOException::class); - $this->expectExceptionMessageRegExp(sprintf( + $this->expectExceptionMessageMatches(sprintf( '#^%s$#', preg_quote('Cannot write to file "'.realpath($file).'" as it is not writable.', '#') )); @@ -166,7 +166,7 @@ public function testWriteCacheFilePermissions() $file = __DIR__.'/../Fixtures/cache-file-handler/rw_cache.test'; @unlink($file); - static::assertFileNotExists($file); + static::assertFileDoesNotExist($file); $handler = new FileHandler($file); $handler->write(new Cache($this->createSignature())); diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index bd6900d80cf..92b2d24689a 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -44,7 +44,7 @@ public function testConfigRulesUsingSeparateMethod() new ToolInfo() ); - static::assertArraySubset( + static::assertSame( [ 'cast_spaces' => true, 'braces' => true, @@ -65,7 +65,7 @@ public function testConfigRulesUsingJsonMethod() new ToolInfo() ); - static::assertArraySubset( + static::assertSame( [ 'array_syntax' => [ 'syntax' => 'short', @@ -190,7 +190,7 @@ public function testThatMutatorHasFluentInterface() public function testRegisterCustomFixersWithInvalidArgument() { $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessageRegExp('/^Argument must be an array or a Traversable, got "\w+"\.$/'); + $this->expectExceptionMessageMatches('/^Argument must be an array or a Traversable, got "\w+"\.$/'); $config = new Config(); $config->registerCustomFixers('foo'); @@ -257,7 +257,7 @@ public function testSetInvalidFinder() $config = new Config(); $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessageRegExp('/^Argument must be an array or a Traversable, got "integer"\.$/'); + $this->expectExceptionMessageMatches('/^Argument must be an array or a Traversable, got "integer"\.$/'); $config->setFinder(123); } diff --git a/tests/Console/Command/DescribeCommandTest.php b/tests/Console/Command/DescribeCommandTest.php index 5c9f47eb85a..3fedbc51c71 100644 --- a/tests/Console/Command/DescribeCommandTest.php +++ b/tests/Console/Command/DescribeCommandTest.php @@ -129,7 +129,7 @@ public function testExecuteWithUnknownRuleName() $commandTester = new CommandTester($command); $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessageRegExp('#^Rule "Foo/bar" not found\.$#'); + $this->expectExceptionMessageMatches('#^Rule "Foo/bar" not found\.$#'); $commandTester->execute([ 'command' => $command->getName(), 'name' => 'Foo/bar', @@ -146,7 +146,7 @@ public function testExecuteWithUnknownSetName() $commandTester = new CommandTester($command); $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessageRegExp('#^Set "@NoSuchSet" not found\.$#'); + $this->expectExceptionMessageMatches('#^Set "@NoSuchSet" not found\.$#'); $commandTester->execute([ 'command' => $command->getName(), 'name' => '@NoSuchSet', @@ -163,7 +163,7 @@ public function testExecuteWithoutName() $commandTester = new CommandTester($command); $this->expectException(\RuntimeException::class); - $this->expectExceptionMessageRegExp('/^Not enough arguments( \(missing: "name"\))?\.$/'); + $this->expectExceptionMessageMatches('/^Not enough arguments( \(missing: "name"\))?\.$/'); $commandTester->execute([ 'command' => $command->getName(), ]); @@ -172,7 +172,7 @@ public function testExecuteWithoutName() public function testGetAlternativeSuggestion() { $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessageRegExp('#^Rule "Foo2/bar" not found\. Did you mean "Foo/bar"\?$#'); + $this->expectExceptionMessageMatches('#^Rule "Foo2/bar" not found\. Did you mean "Foo/bar"\?$#'); $this->execute('Foo2/bar', false); } @@ -205,7 +205,7 @@ public function testFixerClassNameIsExposedWhenVerbose() ] ); - static::assertContains(\get_class($mock), $commandTester->getDisplay(true)); + static::assertStringContainsString(\get_class($mock), $commandTester->getDisplay(true)); } /** diff --git a/tests/Console/Command/FixCommandTest.php b/tests/Console/Command/FixCommandTest.php index 2c4f1a164bc..b8fe88c648e 100644 --- a/tests/Console/Command/FixCommandTest.php +++ b/tests/Console/Command/FixCommandTest.php @@ -31,7 +31,7 @@ public function testEmptyRulesValue() $this->expectException( \PhpCsFixer\ConfigurationException\InvalidConfigurationException::class ); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( '#^Empty rules value is not allowed\.$#' ); diff --git a/tests/Console/ConfigurationResolverTest.php b/tests/Console/ConfigurationResolverTest.php index e8166e41d45..14ebecfdbe4 100644 --- a/tests/Console/ConfigurationResolverTest.php +++ b/tests/Console/ConfigurationResolverTest.php @@ -37,7 +37,7 @@ final class ConfigurationResolverTest extends TestCase public function testSetOptionWithUndefinedOption() { $this->expectException(InvalidConfigurationException::class); - $this->expectExceptionMessageRegExp('/^Unknown option name: "foo"\.$/'); + $this->expectExceptionMessageMatches('/^Unknown option name: "foo"\.$/'); $this->createConfigurationResolver(['foo' => 'bar']); } @@ -275,7 +275,7 @@ public function provideResolveConfigFileDefaultCases() public function testResolveConfigFileChooseFileWithInvalidFile() { $this->expectException(InvalidConfigurationException::class); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( '#^The config file: ".+[\/\\\]Fixtures[\/\\\]ConfigurationResolverConfigFile[\/\\\]case_5[\/\\\]\.php_cs\.dist" does not return a "PhpCsFixer\\\ConfigInterface" instance\. Got: "string"\.$#' ); @@ -289,7 +289,7 @@ public function testResolveConfigFileChooseFileWithInvalidFile() public function testResolveConfigFileChooseFileWithInvalidFormat() { $this->expectException(InvalidConfigurationException::class); - $this->expectExceptionMessageRegExp('/^The format "xls" is not defined, supported are "checkstyle", "gitlab", "json", "junit", "txt", "xml"\.$/'); + $this->expectExceptionMessageMatches('/^The format "xls" is not defined, supported are "checkstyle", "gitlab", "json", "junit", "txt", "xml"\.$/'); $dirBase = $this->getFixtureDir(); @@ -301,7 +301,7 @@ public function testResolveConfigFileChooseFileWithInvalidFormat() public function testResolveConfigFileChooseFileWithPathArrayWithoutConfig() { $this->expectException(InvalidConfigurationException::class); - $this->expectExceptionMessageRegExp('/^For multiple paths config parameter is required\.$/'); + $this->expectExceptionMessageMatches('/^For multiple paths config parameter is required\.$/'); $dirBase = $this->getFixtureDir(); @@ -1160,7 +1160,7 @@ public function testResolveUnknownDiffer() ]); $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessageRegExp('#^"diff\-format" must be any of "null", "sbd", "udiff", got "XXX"\.$#'); + $this->expectExceptionMessageMatches('#^"diff\-format" must be any of "null", "sbd", "udiff", got "XXX"\.$#'); $resolver->getDiffer(); } @@ -1210,7 +1210,7 @@ public function testWithEmptyRules() $resolver = $this->createConfigurationResolver(['rules' => '']); $this->expectException(InvalidConfigurationException::class); - $this->expectExceptionMessageRegExp('/^Empty rules value is not allowed\.$/'); + $this->expectExceptionMessageMatches('/^Empty rules value is not allowed\.$/'); $resolver->getRules(); } diff --git a/tests/Console/Output/ErrorOutputTest.php b/tests/Console/Output/ErrorOutputTest.php index 285b0880694..7db85230f88 100644 --- a/tests/Console/Output/ErrorOutputTest.php +++ b/tests/Console/Output/ErrorOutputTest.php @@ -134,13 +134,13 @@ public function testLintingExceptionOutputsAppliedFixersAndDiff() $displayed = $this->readFullStreamOutput($output); - static::assertContains($fixerName, $displayed); - static::assertContains($diffSpecificContext, $displayed); + static::assertStringContainsString($fixerName, $displayed); + static::assertStringContainsString($diffSpecificContext, $displayed); - static::assertContains($noDiffLintFixerName, $displayed); + static::assertStringContainsString($noDiffLintFixerName, $displayed); - static::assertNotContains($invalidErrorFixerName, $displayed); - static::assertNotContains($invalidDiff, $displayed); + static::assertStringNotContainsString($invalidErrorFixerName, $displayed); + static::assertStringNotContainsString($invalidDiff, $displayed); } /** diff --git a/tests/DocBlock/AnnotationTest.php b/tests/DocBlock/AnnotationTest.php index cd885851c57..d091f30f2ca 100644 --- a/tests/DocBlock/AnnotationTest.php +++ b/tests/DocBlock/AnnotationTest.php @@ -460,9 +460,9 @@ public function testSetTypesOnBadTag() public function testGetTagsWithTypes() { $tags = Annotation::getTagsWithTypes(); - static::assertInternalType('array', $tags); + static::assertIsArray($tags); foreach ($tags as $tag) { - static::assertInternalType('string', $tag); + static::assertIsString($tag); static::assertNotEmpty($tag); } } diff --git a/tests/DocBlock/DocBlockTest.php b/tests/DocBlock/DocBlockTest.php index 160753b29c4..194220086b2 100644 --- a/tests/DocBlock/DocBlockTest.php +++ b/tests/DocBlock/DocBlockTest.php @@ -64,7 +64,7 @@ public function testGetLines() { $doc = new DocBlock(self::$sample); - static::assertInternalType('array', $doc->getLines()); + static::assertIsArray($doc->getLines()); static::assertCount(15, $doc->getLines()); foreach ($doc->getLines() as $index => $line) { @@ -79,7 +79,7 @@ public function testGetAnnotations() { $doc = new DocBlock(self::$sample); - static::assertInternalType('array', $doc->getAnnotations()); + static::assertIsArray($doc->getAnnotations()); static::assertCount(5, $doc->getAnnotations()); foreach ($doc->getAnnotations() as $index => $annotations) { @@ -96,7 +96,7 @@ public function testGetAnnotationsOfTypeParam() $annotations = $doc->getAnnotationsOfType('param'); - static::assertInternalType('array', $annotations); + static::assertIsArray($annotations); static::assertCount(3, $annotations); $first = ' * @param string $hello @@ -118,7 +118,7 @@ public function testGetAnnotationsOfTypeThrows() $annotations = $doc->getAnnotationsOfType('throws'); - static::assertInternalType('array', $annotations); + static::assertIsArray($annotations); static::assertCount(1, $annotations); $content = ' * @throws \Exception asdnjkasd @@ -135,7 +135,7 @@ public function testGetAnnotationsOfTypeReturn() $annotations = $doc->getAnnotationsOfType('return'); - static::assertInternalType('array', $annotations); + static::assertIsArray($annotations); static::assertCount(1, $annotations); $content = ' * @return void @@ -150,7 +150,7 @@ public function testGetAnnotationsOfTypeFoo() $annotations = $doc->getAnnotationsOfType('foo'); - static::assertInternalType('array', $annotations); + static::assertIsArray($annotations); static::assertCount(0, $annotations); } diff --git a/tests/Error/ErrorsManagerTest.php b/tests/Error/ErrorsManagerTest.php index bb9b5c2b50f..8f2a71dcaf6 100644 --- a/tests/Error/ErrorsManagerTest.php +++ b/tests/Error/ErrorsManagerTest.php @@ -48,7 +48,7 @@ public function testThatCanReportAndRetrieveInvalidErrors() $errors = $errorsManager->getInvalidErrors(); - static::assertInternalType('array', $errors); + static::assertIsArray($errors); static::assertCount(1, $errors); static::assertSame($error, array_shift($errors)); @@ -71,7 +71,7 @@ public function testThatCanReportAndRetrieveExceptionErrors() $errors = $errorsManager->getExceptionErrors(); - static::assertInternalType('array', $errors); + static::assertIsArray($errors); static::assertCount(1, $errors); static::assertSame($error, array_shift($errors)); @@ -94,7 +94,7 @@ public function testThatCanReportAndRetrieveInvalidFileErrors() $errors = $errorsManager->getLintErrors(); - static::assertInternalType('array', $errors); + static::assertIsArray($errors); static::assertCount(1, $errors); static::assertSame($error, array_shift($errors)); diff --git a/tests/FileReaderTest.php b/tests/FileReaderTest.php index bf00f4b41c1..ec07f63367c 100644 --- a/tests/FileReaderTest.php +++ b/tests/FileReaderTest.php @@ -73,7 +73,7 @@ public function testThrowsExceptionOnFail() $reader = new FileReader(); $this->expectException(\RuntimeException::class); - $this->expectExceptionMessageRegExp('#^Failed to read content from "'.preg_quote($nonExistentFilePath, '#').'.*$#'); + $this->expectExceptionMessageMatches('#^Failed to read content from "'.preg_quote($nonExistentFilePath, '#').'.*$#'); $reader->read($nonExistentFilePath); } diff --git a/tests/FileRemovalTest.php b/tests/FileRemovalTest.php index 7289761e375..26b0dc1aa06 100644 --- a/tests/FileRemovalTest.php +++ b/tests/FileRemovalTest.php @@ -67,7 +67,7 @@ public function testShutdownRemovesObservedFilesSetup() */ public function testShutdownRemovesObservedFiles() { - static::assertFileNotExists(sys_get_temp_dir().'/cs_fixer_foo.php'); + static::assertFileDoesNotExist(sys_get_temp_dir().'/cs_fixer_foo.php'); static::assertFileExists(sys_get_temp_dir().'/cs_fixer_bar.php'); } @@ -82,8 +82,8 @@ public function testCleanRemovesObservedFiles() $fileRemoval->clean(); - static::assertFileNotExists($fs->url().'/foo.php'); - static::assertFileNotExists($fs->url().'/baz.php'); + static::assertFileDoesNotExist($fs->url().'/foo.php'); + static::assertFileDoesNotExist($fs->url().'/baz.php'); static::assertFileExists($fs->url().'/bar.php'); } @@ -98,8 +98,8 @@ public function testDestructRemovesObservedFiles() $fileRemoval->__destruct(); - static::assertFileNotExists($fs->url().'/foo.php'); - static::assertFileNotExists($fs->url().'/baz.php'); + static::assertFileDoesNotExist($fs->url().'/foo.php'); + static::assertFileDoesNotExist($fs->url().'/baz.php'); static::assertFileExists($fs->url().'/bar.php'); } @@ -114,7 +114,7 @@ public function testDeleteObservedFile() $fileRemoval->delete($fs->url().'/foo.php'); - static::assertFileNotExists($fs->url().'/foo.php'); + static::assertFileDoesNotExist($fs->url().'/foo.php'); static::assertFileExists($fs->url().'/baz.php'); } @@ -126,7 +126,7 @@ public function testDeleteNonObservedFile() $fileRemoval->delete($fs->url().'/foo.php'); - static::assertFileNotExists($fs->url().'/foo.php'); + static::assertFileDoesNotExist($fs->url().'/foo.php'); } private function getMockFileSystem() diff --git a/tests/FinderTest.php b/tests/FinderTest.php index ffa1ed95ef2..b4feff9c87f 100644 --- a/tests/FinderTest.php +++ b/tests/FinderTest.php @@ -24,7 +24,7 @@ final class FinderTest extends TestCase public function testThatDefaultFinderDoesNotSpecifyAnyDirectory() { $this->expectException(\LogicException::class); - $this->expectExceptionMessageRegExp('/^You must call (?:the in\(\) method)|(?:one of in\(\) or append\(\)) methods before iterating over a Finder\.$/'); + $this->expectExceptionMessageMatches('/^You must call (?:the in\(\) method)|(?:one of in\(\) or append\(\)) methods before iterating over a Finder\.$/'); $finder = Finder::create(); $finder->getIterator(); diff --git a/tests/Fixer/Alias/NoMixedEchoPrintFixerTest.php b/tests/Fixer/Alias/NoMixedEchoPrintFixerTest.php index ef9ae266a8d..e5f24cfd53f 100644 --- a/tests/Fixer/Alias/NoMixedEchoPrintFixerTest.php +++ b/tests/Fixer/Alias/NoMixedEchoPrintFixerTest.php @@ -300,7 +300,7 @@ public function testDefaultConfig() public function testWrongConfig($wrongConfig, $expectedMessage) { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp($expectedMessage); + $this->expectExceptionMessageMatches($expectedMessage); $this->fixer->configure($wrongConfig); } diff --git a/tests/Fixer/Alias/RandomApiMigrationFixerTest.php b/tests/Fixer/Alias/RandomApiMigrationFixerTest.php index 0c28c7af0b7..730168c877c 100644 --- a/tests/Fixer/Alias/RandomApiMigrationFixerTest.php +++ b/tests/Fixer/Alias/RandomApiMigrationFixerTest.php @@ -27,7 +27,7 @@ final class RandomApiMigrationFixerTest extends AbstractFixerTestCase public function testConfigureCheckSearchFunction() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[random_api_migration\] Invalid configuration: Function "is_null" is not handled by the fixer\.$#'); + $this->expectExceptionMessageMatches('#^\[random_api_migration\] Invalid configuration: Function "is_null" is not handled by the fixer\.$#'); $this->fixer->configure(['replacements' => ['is_null' => 'random_int']]); } @@ -35,7 +35,7 @@ public function testConfigureCheckSearchFunction() public function testConfigureCheckReplacementType() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[random_api_migration\] Invalid configuration: Replacement for function "rand" must be a string, "NULL" given\.$#'); + $this->expectExceptionMessageMatches('#^\[random_api_migration\] Invalid configuration: Replacement for function "rand" must be a string, "NULL" given\.$#'); $this->fixer->configure(['replacements' => ['rand' => null]]); } diff --git a/tests/Fixer/ArrayNotation/ArraySyntaxFixerTest.php b/tests/Fixer/ArrayNotation/ArraySyntaxFixerTest.php index 9a29cc5c0ad..d058715b89a 100644 --- a/tests/Fixer/ArrayNotation/ArraySyntaxFixerTest.php +++ b/tests/Fixer/ArrayNotation/ArraySyntaxFixerTest.php @@ -28,7 +28,7 @@ final class ArraySyntaxFixerTest extends AbstractFixerTestCase public function testInvalidConfiguration() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[array_syntax\] Invalid configuration: The option "a" does not exist\. Defined options are: "syntax"\.$#'); + $this->expectExceptionMessageMatches('#^\[array_syntax\] Invalid configuration: The option "a" does not exist\. Defined options are: "syntax"\.$#'); $this->fixer->configure(['a' => 1]); } diff --git a/tests/Fixer/Basic/BracesFixerTest.php b/tests/Fixer/Basic/BracesFixerTest.php index e61c0446c9a..92b4f3a1540 100644 --- a/tests/Fixer/Basic/BracesFixerTest.php +++ b/tests/Fixer/Basic/BracesFixerTest.php @@ -31,7 +31,7 @@ final class BracesFixerTest extends AbstractFixerTestCase public function testInvalidConfigurationClassyConstructs() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[braces\] Invalid configuration: The option "position_after_functions_and_oop_constructs" with value "neither" is invalid\. Accepted values are: "next", "same"\.$#'); + $this->expectExceptionMessageMatches('#^\[braces\] Invalid configuration: The option "position_after_functions_and_oop_constructs" with value "neither" is invalid\. Accepted values are: "next", "same"\.$#'); $this->fixer->configure(['position_after_functions_and_oop_constructs' => 'neither']); } diff --git a/tests/Fixer/Basic/NonPrintableCharacterFixerTest.php b/tests/Fixer/Basic/NonPrintableCharacterFixerTest.php index ed7e7cb756f..288863629eb 100644 --- a/tests/Fixer/Basic/NonPrintableCharacterFixerTest.php +++ b/tests/Fixer/Basic/NonPrintableCharacterFixerTest.php @@ -303,7 +303,7 @@ function f(string $p) public function testFixWithEscapeSequencesInStringsLowerThanPhp70() { $this->expectException(InvalidForEnvFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[non_printable_character\] Invalid configuration for env: Escape sequences require PHP 7\.0\+\.$/'); + $this->expectExceptionMessageMatches('/^\[non_printable_character\] Invalid configuration for env: Escape sequences require PHP 7\.0\+\.$/'); $this->fixer->configure([ 'use_escape_sequences_in_strings' => true, diff --git a/tests/Fixer/CastNotation/CastSpacesFixerTest.php b/tests/Fixer/CastNotation/CastSpacesFixerTest.php index 95f527e6d9b..0c03b46442e 100644 --- a/tests/Fixer/CastNotation/CastSpacesFixerTest.php +++ b/tests/Fixer/CastNotation/CastSpacesFixerTest.php @@ -24,7 +24,7 @@ final class CastSpacesFixerTest extends AbstractFixerTestCase public function testInvalidConfigMissingKey() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[cast_spaces\] Invalid configuration: The option "a" does not exist\. Defined options are: "space"\.$#'); + $this->expectExceptionMessageMatches('#^\[cast_spaces\] Invalid configuration: The option "a" does not exist\. Defined options are: "space"\.$#'); $this->fixer->configure(['a' => 1]); } @@ -32,7 +32,7 @@ public function testInvalidConfigMissingKey() public function testInvalidConfigValue() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[cast_spaces\] Invalid configuration: The option "space" with value "double" is invalid\. Accepted values are: "none", "single"\.$#'); + $this->expectExceptionMessageMatches('#^\[cast_spaces\] Invalid configuration: The option "space" with value "double" is invalid\. Accepted values are: "none", "single"\.$#'); $this->fixer->configure(['space' => 'double']); } diff --git a/tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php b/tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php index d126a93042b..6ee8787fd7b 100644 --- a/tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php +++ b/tests/Fixer/ClassNotation/ClassDefinitionFixerTest.php @@ -134,7 +134,7 @@ public function testFixingTraits($expected, $input) public function testInvalidConfigurationKey() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( '/^\[class_definition\] Invalid configuration: The option "a" does not exist\. Defined options are: "multi_line_extends_each_single_line", "single_item_single_line", "single_line"\.$/' ); @@ -145,7 +145,7 @@ public function testInvalidConfigurationKey() public function testInvalidConfigurationValueType() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( '/^\[class_definition\] Invalid configuration: The option "single_line" with value "z" is expected to be of type "bool", but is of type "string"\.$/' ); diff --git a/tests/Fixer/ClassNotation/FinalInternalClassFixerTest.php b/tests/Fixer/ClassNotation/FinalInternalClassFixerTest.php index d87a1970286..d3a70a5dc56 100644 --- a/tests/Fixer/ClassNotation/FinalInternalClassFixerTest.php +++ b/tests/Fixer/ClassNotation/FinalInternalClassFixerTest.php @@ -288,7 +288,7 @@ public function provideAnonymousClassesCases() public function testConfigureSameAnnotationInBothLists() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( sprintf('#^%s$#', preg_quote('[final_internal_class] Annotation cannot be used in both the include and exclude list, got duplicates: "internal123".', '#')) ); diff --git a/tests/Fixer/ClassNotation/OrderedClassElementsFixerTest.php b/tests/Fixer/ClassNotation/OrderedClassElementsFixerTest.php index 6594d878673..ac737398224 100644 --- a/tests/Fixer/ClassNotation/OrderedClassElementsFixerTest.php +++ b/tests/Fixer/ClassNotation/OrderedClassElementsFixerTest.php @@ -884,7 +884,7 @@ class Foo { public function testWrongConfig() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[ordered_class_elements\] Invalid configuration: The option "order" .*\.$/'); + $this->expectExceptionMessageMatches('/^\[ordered_class_elements\] Invalid configuration: The option "order" .*\.$/'); $this->fixer->configure(['order' => ['foo']]); } diff --git a/tests/Fixer/ClassNotation/SingleClassElementPerStatementFixerTest.php b/tests/Fixer/ClassNotation/SingleClassElementPerStatementFixerTest.php index 4518e644bf0..63c8954cb6d 100644 --- a/tests/Fixer/ClassNotation/SingleClassElementPerStatementFixerTest.php +++ b/tests/Fixer/ClassNotation/SingleClassElementPerStatementFixerTest.php @@ -710,7 +710,7 @@ class Foo public function testWrongConfig() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[single_class_element_per_statement\] Invalid configuration: The option "elements" .*\.$/'); + $this->expectExceptionMessageMatches('/^\[single_class_element_per_statement\] Invalid configuration: The option "elements" .*\.$/'); $this->fixer->configure(['elements' => ['foo']]); } diff --git a/tests/Fixer/ClassNotation/VisibilityRequiredFixerTest.php b/tests/Fixer/ClassNotation/VisibilityRequiredFixerTest.php index 467169b2613..298c4580153 100644 --- a/tests/Fixer/ClassNotation/VisibilityRequiredFixerTest.php +++ b/tests/Fixer/ClassNotation/VisibilityRequiredFixerTest.php @@ -538,7 +538,7 @@ public function testIgnoreConstants() public function testInvalidConfigurationType() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[visibility_required\] Invalid configuration: The option "elements" .*\.$/'); + $this->expectExceptionMessageMatches('/^\[visibility_required\] Invalid configuration: The option "elements" .*\.$/'); $this->fixer->configure(['elements' => [null]]); } @@ -546,7 +546,7 @@ public function testInvalidConfigurationType() public function testInvalidConfigurationValue() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[visibility_required\] Invalid configuration: The option "elements" .*\.$/'); + $this->expectExceptionMessageMatches('/^\[visibility_required\] Invalid configuration: The option "elements" .*\.$/'); $this->fixer->configure(['elements' => ['_unknown_']]); } diff --git a/tests/Fixer/Comment/HeaderCommentFixerTest.php b/tests/Fixer/Comment/HeaderCommentFixerTest.php index 8e9e845002f..77dc1c75f5c 100644 --- a/tests/Fixer/Comment/HeaderCommentFixerTest.php +++ b/tests/Fixer/Comment/HeaderCommentFixerTest.php @@ -587,7 +587,7 @@ public function testLegacyMisconfiguration() public function testMisconfiguration($configuration, $exceptionMessage) { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp("#^\\[header_comment\\] {$exceptionMessage}$#"); + $this->expectExceptionMessageMatches("#^\\[header_comment\\] {$exceptionMessage}$#"); $this->configureFixerWithAliasedOptions($configuration); } @@ -773,7 +773,7 @@ public function testConfigurationUpdatedWithWhitespsacesConfig() public function testInvalidHeaderConfiguration() { $this->expectException(InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[header_comment\] Cannot use \'\*/\' in header\.$#'); + $this->expectExceptionMessageMatches('#^\[header_comment\] Cannot use \'\*/\' in header\.$#'); $this->fixer->configure([ 'header' => '/** test */', diff --git a/tests/Fixer/ControlStructure/NoBreakCommentFixerTest.php b/tests/Fixer/ControlStructure/NoBreakCommentFixerTest.php index 8c7923a50ca..99193615a11 100644 --- a/tests/Fixer/ControlStructure/NoBreakCommentFixerTest.php +++ b/tests/Fixer/ControlStructure/NoBreakCommentFixerTest.php @@ -1147,7 +1147,7 @@ public function testFixWithCommentTextWithTrailingSpaces() public function testFixWithCommentTextContainingNewLines($text) { $this->expectException(InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[no_break_comment\] Invalid configuration: The comment text must not contain new lines\.$/'); + $this->expectExceptionMessageMatches('/^\[no_break_comment\] Invalid configuration: The comment text must not contain new lines\.$/'); $this->fixer->configure([ 'comment_text' => $text, @@ -1166,7 +1166,7 @@ public function provideFixWithCommentTextContainingNewLinesCases() public function testConfigureWithInvalidOptions() { $this->expectException(InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[no_break_comment\] Invalid configuration: The option "foo" does not exist\. Defined options are: "comment_text"\.$/'); + $this->expectExceptionMessageMatches('/^\[no_break_comment\] Invalid configuration: The option "foo" does not exist\. Defined options are: "comment_text"\.$/'); $this->fixer->configure(['foo' => true]); } diff --git a/tests/Fixer/ControlStructure/YodaStyleFixerTest.php b/tests/Fixer/ControlStructure/YodaStyleFixerTest.php index 3b5a9486268..45f6eeda9a3 100644 --- a/tests/Fixer/ControlStructure/YodaStyleFixerTest.php +++ b/tests/Fixer/ControlStructure/YodaStyleFixerTest.php @@ -743,7 +743,7 @@ public function testComplexConfiguration() public function testInvalidConfig(array $config, $expectedMessage) { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp("#^\\[{$this->fixer->getName()}\\] {$expectedMessage}$#"); + $this->expectExceptionMessageMatches("#^\\[{$this->fixer->getName()}\\] {$expectedMessage}$#"); $this->fixer->configure($config); } diff --git a/tests/Fixer/FunctionNotation/FunctionDeclarationFixerTest.php b/tests/Fixer/FunctionNotation/FunctionDeclarationFixerTest.php index f3d63d3972f..8b472be2b38 100644 --- a/tests/Fixer/FunctionNotation/FunctionDeclarationFixerTest.php +++ b/tests/Fixer/FunctionNotation/FunctionDeclarationFixerTest.php @@ -29,7 +29,7 @@ final class FunctionDeclarationFixerTest extends AbstractFixerTestCase public function testInvalidConfigurationClosureFunctionSpacing() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( '#^\[function_declaration\] Invalid configuration: The option "closure_function_spacing" with value "neither" is invalid\. Accepted values are: "none", "one"\.$#' ); diff --git a/tests/Fixer/FunctionNotation/NativeFunctionInvocationFixerTest.php b/tests/Fixer/FunctionNotation/NativeFunctionInvocationFixerTest.php index d9a6d27270c..c155e53e9ba 100644 --- a/tests/Fixer/FunctionNotation/NativeFunctionInvocationFixerTest.php +++ b/tests/Fixer/FunctionNotation/NativeFunctionInvocationFixerTest.php @@ -91,7 +91,7 @@ public function testConfigureIncludeSets( ) { if (null !== $expectedExceptionClass) { $this->expectException($expectedExceptionClass); - $this->expectExceptionMessageRegExp(sprintf('#^%s$#', preg_quote($expectedExceptionMessage, '#'))); + $this->expectExceptionMessageMatches(sprintf('#^%s$#', preg_quote($expectedExceptionMessage, '#'))); } $this->fixer->configure(['include' => $include]); diff --git a/tests/Fixer/FunctionNotation/ReturnTypeDeclarationFixerTest.php b/tests/Fixer/FunctionNotation/ReturnTypeDeclarationFixerTest.php index 04508195280..209d4e59eca 100644 --- a/tests/Fixer/FunctionNotation/ReturnTypeDeclarationFixerTest.php +++ b/tests/Fixer/FunctionNotation/ReturnTypeDeclarationFixerTest.php @@ -27,7 +27,7 @@ final class ReturnTypeDeclarationFixerTest extends AbstractFixerTestCase public function testInvalidConfiguration() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( '#^\[return_type_declaration\] Invalid configuration: The option "s" does not exist\. (Known|Defined) options are: "space_before"\.$#' ); diff --git a/tests/Fixer/LanguageConstruct/FunctionToConstantFixerTest.php b/tests/Fixer/LanguageConstruct/FunctionToConstantFixerTest.php index 2f539a2134e..28bb62d5ffe 100644 --- a/tests/Fixer/LanguageConstruct/FunctionToConstantFixerTest.php +++ b/tests/Fixer/LanguageConstruct/FunctionToConstantFixerTest.php @@ -266,7 +266,7 @@ class Foo{ public function Bar(){ echo $reflection = new \ReflectionClass(get_cl public function testInvalidConfigurationKeys(array $config) { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[function_to_constant\] Invalid configuration: The option "functions" with value array is invalid\.$#'); + $this->expectExceptionMessageMatches('#^\[function_to_constant\] Invalid configuration: The option "functions" with value array is invalid\.$#'); $this->fixer->configure($config); } @@ -283,7 +283,7 @@ public function provideInvalidConfigurationKeysCases() public function testInvalidConfigurationValue() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[function_to_constant\] Invalid configuration: The option "0" does not exist\. Defined options are: "functions"\.$#'); + $this->expectExceptionMessageMatches('#^\[function_to_constant\] Invalid configuration: The option "0" does not exist\. Defined options are: "functions"\.$#'); $this->fixer->configure(['pi123']); } diff --git a/tests/Fixer/LanguageConstruct/IsNullFixerTest.php b/tests/Fixer/LanguageConstruct/IsNullFixerTest.php index 88eb1335ffd..68d9693653a 100644 --- a/tests/Fixer/LanguageConstruct/IsNullFixerTest.php +++ b/tests/Fixer/LanguageConstruct/IsNullFixerTest.php @@ -40,7 +40,7 @@ public function testConfigurationWrongOption() public function testConfigurationWrongValue() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[is_null\] Invalid configuration: The option "use_yoda_style" with value -1 is expected to be of type "bool", but is of type "(int|integer)"\.$#'); + $this->expectExceptionMessageMatches('#^\[is_null\] Invalid configuration: The option "use_yoda_style" with value -1 is expected to be of type "bool", but is of type "(int|integer)"\.$#'); $this->fixer->configure(['use_yoda_style' => -1]); } diff --git a/tests/Fixer/Operator/BinaryOperatorSpacesFixerTest.php b/tests/Fixer/Operator/BinaryOperatorSpacesFixerTest.php index 7f58ea3ef9e..66e455b474a 100644 --- a/tests/Fixer/Operator/BinaryOperatorSpacesFixerTest.php +++ b/tests/Fixer/Operator/BinaryOperatorSpacesFixerTest.php @@ -797,7 +797,7 @@ function b( public function testWrongConfigItem() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( '/^\[binary_operator_spaces\] Invalid configuration: The option "foo" does not exist\. Defined options are: "align_double_arrow", "align_equals", "default", "operators"\.$/' ); @@ -807,7 +807,7 @@ public function testWrongConfigItem() public function testWrongConfigOldValue() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( '/^\[binary_operator_spaces\] Invalid configuration: The option "align_double_arrow" with value 123 is invalid\. Accepted values are: true, false, null\.$/' ); @@ -899,7 +899,7 @@ public function testWrongConfigOldDeprecated5() public function testWrongConfigOldAndNewMixed() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[binary_operator_spaces\] Mixing old configuration with new configuration is not allowed\.$/'); + $this->expectExceptionMessageMatches('/^\[binary_operator_spaces\] Mixing old configuration with new configuration is not allowed\.$/'); $this->fixer->configure([ 'align_double_arrow' => true, @@ -910,7 +910,7 @@ public function testWrongConfigOldAndNewMixed() public function testWrongConfigTypeForOperators() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( '/^\[binary_operator_spaces\] Invalid configuration: The option "operators" with value true is expected to be of type "array", but is of type "(bool|boolean)"\.$/' ); @@ -920,7 +920,7 @@ public function testWrongConfigTypeForOperators() public function testWrongConfigTypeForOperatorsKey() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[binary_operator_spaces\] Invalid configuration: Unexpected "operators" key, expected any of ".*", got "integer#123"\.$/'); + $this->expectExceptionMessageMatches('/^\[binary_operator_spaces\] Invalid configuration: Unexpected "operators" key, expected any of ".*", got "integer#123"\.$/'); $this->fixer->configure(['operators' => [123 => 1]]); } @@ -928,7 +928,7 @@ public function testWrongConfigTypeForOperatorsKey() public function testWrongConfigTypeForOperatorsKeyValue() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[binary_operator_spaces\] Invalid configuration: Unexpected value for operator "\+", expected any of ".*", got "string#abc"\.$/'); + $this->expectExceptionMessageMatches('/^\[binary_operator_spaces\] Invalid configuration: Unexpected value for operator "\+", expected any of ".*", got "string#abc"\.$/'); $this->fixer->configure(['operators' => ['+' => 'abc']]); } diff --git a/tests/Fixer/Operator/ConcatSpaceFixerTest.php b/tests/Fixer/Operator/ConcatSpaceFixerTest.php index 6a6c3c36d8a..2092b6152f8 100644 --- a/tests/Fixer/Operator/ConcatSpaceFixerTest.php +++ b/tests/Fixer/Operator/ConcatSpaceFixerTest.php @@ -27,7 +27,7 @@ final class ConcatSpaceFixerTest extends AbstractFixerTestCase public function testInvalidConfigMissingKey() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[concat_space\] Invalid configuration: The option "a" does not exist\. Defined options are: "spacing"\.$#'); + $this->expectExceptionMessageMatches('#^\[concat_space\] Invalid configuration: The option "a" does not exist\. Defined options are: "spacing"\.$#'); $this->fixer->configure(['a' => 1]); } @@ -35,7 +35,7 @@ public function testInvalidConfigMissingKey() public function testInvalidConfigValue() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[concat_space\] Invalid configuration: The option "spacing" with value "tabs" is invalid\. Accepted values are: "one", "none"\.$#'); + $this->expectExceptionMessageMatches('#^\[concat_space\] Invalid configuration: The option "spacing" with value "tabs" is invalid\. Accepted values are: "one", "none"\.$#'); $this->fixer->configure(['spacing' => 'tabs']); } diff --git a/tests/Fixer/PhpUnit/PhpUnitConstructFixerTest.php b/tests/Fixer/PhpUnit/PhpUnitConstructFixerTest.php index 22403475c22..7e93e22fc42 100644 --- a/tests/Fixer/PhpUnit/PhpUnitConstructFixerTest.php +++ b/tests/Fixer/PhpUnit/PhpUnitConstructFixerTest.php @@ -179,7 +179,7 @@ class FooTest3 extends PHPUnit_Framework_TestCase { public function testFoo(){ $ public function testInvalidConfig() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[php_unit_construct\] Invalid configuration: The option "assertions" .*\.$/'); + $this->expectExceptionMessageMatches('/^\[php_unit_construct\] Invalid configuration: The option "assertions" .*\.$/'); $this->fixer->configure(['assertions' => ['__TEST__']]); } diff --git a/tests/Fixer/PhpUnit/PhpUnitDedicateAssertFixerTest.php b/tests/Fixer/PhpUnit/PhpUnitDedicateAssertFixerTest.php index a02274c5870..6530e8902c9 100644 --- a/tests/Fixer/PhpUnit/PhpUnitDedicateAssertFixerTest.php +++ b/tests/Fixer/PhpUnit/PhpUnitDedicateAssertFixerTest.php @@ -342,7 +342,7 @@ public function testConfig() public function testInvalidConfig() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[php_unit_dedicate_assert\] Invalid configuration: The option "target" .*\.$/'); + $this->expectExceptionMessageMatches('/^\[php_unit_dedicate_assert\] Invalid configuration: The option "target" .*\.$/'); $this->fixer->configure(['target' => '_unknown_']); } diff --git a/tests/Fixer/PhpUnit/PhpUnitNamespacedFixerTest.php b/tests/Fixer/PhpUnit/PhpUnitNamespacedFixerTest.php index b9a7bc9a4aa..fdc8e235ef4 100644 --- a/tests/Fixer/PhpUnit/PhpUnitNamespacedFixerTest.php +++ b/tests/Fixer/PhpUnit/PhpUnitNamespacedFixerTest.php @@ -253,7 +253,7 @@ public function testClassIsFixed($class) $this->fixer->fix($this->getTestFile(), $tokens); static::assertTrue($tokens->isChanged()); - static::assertNotContains('_', $tokens->generateCode()); + static::assertStringNotContainsString('_', $tokens->generateCode()); } public static function provideClassIsFixedCases() diff --git a/tests/Fixer/PhpUnit/PhpUnitStrictFixerTest.php b/tests/Fixer/PhpUnit/PhpUnitStrictFixerTest.php index f87d1911464..7faf5825a7e 100644 --- a/tests/Fixer/PhpUnit/PhpUnitStrictFixerTest.php +++ b/tests/Fixer/PhpUnit/PhpUnitStrictFixerTest.php @@ -139,7 +139,7 @@ public function provideTestNoFixWithWrongNumberOfArgumentsCases() public function testInvalidConfig() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[php_unit_strict\] Invalid configuration: The option "assertions" .*\.$/'); + $this->expectExceptionMessageMatches('/^\[php_unit_strict\] Invalid configuration: The option "assertions" .*\.$/'); $this->fixer->configure(['assertions' => ['__TEST__']]); } diff --git a/tests/Fixer/PhpUnit/PhpUnitTestCaseStaticMethodCallsFixerTest.php b/tests/Fixer/PhpUnit/PhpUnitTestCaseStaticMethodCallsFixerTest.php index 96fa9b15e7a..4b178326cbc 100644 --- a/tests/Fixer/PhpUnit/PhpUnitTestCaseStaticMethodCallsFixerTest.php +++ b/tests/Fixer/PhpUnit/PhpUnitTestCaseStaticMethodCallsFixerTest.php @@ -47,7 +47,7 @@ public function testFixerContainsAllPhpunitStaticMethodsInItsList() public function testWrongConfigTypeForMethodsKey() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/Unexpected "methods" key, expected any of ".*", got "integer#123"\.$/'); + $this->expectExceptionMessageMatches('/Unexpected "methods" key, expected any of ".*", got "integer#123"\.$/'); $this->fixer->configure(['methods' => [123 => 1]]); } @@ -55,7 +55,7 @@ public function testWrongConfigTypeForMethodsKey() public function testWrongConfigTypeForMethodsValue() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/Unexpected value for method "assertSame", expected any of ".*", got "integer#123"\.$/'); + $this->expectExceptionMessageMatches('/Unexpected value for method "assertSame", expected any of ".*", got "integer#123"\.$/'); $this->fixer->configure(['methods' => ['assertSame' => 123]]); } diff --git a/tests/Fixer/Phpdoc/PhpdocAddMissingParamAnnotationFixerTest.php b/tests/Fixer/Phpdoc/PhpdocAddMissingParamAnnotationFixerTest.php index 915472f387c..908493e22ab 100644 --- a/tests/Fixer/Phpdoc/PhpdocAddMissingParamAnnotationFixerTest.php +++ b/tests/Fixer/Phpdoc/PhpdocAddMissingParamAnnotationFixerTest.php @@ -48,7 +48,7 @@ public function testConfigureRejectsUnknownConfigurationKey() public function testConfigureRejectsInvalidConfigurationValue($value, $expectedMessage) { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidConfigurationException::class); - $this->expectExceptionMessageRegExp($expectedMessage); + $this->expectExceptionMessageMatches($expectedMessage); $this->fixer->configure([ 'only_untyped' => $value, diff --git a/tests/Fixer/Phpdoc/PhpdocNoAliasTagFixerTest.php b/tests/Fixer/Phpdoc/PhpdocNoAliasTagFixerTest.php index 273912aa676..4e7239f8467 100644 --- a/tests/Fixer/Phpdoc/PhpdocNoAliasTagFixerTest.php +++ b/tests/Fixer/Phpdoc/PhpdocNoAliasTagFixerTest.php @@ -28,7 +28,7 @@ final class PhpdocNoAliasTagFixerTest extends AbstractFixerTestCase public function testInvalidConfigCase1() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[phpdoc_no_alias_tag\] Invalid configuration: Tag to replace must be a string\.$#'); + $this->expectExceptionMessageMatches('#^\[phpdoc_no_alias_tag\] Invalid configuration: Tag to replace must be a string\.$#'); $this->fixer->configure(['replacements' => [1 => 'abc']]); } @@ -36,7 +36,7 @@ public function testInvalidConfigCase1() public function testInvalidConfigCase2() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[phpdoc_no_alias_tag\] Invalid configuration: Tag to replace to from "a" must be a string\.$#'); + $this->expectExceptionMessageMatches('#^\[phpdoc_no_alias_tag\] Invalid configuration: Tag to replace to from "a" must be a string\.$#'); $this->fixer->configure(['replacements' => ['a' => null]]); } @@ -44,7 +44,7 @@ public function testInvalidConfigCase2() public function testInvalidConfigCase3() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[phpdoc_no_alias_tag\] Invalid configuration: Tag "see" cannot be replaced by invalid tag "link\*\/"\.$#'); + $this->expectExceptionMessageMatches('#^\[phpdoc_no_alias_tag\] Invalid configuration: Tag "see" cannot be replaced by invalid tag "link\*\/"\.$#'); $this->fixer->configure(['replacements' => ['see' => 'link*/']]); } @@ -52,7 +52,7 @@ public function testInvalidConfigCase3() public function testInvalidConfigCase4() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[phpdoc_no_alias_tag\] Invalid configuration: Cannot change tag "link" to tag "see", as the tag "see" is configured to be replaced to "link"\.$#'); + $this->expectExceptionMessageMatches('#^\[phpdoc_no_alias_tag\] Invalid configuration: Cannot change tag "link" to tag "see", as the tag "see" is configured to be replaced to "link"\.$#'); $this->fixer->configure(['replacements' => [ 'link' => 'see', @@ -64,7 +64,7 @@ public function testInvalidConfigCase4() public function testInvalidConfigCase5() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[phpdoc_no_alias_tag\] Invalid configuration: Cannot change tag "b" to tag "see", as the tag "see" is configured to be replaced to "link"\.$#'); + $this->expectExceptionMessageMatches('#^\[phpdoc_no_alias_tag\] Invalid configuration: Cannot change tag "b" to tag "see", as the tag "see" is configured to be replaced to "link"\.$#'); $this->fixer->configure(['replacements' => [ 'b' => 'see', @@ -76,7 +76,7 @@ public function testInvalidConfigCase5() public function testInvalidConfigCase6() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('#^\[phpdoc_no_alias_tag\] Invalid configuration: Cannot change tag "see" to tag "link", as the tag "link" is configured to be replaced to "b"\.$#'); + $this->expectExceptionMessageMatches('#^\[phpdoc_no_alias_tag\] Invalid configuration: Cannot change tag "see" to tag "link", as the tag "link" is configured to be replaced to "b"\.$#'); $this->fixer->configure(['replacements' => [ 'see' => 'link', diff --git a/tests/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixerTest.php b/tests/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixerTest.php index 2bf2993bf03..552db3871d4 100644 --- a/tests/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixerTest.php +++ b/tests/Fixer/Phpdoc/PhpdocReturnSelfReferenceFixerTest.php @@ -176,7 +176,7 @@ public function provideGeneratedFixCases() public function testInvalidConfiguration(array $configuration, $message) { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp(sprintf('/^\[phpdoc_return_self_reference\] %s$/', preg_quote($message, '/'))); + $this->expectExceptionMessageMatches(sprintf('/^\[phpdoc_return_self_reference\] %s$/', preg_quote($message, '/'))); $this->fixer->configure($configuration); } diff --git a/tests/Fixer/Phpdoc/PhpdocTypesFixerTest.php b/tests/Fixer/Phpdoc/PhpdocTypesFixerTest.php index a2b547b0264..56331fd01bc 100644 --- a/tests/Fixer/Phpdoc/PhpdocTypesFixerTest.php +++ b/tests/Fixer/Phpdoc/PhpdocTypesFixerTest.php @@ -255,7 +255,7 @@ public function testWithConfig() public function testWrongConfig() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[phpdoc_types\] Invalid configuration: The option "groups" .*\.$/'); + $this->expectExceptionMessageMatches('/^\[phpdoc_types\] Invalid configuration: The option "groups" .*\.$/'); $this->fixer->configure(['groups' => ['__TEST__']]); } diff --git a/tests/Fixer/Whitespace/NoExtraBlankLinesFixerTest.php b/tests/Fixer/Whitespace/NoExtraBlankLinesFixerTest.php index 9ebfbbe5832..8a9be6bc52b 100644 --- a/tests/Fixer/Whitespace/NoExtraBlankLinesFixerTest.php +++ b/tests/Fixer/Whitespace/NoExtraBlankLinesFixerTest.php @@ -487,7 +487,7 @@ public function provideLineBreakCases() public function testWrongConfig() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[no_extra_blank_lines\] Invalid configuration: The option "tokens" .*\.$/'); + $this->expectExceptionMessageMatches('/^\[no_extra_blank_lines\] Invalid configuration: The option "tokens" .*\.$/'); $this->fixer->configure(['tokens' => ['__TEST__']]); } diff --git a/tests/Fixer/Whitespace/NoSpacesAroundOffsetFixerTest.php b/tests/Fixer/Whitespace/NoSpacesAroundOffsetFixerTest.php index 606a512b257..881de42ae18 100644 --- a/tests/Fixer/Whitespace/NoSpacesAroundOffsetFixerTest.php +++ b/tests/Fixer/Whitespace/NoSpacesAroundOffsetFixerTest.php @@ -387,7 +387,7 @@ public function provideConfigurationCases() public function testWrongConfig() { $this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class); - $this->expectExceptionMessageRegExp('/^\[no_spaces_around_offset\] Invalid configuration: The option "positions" .*\.$/'); + $this->expectExceptionMessageMatches('/^\[no_spaces_around_offset\] Invalid configuration: The option "positions" .*\.$/'); $this->fixer->configure(['positions' => ['foo']]); } diff --git a/tests/FixerConfiguration/AliasedFixerOptionTest.php b/tests/FixerConfiguration/AliasedFixerOptionTest.php index c10dcf76475..fcc1b96f67f 100644 --- a/tests/FixerConfiguration/AliasedFixerOptionTest.php +++ b/tests/FixerConfiguration/AliasedFixerOptionTest.php @@ -164,7 +164,7 @@ public function testGetAllowedValuesClosure() { $option = new AliasedFixerOption(new FixerOption('foo', 'Bar.', true, null, null, [static function () {}]), 'baz'); $allowedTypes = $option->getAllowedValues(); - static::assertInternalType('array', $allowedTypes); + static::assertIsArray($allowedTypes); static::assertCount(1, $allowedTypes); static::assertArrayHasKey(0, $allowedTypes); static::assertInstanceOf(\Closure::class, $allowedTypes[0]); diff --git a/tests/FixerConfiguration/AllowedValueSubsetTest.php b/tests/FixerConfiguration/AllowedValueSubsetTest.php index 75a3c7fd457..b4a54cb0ee8 100644 --- a/tests/FixerConfiguration/AllowedValueSubsetTest.php +++ b/tests/FixerConfiguration/AllowedValueSubsetTest.php @@ -24,7 +24,7 @@ final class AllowedValueSubsetTest extends TestCase { public function testConstructor() { - static::assertInternalType('callable', new AllowedValueSubset(['foo', 'bar'])); + static::assertIsCallable(new AllowedValueSubset(['foo', 'bar'])); } /** diff --git a/tests/FixerConfiguration/FixerOptionTest.php b/tests/FixerConfiguration/FixerOptionTest.php index acf3870c30a..70ce82b3897 100644 --- a/tests/FixerConfiguration/FixerOptionTest.php +++ b/tests/FixerConfiguration/FixerOptionTest.php @@ -83,7 +83,7 @@ public function testGetAllowedValues() $option = new FixerOption('foo', 'Bar.', true, null, null, [static function () {}]); $allowedTypes = $option->getAllowedValues(); - static::assertInternalType('array', $allowedTypes); + static::assertIsArray($allowedTypes); static::assertCount(1, $allowedTypes); static::assertArrayHasKey(0, $allowedTypes); static::assertInstanceOf(\Closure::class, $allowedTypes[0]); diff --git a/tests/FixerFactoryTest.php b/tests/FixerFactoryTest.php index ae75abc14eb..abc0e8c8b66 100644 --- a/tests/FixerFactoryTest.php +++ b/tests/FixerFactoryTest.php @@ -208,7 +208,7 @@ public function testHasRuleWithChangedRuleSet() public function testConflictingFixers(RuleSet $ruleSet) { $this->expectException(\UnexpectedValueException::class); - $this->expectExceptionMessageRegExp('#^Rule contains conflicting fixers:\n#'); + $this->expectExceptionMessageMatches('#^Rule contains conflicting fixers:\n#'); FixerFactory::create()->registerBuiltInFixers()->useRuleSet($ruleSet); } diff --git a/tests/Indicator/PhpUnitTestCaseIndicatorTest.php b/tests/Indicator/PhpUnitTestCaseIndicatorTest.php index 3a174398701..5233c2b2493 100644 --- a/tests/Indicator/PhpUnitTestCaseIndicatorTest.php +++ b/tests/Indicator/PhpUnitTestCaseIndicatorTest.php @@ -126,7 +126,7 @@ public function testThrowsExceptionIfNotClass() $tokens = Tokens::fromCode('expectException(\LogicException::class); - $this->expectExceptionMessageRegExp('/^No "T_CLASS" at given index 1, got "T_ECHO"\.$/'); + $this->expectExceptionMessageMatches('/^No "T_CLASS" at given index 1, got "T_ECHO"\.$/'); $this->indicator->isPhpUnitClass($tokens, 1); } diff --git a/tests/PregTest.php b/tests/PregTest.php index b9030274ded..12efd89c626 100644 --- a/tests/PregTest.php +++ b/tests/PregTest.php @@ -180,7 +180,7 @@ public function testMatchAll($pattern, $subject) public function testReplaceFailing() { $this->expectException(PregException::class); - $this->expectExceptionMessageRegExp('~\Q\Preg::replace()\E: Invalid PCRE pattern "": \(code: \d+\) [^(]+ \(version: \d+~'); + $this->expectExceptionMessageMatches('~\Q\Preg::replace()\E: Invalid PCRE pattern "": \(code: \d+\) [^(]+ \(version: \d+~'); Preg::replace('', 'foo', 'bar'); } diff --git a/tests/RuleSet/RuleSetTest.php b/tests/RuleSet/RuleSetTest.php index dbe5aa66c3b..af0941f6d64 100644 --- a/tests/RuleSet/RuleSetTest.php +++ b/tests/RuleSet/RuleSetTest.php @@ -141,7 +141,7 @@ public function testGetBuildInSetDefinitionNames() { $setNames = RuleSets::getSetDefinitionNames(); - static::assertInternalType('array', $setNames); + static::assertIsArray($setNames); static::assertNotEmpty($setNames); } @@ -321,7 +321,7 @@ public function provideSafeSetCases() public function testInvalidConfigNestedSets() { $this->expectException(\UnexpectedValueException::class); - $this->expectExceptionMessageRegExp('#^Nested rule set "@PSR1" configuration must be a boolean\.$#'); + $this->expectExceptionMessageMatches('#^Nested rule set "@PSR1" configuration must be a boolean\.$#'); new RuleSet( ['@PSR1' => ['@PSR2' => 'no']] @@ -333,7 +333,7 @@ public function testGetMissingRuleConfiguration() $ruleSet = new RuleSet(); $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessageRegExp('#^Rule "_not_exists" is not in the set\.$#'); + $this->expectExceptionMessageMatches('#^Rule "_not_exists" is not in the set\.$#'); $ruleSet->getRuleConfiguration('_not_exists'); } diff --git a/tests/RuleSet/RuleSetsTest.php b/tests/RuleSet/RuleSetsTest.php index 5dc5c0a5a43..ba5fe23c579 100644 --- a/tests/RuleSet/RuleSetsTest.php +++ b/tests/RuleSet/RuleSetsTest.php @@ -41,9 +41,9 @@ public function testGetSetDefinitions() $sets = RuleSets::getSetDefinitions(); foreach ($sets as $name => $set) { - static::assertInternalType('string', $name); + static::assertIsString($name); static::assertTrue('@' === $name[0]); - static::assertInternalType('array', $set->getRules()); + static::assertIsArray($set->getRules()); } } @@ -101,7 +101,7 @@ public function testHasIntegrationTest($setDefinitionName) */ public function testBuildInSetDefinitionNames($setName) { - static::assertInternalType('string', $setName); + static::assertIsString($setName); static::assertSame('@', substr($setName, 0, 1)); } diff --git a/tests/RuleSet/Sets/AbstractSetTest.php b/tests/RuleSet/Sets/AbstractSetTest.php index a83f78e2ae9..ed8cd6e6caf 100644 --- a/tests/RuleSet/Sets/AbstractSetTest.php +++ b/tests/RuleSet/Sets/AbstractSetTest.php @@ -33,7 +33,7 @@ public function testSet() $rules = $set->getRules(); - static::assertInternalType('array', $rules); + static::assertIsArray($rules); foreach ($rules as $rule => $config) { self::assertSanityString($rule); @@ -45,7 +45,7 @@ public function testIsRisky() $set = self::getSet(); $isRisky = $set->isRisky(); - static::assertInternalType('bool', $isRisky); + static::assertIsBool($isRisky); $factory = new FixerFactory(); $factory->registerBuiltInFixers(); @@ -63,7 +63,7 @@ public function testIsRisky() private static function assertSanityString($string) { - static::assertInternalType('string', $string); + static::assertIsString($string); static::assertSame(trim($string), $string); static::assertFalse('' === $string); } diff --git a/tests/Runner/FileFilterIteratorTest.php b/tests/Runner/FileFilterIteratorTest.php index 839a4e19896..0fab7ebab2b 100644 --- a/tests/Runner/FileFilterIteratorTest.php +++ b/tests/Runner/FileFilterIteratorTest.php @@ -182,7 +182,7 @@ public function testInvalidIterator() $this->expectException( \RuntimeException::class ); - $this->expectExceptionMessageRegExp( + $this->expectExceptionMessageMatches( '#^Expected instance of "\\\SplFileInfo", got "string"\.$#' ); diff --git a/tests/Runner/RunnerTest.php b/tests/Runner/RunnerTest.php index bdb081a032c..7d993446e90 100644 --- a/tests/Runner/RunnerTest.php +++ b/tests/Runner/RunnerTest.php @@ -78,8 +78,8 @@ public function testThatFixSuccessfully() $changed = $runner->fix(); static::assertCount(2, $changed); - static::assertArraySubset($expectedChangedInfo, array_pop($changed)); - static::assertArraySubset($expectedChangedInfo, array_pop($changed)); + static::assertSame($expectedChangedInfo, array_pop($changed)); + static::assertSame($expectedChangedInfo, array_pop($changed)); $path = __DIR__.\DIRECTORY_SEPARATOR.'..'.\DIRECTORY_SEPARATOR.'Fixtures'.\DIRECTORY_SEPARATOR.'FixerTest'.\DIRECTORY_SEPARATOR.'fix'; $runner = new Runner( @@ -98,7 +98,7 @@ public function testThatFixSuccessfully() $changed = $runner->fix(); static::assertCount(1, $changed); - static::assertArraySubset($expectedChangedInfo, array_pop($changed)); + static::assertSame($expectedChangedInfo, array_pop($changed)); } /** diff --git a/tests/Smoke/CiIntegrationTest.php b/tests/Smoke/CiIntegrationTest.php index 49a9521937b..79c6b1023aa 100644 --- a/tests/Smoke/CiIntegrationTest.php +++ b/tests/Smoke/CiIntegrationTest.php @@ -157,7 +157,7 @@ public function testIntegration( preg_quote('Legend: ?-unknown, I-invalid file syntax (file ignored), S-skipped (cached or empty file), .-no changes, F-fixed, E-error', '/') ); - static::assertRegExp($pattern, $result3->getError()); + static::assertMatchesRegularExpression($pattern, $result3->getError()); preg_match($pattern, $result3->getError(), $matches); @@ -165,7 +165,7 @@ public function testIntegration( static::assertSame(substr_count($expectedResult3Files, '.'), substr_count($matches[1], '.')); static::assertSame(substr_count($expectedResult3Files, 'S'), substr_count($matches[1], 'S')); - static::assertRegExp( + static::assertMatchesRegularExpression( '/^\s*Checked all files in \d+\.\d+ seconds, \d+\.\d+ MB memory used\s*$/', $result3->getOutput() ); diff --git a/tests/Smoke/InstallViaComposerTest.php b/tests/Smoke/InstallViaComposerTest.php index 9fcaa7f9bf5..8d31ddad0ed 100644 --- a/tests/Smoke/InstallViaComposerTest.php +++ b/tests/Smoke/InstallViaComposerTest.php @@ -44,6 +44,10 @@ public static function setUpBeforeClass() { parent::setUpBeforeClass(); + if ('\\' === \DIRECTORY_SEPARATOR) { + static::markTestIncomplete('This test is broken on Windows'); + } + try { CommandExecutor::create('php --version', __DIR__)->getResult(); } catch (\RuntimeException $e) { diff --git a/tests/Smoke/PharTest.php b/tests/Smoke/PharTest.php index 3d7db0bf9d4..b9e34f82142 100644 --- a/tests/Smoke/PharTest.php +++ b/tests/Smoke/PharTest.php @@ -46,7 +46,7 @@ public static function setUpBeforeClass() public function testVersion() { - static::assertRegExp( + static::assertMatchesRegularExpression( '/^.* '.Application::VERSION.'(?: '.Application::VERSION_CODENAME.')? by .*$/', self::executePharCommand('--version')->getOutput() ); diff --git a/tests/Test/AbstractFixerTestCase.php b/tests/Test/AbstractFixerTestCase.php index 4a16372f5f7..fef9e74a386 100644 --- a/tests/Test/AbstractFixerTestCase.php +++ b/tests/Test/AbstractFixerTestCase.php @@ -91,7 +91,7 @@ protected function tearDown() final public function testIsRisky() { - static::assertInternalType('bool', $this->fixer->isRisky(), sprintf('Return type for ::isRisky of "%s" is invalid.', $this->fixer->getName())); + static::assertIsBool($this->fixer->isRisky(), sprintf('Return type for ::isRisky of "%s" is invalid.', $this->fixer->getName())); if ($this->fixer->isRisky()) { self::assertValidDescription($this->fixer->getName(), 'risky description', $this->fixer->getDefinition()->getRiskyDescription()); @@ -129,11 +129,11 @@ final public function testFixerDefinitions() $dummyFileInfo = new StdinFileInfo(); foreach ($samples as $sampleCounter => $sample) { static::assertInstanceOf(CodeSampleInterface::class, $sample, sprintf('[%s] Sample #%d', $fixerName, $sampleCounter)); - static::assertInternalType('int', $sampleCounter); + static::assertIsInt($sampleCounter); $code = $sample->getCode(); - static::assertInternalType('string', $code, sprintf('[%s] Sample #%d', $fixerName, $sampleCounter)); + static::assertIsString($code, sprintf('[%s] Sample #%d', $fixerName, $sampleCounter)); static::assertNotEmpty($code, sprintf('[%s] Sample #%d', $fixerName, $sampleCounter)); if (!($this->fixer instanceof SingleBlankLineAtEofFixer)) { @@ -143,7 +143,7 @@ final public function testFixerDefinitions() $config = $sample->getConfiguration(); if (null !== $config) { static::assertTrue($fixerIsConfigurable, sprintf('[%s] Sample #%d has configuration, but the fixer is not configurable.', $fixerName, $sampleCounter)); - static::assertInternalType('array', $config, sprintf('[%s] Sample #%d configuration must be an array or null.', $fixerName, $sampleCounter)); + static::assertIsArray($config, sprintf('[%s] Sample #%d configuration must be an array or null.', $fixerName, $sampleCounter)); $configSamplesProvided[$sampleCounter] = $config; } elseif ($fixerIsConfigurable) { @@ -219,7 +219,7 @@ final public function testFixerDefinitions() static::markTestIncomplete(sprintf('Rule "%s" is not following new option casing yet, please help.', $fixerName)); } - static::assertRegExp('/^[a-z_]+[a-z]$/', $option->getName(), sprintf('[%s] Option %s is not snake_case.', $fixerName, $option->getName())); + static::assertMatchesRegularExpression('/^[a-z_]+[a-z]$/', $option->getName(), sprintf('[%s] Option %s is not snake_case.', $fixerName, $option->getName())); } } } @@ -257,16 +257,16 @@ final public function testDeprecatedFixersHaveCorrectSummary() $reflection = new \ReflectionClass($this->fixer); $comment = $reflection->getDocComment(); - static::assertNotContains( + static::assertStringNotContainsString( 'DEPRECATED', $this->fixer->getDefinition()->getSummary(), 'Fixer cannot contain word "DEPRECATED" in summary' ); if ($this->fixer instanceof DeprecatedFixerInterface) { - static::assertContains('@deprecated', $comment); + static::assertStringContainsString('@deprecated', $comment); } elseif (\is_string($comment)) { - static::assertNotContains('@deprecated', $comment); + static::assertStringNotContainsString('@deprecated', $comment); } } @@ -298,7 +298,7 @@ final public function testFixerConfigurationDefinitions() ) ); - static::assertNotContains( + static::assertStringNotContainsString( 'DEPRECATED', $option->getDescription(), 'Option description cannot contain word "DEPRECATED"' @@ -311,13 +311,13 @@ final public function testFixersReturnTypes() $tokens = Tokens::fromCode('fixer->getPriority(), sprintf('Return type for ::getPriority of "%s" is invalid.', $this->fixer->getName())); - static::assertInternalType('bool', $this->fixer->supports(new \SplFileInfo(__FILE__)), sprintf('Return type for ::supports of "%s" is invalid.', $this->fixer->getName())); + static::assertIsInt($this->fixer->getPriority(), sprintf('Return type for ::getPriority of "%s" is invalid.', $this->fixer->getName())); + static::assertIsBool($this->fixer->supports(new \SplFileInfo(__FILE__)), sprintf('Return type for ::supports of "%s" is invalid.', $this->fixer->getName())); - static::assertInternalType('bool', $this->fixer->isCandidate($emptyTokens), sprintf('Return type for ::isCandidate with empty tokens of "%s" is invalid.', $this->fixer->getName())); + static::assertIsBool($this->fixer->isCandidate($emptyTokens), sprintf('Return type for ::isCandidate with empty tokens of "%s" is invalid.', $this->fixer->getName())); static::assertFalse($emptyTokens->isChanged()); - static::assertInternalType('bool', $this->fixer->isCandidate($tokens), sprintf('Return type for ::isCandidate of "%s" is invalid.', $this->fixer->getName())); + static::assertIsBool($this->fixer->isCandidate($tokens), sprintf('Return type for ::isCandidate of "%s" is invalid.', $this->fixer->getName())); static::assertFalse($tokens->isChanged()); if ($this->fixer instanceof HeaderCommentFixer) { @@ -481,9 +481,9 @@ private function getLinter() */ private static function assertValidDescription($fixerName, $descriptionType, $description) { - static::assertInternalType('string', $description); - static::assertRegExp('/^[A-Z`][^"]+\.$/', $description, sprintf('[%s] The %s must start with capital letter or a ` and end with dot.', $fixerName, $descriptionType)); - static::assertNotContains('phpdocs', $description, sprintf('[%s] `PHPDoc` must not be in the plural in %s.', $fixerName, $descriptionType), true); + static::assertIsString($description); + static::assertMatchesRegularExpression('/^[A-Z`][^"]+\.$/', $description, sprintf('[%s] The %s must start with capital letter or a ` and end with dot.', $fixerName, $descriptionType)); + static::assertStringNotContainsString('phpdocs', $description, sprintf('[%s] `PHPDoc` must not be in the plural in %s.', $fixerName, $descriptionType)); static::assertCorrectCasing($description, 'PHPDoc', sprintf('[%s] `PHPDoc` must be in correct casing in %s.', $fixerName, $descriptionType)); static::assertCorrectCasing($description, 'PHPUnit', sprintf('[%s] `PHPUnit` must be in correct casing in %s.', $fixerName, $descriptionType)); static::assertFalse(strpos($descriptionType, '``'), sprintf('[%s] The %s must no contain sequential backticks.', $fixerName, $descriptionType)); diff --git a/tests/Test/AbstractTransformerTestCase.php b/tests/Test/AbstractTransformerTestCase.php index 4bc8580f40a..45c9497176c 100644 --- a/tests/Test/AbstractTransformerTestCase.php +++ b/tests/Test/AbstractTransformerTestCase.php @@ -53,15 +53,15 @@ protected function tearDown() public function testGetPriority() { - static::assertInternalType('int', $this->transformer->getPriority(), $this->transformer->getName()); + static::assertIsInt($this->transformer->getPriority(), $this->transformer->getName()); } public function testGetName() { $name = $this->transformer->getName(); - static::assertInternalType('string', $name); - static::assertRegExp('/^[a-z]+[a-z_]*[a-z]$/', $name); + static::assertIsString($name); + static::assertMatchesRegularExpression('/^[a-z]+[a-z_]*[a-z]$/', $name); } /** @@ -73,10 +73,10 @@ public function testGetCustomTokens() $name = $this->transformer->getName(); $customTokens = $this->transformer->getCustomTokens(); - static::assertInternalType('array', $customTokens, $name); + static::assertIsArray($customTokens, $name); foreach ($customTokens as $customToken) { - static::assertInternalType('int', $customToken, $name); + static::assertIsInt($customToken, $name); } } @@ -85,7 +85,7 @@ public function testGetRequiredPhpVersionId() $name = $this->transformer->getName(); $requiredPhpVersionId = $this->transformer->getRequiredPhpVersionId(); - static::assertInternalType('int', $requiredPhpVersionId, $name); + static::assertIsInt($requiredPhpVersionId, $name); static::assertGreaterThanOrEqual(50000, $requiredPhpVersionId, $name); } diff --git a/tests/TestCase.php b/tests/TestCase.php index 1702107b2ca..65c6caee372 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -13,6 +13,7 @@ namespace PhpCsFixer\Tests; use PHPUnit\Framework\TestCase as BaseTestCase; +use PHPUnitGoodPractices\Polyfill\PolyfillTrait; use PHPUnitGoodPractices\Traits\ExpectationViaCodeOverAnnotationTrait; use PHPUnitGoodPractices\Traits\ExpectOverSetExceptionTrait; use PHPUnitGoodPractices\Traits\IdentityOverEqualityTrait; @@ -32,6 +33,7 @@ abstract class TestCase extends BaseTestCase use IdentityOverEqualityTrait; use ProphecyOverMockObjectTrait; use ProphesizeOnlyInterfaceTrait; + use PolyfillTrait; } } else { /** diff --git a/tests/Tokenizer/TokensTest.php b/tests/Tokenizer/TokensTest.php index 78f6bab123d..1ded123d0d7 100644 --- a/tests/Tokenizer/TokensTest.php +++ b/tests/Tokenizer/TokensTest.php @@ -476,7 +476,7 @@ public function bar() $tokens = Tokens::fromCode($source); /** @var Token[] $found */ $found = $tokens->findGivenKind(T_CLASS); - static::assertInternalType('array', $found); + static::assertIsArray($found); static::assertCount(1, $found); static::assertArrayHasKey(1, $found); static::assertSame(T_CLASS, $found[1]->getId()); @@ -485,13 +485,13 @@ public function bar() $found = $tokens->findGivenKind([T_CLASS, T_FUNCTION]); static::assertCount(2, $found); static::assertArrayHasKey(T_CLASS, $found); - static::assertInternalType('array', $found[T_CLASS]); + static::assertIsArray($found[T_CLASS]); static::assertCount(1, $found[T_CLASS]); static::assertArrayHasKey(1, $found[T_CLASS]); static::assertSame(T_CLASS, $found[T_CLASS][1]->getId()); static::assertArrayHasKey(T_FUNCTION, $found); - static::assertInternalType('array', $found[T_FUNCTION]); + static::assertIsArray($found[T_FUNCTION]); static::assertCount(2, $found[T_FUNCTION]); static::assertArrayHasKey(9, $found[T_FUNCTION]); static::assertSame(T_FUNCTION, $found[T_FUNCTION][9]->getId()); @@ -752,7 +752,7 @@ public function provideFindBlockEnd71Cases() public function testFindBlockEndInvalidType() { $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessageRegExp('/^Invalid param type: "-1"\.$/'); + $this->expectExceptionMessageMatches('/^Invalid param type: "-1"\.$/'); Tokens::clearCache(); $tokens = Tokens::fromCode('expectException(\InvalidArgumentException::class); - $this->expectExceptionMessageRegExp('/^Invalid param \$startIndex - not a proper block "start"\.$/'); + $this->expectExceptionMessageMatches('/^Invalid param \$startIndex - not a proper block "start"\.$/'); Tokens::clearCache(); $tokens = Tokens::fromCode('findBlockStart($type, $expectedIndex)); $detectedType = Tokens::detectBlockType($tokens[$searchIndex]); - static::assertInternalType('array', $detectedType); + static::assertIsArray($detectedType); static::assertArrayHasKey('type', $detectedType); static::assertArrayHasKey('isStart', $detectedType); static::assertSame($type, $detectedType['type']); static::assertTrue($detectedType['isStart']); $detectedType = Tokens::detectBlockType($tokens[$expectedIndex]); - static::assertInternalType('array', $detectedType); + static::assertIsArray($detectedType); static::assertArrayHasKey('type', $detectedType); static::assertArrayHasKey('isStart', $detectedType); static::assertSame($type, $detectedType['type']); diff --git a/tests/ToolInfoTest.php b/tests/ToolInfoTest.php index d25e226c652..a1280f33f82 100644 --- a/tests/ToolInfoTest.php +++ b/tests/ToolInfoTest.php @@ -26,7 +26,7 @@ final class ToolInfoTest extends TestCase public function testGetVersion() { $toolInfo = new ToolInfo(); - static::assertInternalType('string', $toolInfo->getVersion()); + static::assertIsString($toolInfo->getVersion()); } public function testIsInstallAsPhar() diff --git a/tests/WhitespacesFixerConfigTest.php b/tests/WhitespacesFixerConfigTest.php index d9d88568e9f..33de3f4c13b 100644 --- a/tests/WhitespacesFixerConfigTest.php +++ b/tests/WhitespacesFixerConfigTest.php @@ -34,7 +34,7 @@ public function testCases($indent, $lineEnding, $exceptionRegExp = null) { if (null !== $exceptionRegExp) { $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessageRegExp('%^'.preg_quote($exceptionRegExp, '%').'$%'); + $this->expectExceptionMessageMatches('%^'.preg_quote($exceptionRegExp, '%').'$%'); } $config = new WhitespacesFixerConfig($indent, $lineEnding);