Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Twig 4] Add PHPUnit as dev dependency #4472

Merged
merged 1 commit into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ jobs:
coverage: "none"
php-version: ${{ matrix.php-version }}
ini-values: memory_limit=-1
tools: phpunit:11.3

- name: "Add PHPUnit matcher"
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- run: composer install

- name: "Run tests"
run: phpunit
run: vendor/bin/phpunit

extension-tests:
needs:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"keywords": ["templating"],
"homepage": "https://twig.symfony.com",
"license": "BSD-3-Clause",
"minimum-stability": "dev",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using dev stability for our dependencies was done on purpose. You should use phpunit/phpunit": "^11.4@stable" to override it only for phpunit instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really needed? Looking at the dependencies:

Twig/composer.json

Lines 26 to 35 in c192cbf

"require": {
"php": ">=8.2",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/polyfill-mbstring": "^1.3",
"symfony/polyfill-ctype": "^1.8"
},
"require-dev": {
"psr/container": "^1.0|^2.0",
"phpstan/phpstan": "^2.0"
},

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, the same thing happened when @VincentLanglet added PHPStan. It was installing the dev version without anybody noticing it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"phpstan/phpstan": "^2.0@stable"

should be preferred too then

"authors": [
{
"name": "Fabien Potencier",
Expand All @@ -32,7 +31,8 @@
},
"require-dev": {
"psr/container": "^1.0|^2.0",
"phpstan/phpstan": "^2.0"
"phpstan/phpstan": "^2.0",
"phpunit/phpunit": "^11.4"
},
"autoload": {
"psr-4" : {
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
processIsolation="false"
stopOnFailure="false"
bootstrap="vendor/autoload.php"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.3/phpunit.xsd"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
failOnDeprecation="true"
Expand Down
5 changes: 2 additions & 3 deletions tests/DeprecatedCallableInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
* file that was distributed with this source code.
*/

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Twig\DeprecatedCallableInfo;

class DeprecatedCallableInfoTest extends TestCase
{
/**
* @dataProvider provideTestsForTriggerDeprecation
*/
#[DataProvider('provideTestsForTriggerDeprecation')]
public function testTriggerDeprecation($expected, DeprecatedCallableInfo $info)
{
$info->setType('function');
Expand Down
12 changes: 3 additions & 9 deletions tests/LexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,7 @@ public function testInlineCommentWithHashInString()
$this->assertTrue($stream->isEOF());
}

/**
* @dataProvider getTemplateForInlineCommentsForVariable
*/
#[DataProvider('getTemplateForInlineCommentsForVariable')]
public function testInlineCommentForVariable(string $template)
{
$lexer = new Lexer(new Environment(new ArrayLoader()));
Expand Down Expand Up @@ -524,9 +522,7 @@ public static function getTemplateForInlineCommentsForVariable()
}}'];
}

/**
* @dataProvider getTemplateForInlineCommentsForBlock
*/
#[DataProvider('getTemplateForInlineCommentsForBlock')]
public function testInlineCommentForBlock(string $template)
{
$lexer = new Lexer(new Environment(new ArrayLoader()));
Expand Down Expand Up @@ -562,9 +558,7 @@ public static function getTemplateForInlineCommentsForBlock()
%}me{% endif %}'];
}

/**
* @dataProvider getTemplateForInlineCommentsForComment
*/
#[DataProvider('getTemplateForInlineCommentsForComment')]
public function testInlineCommentForComment(string $template)
{
$lexer = new Lexer(new Environment(new ArrayLoader()));
Expand Down
5 changes: 2 additions & 3 deletions tests/Util/CallableArgumentsExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* file that was distributed with this source code.
*/

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Twig\Error\SyntaxError;
use Twig\Node\EmptyNode;
Expand Down Expand Up @@ -83,9 +84,7 @@ public function testGetArgumentsForStaticMethod()
$this->assertEquals(['arg1'], $this->getArguments('custom_static_function', __CLASS__.'::customStaticFunction', ['arg1' => 'arg1']));
}

/**
* @dataProvider getGetArgumentsConversionData
*/
#[DataProvider('getGetArgumentsConversionData')]
public function testGetArgumentsConversion($arg1, $arg2)
{
$this->assertEquals([null], $this->getArguments('custom', eval("return fn (\$$arg1) => '';"), [$arg1 => null]));
Expand Down
Loading