Upgrade 1-11.38

This commit is contained in:
xesmyd
2026-03-30 14:10:30 +02:00
parent f2a7e6d1fc
commit ac648ef29d
24665 changed files with 69682 additions and 2205004 deletions
@@ -11,9 +11,11 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine;
use Symfony\Component\HttpFoundation\Response;
class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
class DelegatingEngineTest extends TestCase
{
public function testSupportsRetrievesEngineFromTheContainer()
{
@@ -60,7 +62,7 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
public function testRenderResponseWithFrameworkEngine()
{
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
$response = new Response();
$engine = $this->getFrameworkEngineMock('template.php', true);
$engine->expects($this->once())
->method('renderResponse')
@@ -84,7 +86,7 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
private function getEngineMock($template, $supports)
{
$engine = $this->getMock('Symfony\Component\Templating\EngineInterface');
$engine = $this->getMockBuilder('Symfony\Component\Templating\EngineInterface')->getMock();
$engine->expects($this->once())
->method('supports')
@@ -96,7 +98,7 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
private function getFrameworkEngineMock($template, $supports)
{
$engine = $this->getMock('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface');
$engine = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock();
$engine->expects($this->once())
->method('supports')
@@ -108,7 +110,7 @@ class DelegatingEngineTest extends \PHPUnit_Framework_TestCase
private function getContainerMock($services)
{
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$i = 0;
foreach ($services as $id => $service) {
@@ -33,7 +33,7 @@ class GlobalVariablesTest extends TestCase
public function testGetUserNoToken()
{
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$this->container->set('security.token_storage', $tokenStorage);
$this->assertNull($this->globals->getUser());
}
@@ -43,8 +43,8 @@ class GlobalVariablesTest extends TestCase
*/
public function testGetUser($user, $expectedUser)
{
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$this->container->set('security.token_storage', $tokenStorage);
@@ -63,9 +63,9 @@ class GlobalVariablesTest extends TestCase
public function getUserProvider()
{
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$std = new \stdClass();
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
return array(
array($user, $user),
@@ -11,12 +11,13 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper;
use Symfony\Component\Asset\Package;
use Symfony\Component\Asset\Packages;
use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy;
class AssetsHelperTest extends \PHPUnit_Framework_TestCase
class AssetsHelperTest extends TestCase
{
private $helper;
@@ -11,11 +11,12 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\RequestHelper;
class RequestHelperTest extends \PHPUnit_Framework_TestCase
class RequestHelperTest extends TestCase
{
protected $requestStack;
@@ -11,13 +11,14 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper;
class SessionHelperTest extends \PHPUnit_Framework_TestCase
class SessionHelperTest extends TestCase
{
protected $requestStack;
@@ -11,13 +11,14 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Templating\Helper\StopwatchHelper;
class StopwatchHelperTest extends \PHPUnit_Framework_TestCase
class StopwatchHelperTest extends TestCase
{
public function testDevEnvironment()
{
$stopwatch = $this->getMock('Symfony\Component\Stopwatch\Stopwatch');
$stopwatch = $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
$stopwatch->expects($this->once())
->method('start')
->with('foo');
@@ -29,11 +30,10 @@ class StopwatchHelperTest extends \PHPUnit_Framework_TestCase
public function testProdEnvironment()
{
$helper = new StopwatchHelper(null);
$helper->start('foo');
try {
$helper->start('foo');
} catch (\BadMethodCallException $e) {
$this->fail('Assumed stopwatch is not called when not provided');
}
// add a dummy assertion here to satisfy PHPUnit, the only thing we want to test is that the code above
// can be executed without throwing any exceptions
$this->addToAssertionCount(1);
}
}
@@ -33,6 +33,20 @@ class TemplateLocatorTest extends TestCase
$locator = new TemplateLocator($fileLocator);
$this->assertEquals('/path/to/template', $locator->locate($template));
// Assert cache is used as $fileLocator->locate should be called only once
$this->assertEquals('/path/to/template', $locator->locate($template));
}
public function testLocateATemplateFromCacheDir()
{
$template = new TemplateReference('bundle', 'controller', 'name', 'format', 'engine');
$fileLocator = $this->getFileLocator();
$locator = new TemplateLocator($fileLocator, __DIR__.'/../../Fixtures');
$this->assertEquals(realpath(__DIR__.'/../../Fixtures/Resources/views/this.is.a.template.format.engine'), $locator->locate($template));
}
public function testThrowsExceptionWhenTemplateNotFound()
@@ -22,7 +22,7 @@ class TemplateNameParserTest extends TestCase
protected function setUp()
{
$kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface');
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\KernelInterface')->getMock();
$kernel
->expects($this->any())
->method('getBundle')
@@ -68,11 +68,6 @@ class TemplateNameParserTest extends TestCase
array('FooBundle:Post:foo.bar.index.html.php', 'FooBundle:Post:foo.bar.index.html.php', '@FooBundle/Resources/views/Post/foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')),
array('@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', '@FooBundle/Resources/views/layout.html.twig', new BaseTemplateReference('@FooBundle/Resources/views/layout.html.twig', 'twig')),
array('@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', '@FooBundle/Foo/layout.html.twig', new BaseTemplateReference('@FooBundle/Foo/layout.html.twig', 'twig')),
array('/path/to/section/index.html.php', '/path/to/section/index.html.php', '/path/to/section/index.html.php', new BaseTemplateReference('/path/to/section/index.html.php', 'php')),
array('C:\\path\\to\\section\\name.html.php', 'C:path/to/section/name.html.php', 'C:path/to/section/name.html.php', new BaseTemplateReference('C:path/to/section/name.html.php', 'php')),
array('C:\\path\\to\\section\\name:foo.html.php', 'C:path/to/section/name:foo.html.php', 'C:path/to/section/name:foo.html.php', new BaseTemplateReference('C:path/to/section/name:foo.html.php', 'php')),
array('\\path\\to\\section\\name.html.php', '/path/to/section/name.html.php', '/path/to/section/name.html.php', new BaseTemplateReference('/path/to/section/name.html.php', 'php')),
array('/path/to/section/name.php', '/path/to/section/name.php', '/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')),
array('name.twig', 'name.twig', 'name.twig', new BaseTemplateReference('name.twig', 'twig')),
array('name', 'name', 'name', new BaseTemplateReference('name')),
array('default/index.html.php', '::default/index.html.php', 'views/default/index.html.php', new TemplateReference(null, null, 'default/index', 'html', 'php')),
@@ -86,4 +81,29 @@ class TemplateNameParserTest extends TestCase
{
$this->parser->parse('BarBundle:Post:index.html.php');
}
/**
* @group legacy
* @dataProvider provideAbsolutePaths
* @expectedDeprecation Absolute template path support is deprecated since Symfony 3.1 and will be removed in 4.0.
*/
public function testAbsolutePathsAreDeprecated($name, $logicalName, $path, $ref)
{
$template = $this->parser->parse($name);
$this->assertSame($ref->getLogicalName(), $template->getLogicalName());
$this->assertSame($logicalName, $template->getLogicalName());
$this->assertSame($path, $template->getPath());
}
public function provideAbsolutePaths()
{
return array(
array('/path/to/section/index.html.php', '/path/to/section/index.html.php', '/path/to/section/index.html.php', new BaseTemplateReference('/path/to/section/index.html.php', 'php')),
array('C:\\path\\to\\section\\name.html.php', 'C:path/to/section/name.html.php', 'C:path/to/section/name.html.php', new BaseTemplateReference('C:path/to/section/name.html.php', 'php')),
array('C:\\path\\to\\section\\name:foo.html.php', 'C:path/to/section/name:foo.html.php', 'C:path/to/section/name:foo.html.php', new BaseTemplateReference('C:path/to/section/name:foo.html.php', 'php')),
array('\\path\\to\\section\\name.html.php', '/path/to/section/name.html.php', '/path/to/section/name.html.php', new BaseTemplateReference('/path/to/section/name.html.php', 'php')),
array('/path/to/section/name.php', '/path/to/section/name.php', '/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')),
);
}
}
@@ -19,21 +19,9 @@ class TemplateTest extends TestCase
/**
* @dataProvider getTemplateToPathProvider
*/
public function testGetPathForTemplatesInABundle($template, $path)
public function testGetPathForTemplate($template, $path)
{
if ($template->get('bundle')) {
$this->assertEquals($template->getPath(), $path);
}
}
/**
* @dataProvider getTemplateToPathProvider
*/
public function testGetPathForTemplatesOutOfABundle($template, $path)
{
if (!$template->get('bundle')) {
$this->assertEquals($template->getPath(), $path);
}
$this->assertSame($template->getPath(), $path);
}
public function getTemplateToPathProvider()
@@ -44,7 +44,7 @@ class TimedPhpEngineTest extends TestCase
*/
private function getContainer()
{
return $this->getMock('Symfony\Component\DependencyInjection\Container');
return $this->getMockBuilder('Symfony\Component\DependencyInjection\Container')->getMock();
}
/**
@@ -52,8 +52,8 @@ class TimedPhpEngineTest extends TestCase
*/
private function getTemplateNameParser()
{
$templateReference = $this->getMock('Symfony\Component\Templating\TemplateReferenceInterface');
$templateNameParser = $this->getMock('Symfony\Component\Templating\TemplateNameParserInterface');
$templateReference = $this->getMockBuilder('Symfony\Component\Templating\TemplateReferenceInterface')->getMock();
$templateNameParser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock();
$templateNameParser->expects($this->any())
->method('parse')
->will($this->returnValue($templateReference));
@@ -111,6 +111,6 @@ class TimedPhpEngineTest extends TestCase
*/
private function getStopwatch()
{
return $this->getMock('Symfony\Component\Stopwatch\Stopwatch');
return $this->getMockBuilder('Symfony\Component\Stopwatch\Stopwatch')->getMock();
}
}