Fix merge conflict resolution

This commit is contained in:
Fabien Potencier
2026-07-30 13:32:38 +02:00
parent 3197df7b5e
commit feffcb7df8
5 changed files with 18 additions and 38 deletions
+5 -12
View File
@@ -21,6 +21,8 @@ namespace Twig\Tests\Extension;
*/
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\TestCase;
use Twig\Environment;
use Twig\Error\RuntimeError;
@@ -353,10 +355,7 @@ class CoreTest extends TestCase
];
}
/**
* @group legacy
*/
#[Group('legacy')]
#[Group('legacy'), IgnoreDeprecations]
public function testSandboxedInclude(): void
{
$twig = new Environment(new ArrayLoader([
@@ -372,10 +371,7 @@ class CoreTest extends TestCase
$twig->render('index');
}
/**
* @group legacy
*/
#[Group('legacy')]
#[Group('legacy'), IgnoreDeprecations]
public function testSandboxedIncludeWithPreloadedTemplate(): void
{
$twig = new Environment(new ArrayLoader([
@@ -395,10 +391,7 @@ class CoreTest extends TestCase
$twig->render('index');
}
/**
* @group legacy
*/
#[Group('legacy')]
#[Group('legacy'), IgnoreDeprecations]
public function testSandboxedIncludeResultStaysEscapedWhenAssigned(): void
{
$twig = new Environment(new ArrayLoader([
+7 -12
View File
@@ -12,26 +12,21 @@
namespace Twig\Tests\Extension;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Twig\Environment;
use Twig\Extension\SandboxExtension;
use Twig\Loader\ArrayLoader;
use Twig\Sandbox\SecurityPolicy;
/**
* @group legacy
*/
#[Group('legacy')]
#[Group('legacy'), IgnoreDeprecations]
class SandboxDeprecationsTest extends TestCase
{
use ExpectDeprecationTrait;
public function testEnableSandboxIsDeprecated(): void
{
$extension = new SandboxExtension(new SecurityPolicy());
$this->expectDeprecation('Since twig/twig 3.29: The "Twig\Extension\SandboxExtension::enableSandbox()" method is deprecated, use "Twig\Sandbox\Sandbox" to render untrusted templates instead.');
$this->expectUserDeprecationMessage('Since twig/twig 3.29: The "Twig\Extension\SandboxExtension::enableSandbox()" method is deprecated, use "Twig\Sandbox\Sandbox" to render untrusted templates instead.');
$extension->enableSandbox();
$this->assertTrue($extension->isSandboxed());
@@ -42,7 +37,7 @@ class SandboxDeprecationsTest extends TestCase
$extension = new SandboxExtension(new SecurityPolicy());
$extension->getChecker()->setSandboxed(true);
$this->expectDeprecation('Since twig/twig 3.29: The "Twig\Extension\SandboxExtension::disableSandbox()" method is deprecated, use "Twig\Sandbox\Sandbox" to render untrusted templates instead.');
$this->expectUserDeprecationMessage('Since twig/twig 3.29: The "Twig\Extension\SandboxExtension::disableSandbox()" method is deprecated, use "Twig\Sandbox\Sandbox" to render untrusted templates instead.');
$extension->disableSandbox();
$this->assertFalse($extension->isSandboxed());
@@ -52,7 +47,7 @@ class SandboxDeprecationsTest extends TestCase
{
$extension = new SandboxExtension(new SecurityPolicy(), true);
$this->expectDeprecation('Since twig/twig 3.29: The "Twig\Extension\SandboxExtension::isSandboxedGlobally()" method is deprecated, use "Twig\Sandbox\Sandbox" to render untrusted templates instead.');
$this->expectUserDeprecationMessage('Since twig/twig 3.29: The "Twig\Extension\SandboxExtension::isSandboxedGlobally()" method is deprecated, use "Twig\Sandbox\Sandbox" to render untrusted templates instead.');
$this->assertTrue($extension->isSandboxedGlobally());
}
@@ -65,7 +60,7 @@ class SandboxDeprecationsTest extends TestCase
]), ['autoescape' => false]);
$twig->addExtension(new SandboxExtension(new SecurityPolicy(allowedFunctions: ['include'])));
$this->expectDeprecation('Since twig/twig 3.29: The "sandboxed" argument of the "include" function is deprecated, use the "render_sandboxed" function to render untrusted templates instead.');
$this->expectUserDeprecationMessage('Since twig/twig 3.29: The "sandboxed" argument of the "include" function is deprecated, use the "render_sandboxed" function to render untrusted templates instead.');
$this->assertSame('partial content', $twig->render('index'));
}
@@ -77,7 +72,7 @@ class SandboxDeprecationsTest extends TestCase
'partial' => 'partial content',
]), ['autoescape' => false]);
$this->expectDeprecation('Since twig/twig 3.29: The "sandboxed" argument of the "include" function is deprecated, remove the argument as "false" has no effect.');
$this->expectUserDeprecationMessage('Since twig/twig 3.29: The "sandboxed" argument of the "include" function is deprecated, remove the argument as "false" has no effect.');
$this->assertSame('partial content', $twig->render('index'));
}
+3 -3
View File
@@ -11,6 +11,8 @@
namespace Twig\Tests\Extension;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\TestCase;
use Twig\Environment;
use Twig\Extension\SandboxExtension;
@@ -29,10 +31,8 @@ use Twig\Sandbox\SecurityPolicyInterface;
* Without the fix, the compiled checkSecurity() method only ran once at
* construction time, locking in the verdict computed against whatever sandbox
* state was active when the template was first loaded.
*
* @group legacy
*/
#[Group('legacy')]
#[Group('legacy'), IgnoreDeprecations]
class SandboxStateChangeTest extends TestCase
{
public function testEnableSandboxAfterFirstRender(): void
+3 -3
View File
@@ -21,6 +21,8 @@ namespace Twig\Tests\Extension;
*/
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\TestCase;
use Twig\Environment;
use Twig\Error\RuntimeError;
@@ -53,10 +55,8 @@ use Twig\TwigTest;
/**
* Covers the deprecated stateful sandbox mechanisms; new code should use
* \Twig\Sandbox\Sandbox, covered by \Twig\Tests\Sandbox\SandboxTest.
*
* @group legacy
*/
#[Group('legacy')]
#[Group('legacy'), IgnoreDeprecations]
class SandboxTest extends TestCase
{
protected static $params;
-8
View File
@@ -41,14 +41,6 @@ class SandboxTest extends TestCase
$this->assertSame('Hello FABIEN', $sandbox->render('index', ['greet' => true, 'name' => 'fabien']));
}
public function testNonStrictSecurityPolicyIsRejected(): void
{
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('The sandbox requires a strict security policy, call "setStrict(true)" on a dedicated policy for this sandbox.');
new Sandbox(self::env(), new SecurityPolicy());
}
public function testAnAlreadyUsedEnvironmentIsRejected(): void
{
$env = self::env(['index' => 'plain content']);