Skip to content

Use preg_qoute() escaping for --filter phpunit option#2923

Closed
staabm wants to merge 1 commit intophpstan:1.10.xfrom
staabm:quote
Closed

Use preg_qoute() escaping for --filter phpunit option#2923
staabm wants to merge 1 commit intophpstan:1.10.xfrom
staabm:quote

Conversation

@staabm
Copy link
Copy Markdown
Contributor

@staabm staabm commented Feb 18, 2024

see discussion in #2916 (comment)

a test-class like

<?php
namespace TestNamespace;

use PHPUnit\Framework\TestCase;

class mytest extends TestCase
{
	/**
	 * @dataProvider provider
	 */
	public function testMethod($data)
	{
		$this->assertTrue($data);
	}

	public function provider()
	{
		return [
			'my name(d data' => [true],
			'my $dat)a'       => [true]
		];
	}
}

requires a escaped filter

➜  phpstan-src git:(1.11.x) ✗ vendor/bin/phpunit mytest.php --filter 'my $dat\)a'
PHPUnit 9.5.23 #StandWithUkraine

Warning:       No code coverage driver available

No tests executed!
➜  phpstan-src git:(1.11.x) ✗ vendor/bin/phpunit mytest.php --filter 'my \$dat\)a'
PHPUnit 9.5.23 #StandWithUkraine

Warning:       No code coverage driver available

.                                                                   1 / 1 (100%)

Time: 00:00.011, Memory: 32.00 MB

OK (1 test, 1 assertion)

@staabm staabm marked this pull request as ready for review February 18, 2024 08:46
@phpstan-bot
Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

@staabm
Copy link
Copy Markdown
Contributor Author

staabm commented Feb 18, 2024

ahh interessting... this doesn't work when a # is part of the filter, which preg_quote() escapes but the filter does not work with. I will open an issue with phpunit

@staabm staabm closed this Feb 18, 2024
@staabm staabm deleted the quote branch February 18, 2024 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants