From 3381c085f4c64210500cce2052b9e24c035eb4fb Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Thu, 27 Jan 2022 16:15:57 +0100 Subject: [PATCH 01/14] =?UTF-8?q?:bulb:=20N=C2=B04714=20fix=20phpdoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/config.class.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 41c756984..6036b8f02 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -37,7 +37,7 @@ define('ITOP_VERSION', '2.7.0-dev'); * Note that in iTop 3.0.0 we used {@see ITOP_DESIGN_LATEST_VERSION} to get core version. * When releasing, both constants should be updated : see `.make/release/update-versions.php` for that ! * - * @since 2.7.7 3.0.1 3.1.1 N°4714 constant creation + * @since 2.7.7 3.0.1 3.1.0 N°4714 constant creation * @used-by utils::GetItopPatchVersion */ define('ITOP_CORE_VERSION', '2.7.7'); From 75dbad7406acb62fa3064a2113b79e7bfc449153 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Fri, 28 Jan 2022 14:57:43 +0100 Subject: [PATCH 02/14] =?UTF-8?q?N=C2=B03129=20PHP=208.0=20compat:=20Fix?= =?UTF-8?q?=20"Deprecated:=20=20Required=20parameter=20...=20follows=20opt?= =?UTF-8?q?ional=20parameter=20..."=20*=20\SQLObjectQuery::PrepareSingleTa?= =?UTF-8?q?ble=20*=20\HistoryBlock::GetRenderContent=20*=20\MenuBlock::Get?= =?UTF-8?q?RenderContent=20*=20\UILinksWidgetDirect::DisplayAsBlock=20*=20?= =?UTF-8?q?\UILinksWidgetDirect::Display=20*=20\UILinksWidgetDirect::Displ?= =?UTF-8?q?ayEditInPlace=20*=20\UIExtKeyWidget::AutoComplete=20*=20\UIExtK?= =?UTF-8?q?eyWidget::DisplayFromAttCode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/displayblock.class.inc.php | 28 +++++++++++++++++-- application/ui.extkeywidget.class.inc.php | 10 +++++-- .../ui.linksdirectwidget.class.inc.php | 16 +++++++++-- core/sqlobjectquery.class.inc.php | 13 ++++++++- 4 files changed, 58 insertions(+), 9 deletions(-) diff --git a/application/displayblock.class.inc.php b/application/displayblock.class.inc.php index 9a21f9db7..c27996848 100644 --- a/application/displayblock.class.inc.php +++ b/application/displayblock.class.inc.php @@ -1418,8 +1418,24 @@ class HistoryBlock extends DisplayBlock $this->iLimitStart = $iStart; $this->iLimitCount = $iCount; } - - public function GetRenderContent(WebPage $oPage, $aExtraParams = array(), $sId) + + /** + * @param \WebPage $oPage + * @param array $aExtraParams + * @param string $sId + * + * @return string + * @throws \ArchivedObjectException + * @throws \CoreException + * @throws \CoreUnexpectedValue + * @throws \DictExceptionMissingString + * @throws \MissingQueryArgument + * @throws \MySQLException + * @throws \MySQLHasGoneAwayException + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aExtraParams for PHP 8.0 compatibility (var is unused, and all calls were already made using a default value) + */ + public function GetRenderContent(WebPage $oPage, $aExtraParams, $sId) { $sHtml = ''; $bTruncated = false; @@ -1558,9 +1574,15 @@ class MenuBlock extends DisplayBlock * @throws \Exception * @throws \MissingQueryArgument * @throws \MySQLException + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aExtraParams for PHP 8.0 compatibility (added a test at function start to handle wrong values) */ - public function GetRenderContent(WebPage $oPage, $aExtraParams = array(), $sId) + public function GetRenderContent(WebPage $oPage, $aExtraParams, $sId) { + if (empty($aExtraParams)) { + $aExtraParams = []; + } + if ($this->m_sStyle == 'popup') // popup is a synonym of 'list' for backward compatibility { $this->m_sStyle = 'list'; diff --git a/application/ui.extkeywidget.class.inc.php b/application/ui.extkeywidget.class.inc.php index 121c91a7b..465f53c03 100644 --- a/application/ui.extkeywidget.class.inc.php +++ b/application/ui.extkeywidget.class.inc.php @@ -71,7 +71,11 @@ class UIExtKeyWidget protected $bSearchMode; //public function __construct($sAttCode, $sClass, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sNameSuffix = '', $sFieldPrefix = '', $sFormPrefix = '') - static public function DisplayFromAttCode($oPage, $sAttCode, $sClass, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName = '', $sFormPrefix = '', $aArgs, $bSearchMode = false) + + /** + * @since 2.7.7 3.0.1 3.1.0 N°3129 Add default value for $aArgs for PHP 8.0 compat + */ + public static function DisplayFromAttCode($oPage, $sAttCode, $sClass, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName = '', $sFormPrefix = '', $aArgs = [], $bSearchMode = false) { $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); $sTargetClass = $oAttDef->GetTargetClass(); @@ -426,8 +430,10 @@ EOF * * @throws CoreException * @throws OQLException + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $oObj for PHP 8.0 compatibility (a null default value is awkward ?!??) */ - public function AutoComplete(WebPage $oP, $sFilter, $oObj = null, $sContains, $sOutputFormat = self::ENUM_OUTPUT_FORMAT_CSV, $sOperation = null) + public function AutoComplete(WebPage $oP, $sFilter, $oObj, $sContains, $sOutputFormat = self::ENUM_OUTPUT_FORMAT_CSV, $sOperation = null) { if (is_null($sFilter)) { diff --git a/application/ui.linksdirectwidget.class.inc.php b/application/ui.linksdirectwidget.class.inc.php index 1fb41501b..e99a74898 100644 --- a/application/ui.linksdirectwidget.class.inc.php +++ b/application/ui.linksdirectwidget.class.inc.php @@ -85,9 +85,15 @@ class UILinksWidgetDirect * @param array $aArgs * @param string $sFormPrefix * @param DBObject $oCurrentObj + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aArgs for PHP 8.0 compatibility (handling wrong values at method start) */ - public function Display(WebPage $oPage, $oValue, $aArgs = array(), $sFormPrefix, $oCurrentObj) + public function Display(WebPage $oPage, $oValue, $aArgs, $sFormPrefix, $oCurrentObj) { + if (empty($aArgs)) { + $aArgs = []; + } + $oLinksetDef = MetaModel::GetAttributeDef($this->sClass, $this->sAttCode); switch($oLinksetDef->GetEditMode()) { @@ -137,8 +143,10 @@ class UILinksWidgetDirect * @param string $sFormPrefix * @param DBObject $oCurrentObj * @param bool $bDisplayMenu + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aArgs for PHP 8.0 compatibility (protected method, always called with default value) */ - protected function DisplayAsBlock(WebPage $oPage, $oValue, $aArgs = array(), $sFormPrefix, $oCurrentObj, $bDisplayMenu) + protected function DisplayAsBlock(WebPage $oPage, $oValue, $aArgs, $sFormPrefix, $oCurrentObj, $bDisplayMenu) { $oLinksetDef = MetaModel::GetAttributeDef($this->sClass, $this->sAttCode); $sTargetClass = $oLinksetDef->GetLinkedClass(); @@ -239,8 +247,10 @@ class UILinksWidgetDirect * @param string $sFormPrefix * @param DBObject $oCurrentObj * @param array $aButtons + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aArgs for PHP 8.0 compatibility (protected method, caller already handles it) */ - protected function DisplayEditInPlace(WebPage $oPage, $oValue, $aArgs = array(), $sFormPrefix, $oCurrentObj, $aButtons = array('create', 'delete')) + protected function DisplayEditInPlace(WebPage $oPage, $oValue, $aArgs, $sFormPrefix, $oCurrentObj, $aButtons = array('create', 'delete')) { $aAttribs = $this->GetTableConfig(); diff --git a/core/sqlobjectquery.class.inc.php b/core/sqlobjectquery.class.inc.php index d7a59fcbb..8ce9a0ff2 100644 --- a/core/sqlobjectquery.class.inc.php +++ b/core/sqlobjectquery.class.inc.php @@ -491,7 +491,17 @@ class SQLObjectQuery extends SQLQuery } } - private function PrepareSingleTable(SQLObjectQuery $oRootQuery, &$aFrom, $sCallerAlias = '', $aJoinData) + /** + * @param \SQLObjectQuery $oRootQuery + * @param $aFrom + * @param $sCallerAlias + * @param $aJoinData + * + * @return string + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $sCallerAlias for PHP 8.0 compat (Private method with only 2 calls in the class, both providing the optional parameter) + */ + private function PrepareSingleTable(SQLObjectQuery $oRootQuery, &$aFrom, $sCallerAlias, $aJoinData) { $aTranslationTable[$this->m_sTable]['*'] = $this->m_sTableAlias; $sJoinCond = ''; @@ -610,6 +620,7 @@ class SQLObjectQuery extends SQLQuery $aTempFrom = array(); // temporary subset of 'from' specs, to be grouped in the final query foreach ($this->m_aJoinSelects as $aJoinData) { + /** @var \SQLObjectQuery $oRightSelect */ $oRightSelect = $aJoinData["select"]; $oRightSelect->PrepareSingleTable($oRootQuery, $aTempFrom, $this->m_sTableAlias, $aJoinData); From 7495fb9af429e565753fa262da0cb81948a6c13f Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Fri, 28 Jan 2022 09:55:38 +0100 Subject: [PATCH 03/14] =?UTF-8?q?N=C2=B03129=20PHP=208.0=20compat:=20Fix?= =?UTF-8?q?=20"Deprecated:=20=20Required=20parameter=20...=20follows=20opt?= =?UTF-8?q?ional=20parameter=20..."=20in=20Twig=20Update=20symfony/twig-bu?= =?UTF-8?q?ndle=20from=203.4.36=20to=203.4.47?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.lock | 32 +- lib/composer/autoload_classmap.php | 4 +- lib/composer/autoload_static.php | 4 +- lib/composer/include_paths.php | 2 +- lib/composer/installed.json | 34 +- lib/composer/installed.php | 10 +- .../CacheWarmer/TemplateCacheWarmer.php | 4 +- .../twig-bundle/Command/DebugCommand.php | 2 +- .../ContainerAwareRuntimeLoader.php | 2 +- .../Compiler/TwigLoaderPass.php | 2 +- lib/symfony/twig-bundle/LICENSE | 2 +- .../Tests/ContainerAwareRuntimeLoaderTest.php | 41 ++ .../Controller/ExceptionControllerTest.php | 92 +++++ .../Controller/PreviewErrorControllerTest.php | 53 +++ .../Compiler/ExtensionPassTest.php | 46 +++ .../Compiler/TwigEnvironmentPassTest.php | 45 +++ .../Compiler/TwigLoaderPassTest.php | 95 +++++ .../DependencyInjection/ConfigurationTest.php | 31 ++ .../Resources/views/layout.html.twig | 1 + .../Resources/views/layout.html.twig | 1 + .../Resources/views/layout.html.twig | 1 + .../Resources/views/layout.html.twig | 1 + .../TwigBundle/views/layout.html.twig | 1 + .../Fixtures/Resources/views/layout.html.twig | 1 + .../php/customTemplateEscapingGuesser.php | 6 + .../Fixtures/php/empty.php | 3 + .../Fixtures/php/extra.php | 7 + .../Fixtures/php/formats.php | 14 + .../DependencyInjection/Fixtures/php/full.php | 27 ++ .../bundles/BarBundle/layout.html.twig | 1 + .../bundles/TwigBundle/layout.html.twig | 1 + .../Fixtures/templates/layout.html.twig | 1 + .../xml/customTemplateEscapingGuesser.xml | 10 + .../Fixtures/xml/empty.xml | 10 + .../Fixtures/xml/extra.xml | 12 + .../Fixtures/xml/formats.xml | 12 + .../DependencyInjection/Fixtures/xml/full.xml | 19 + .../yml/customTemplateEscapingGuesser.yml | 3 + .../Fixtures/yml/empty.yml | 1 + .../Fixtures/yml/extra.yml | 3 + .../Fixtures/yml/formats.yml | 9 + .../DependencyInjection/Fixtures/yml/full.yml | 21 ++ .../DependencyInjection/TwigExtensionTest.php | 355 ++++++++++++++++++ .../BarBundle/Resources/views/index.html.twig | 1 + .../Fixtures/templates/Foo/index.html.twig | 1 + .../Resources/BarBundle/views/base.html.twig | 0 .../Resources/views/layout.html.twig | 1 + .../Resources/views/sub/sub.html.twig | 1 + .../Tests/Functional/CacheWarmingTest.php | 124 ++++++ .../Tests/Functional/EmptyAppTest.php | 51 +++ .../Functional/NoTemplatingEntryTest.php | 80 ++++ .../Resources/config/empty_routing.yml | 0 .../Resources/views/index.html.twig | 1 + .../Tests/Loader/FilesystemLoaderTest.php | 125 ++++++ .../Tests/TemplateIteratorTest.php | 44 +++ lib/symfony/twig-bundle/Tests/TestCase.php | 18 + lib/symfony/twig-bundle/TwigBundle.php | 3 +- lib/symfony/twig-bundle/composer.json | 7 +- 58 files changed, 1437 insertions(+), 42 deletions(-) create mode 100644 lib/symfony/twig-bundle/Tests/ContainerAwareRuntimeLoaderTest.php create mode 100644 lib/symfony/twig-bundle/Tests/Controller/ExceptionControllerTest.php create mode 100644 lib/symfony/twig-bundle/Tests/Controller/PreviewErrorControllerTest.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigEnvironmentPassTest.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/ConfigurationTest.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/views/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/views/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/TwigBundle/views/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/views/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/empty.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/extra.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/formats.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/full.php create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/BarBundle/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/TwigBundle/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/empty.xml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/extra.xml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/formats.xml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/full.xml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/empty.yml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/extra.yml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/formats.yml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/full.yml create mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/TwigExtensionTest.php create mode 100644 lib/symfony/twig-bundle/Tests/Fixtures/templates/BarBundle/Resources/views/index.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/Fixtures/templates/Foo/index.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/BarBundle/views/base.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/layout.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/sub/sub.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/Functional/CacheWarmingTest.php create mode 100644 lib/symfony/twig-bundle/Tests/Functional/EmptyAppTest.php create mode 100644 lib/symfony/twig-bundle/Tests/Functional/NoTemplatingEntryTest.php create mode 100644 lib/symfony/twig-bundle/Tests/Functional/Resources/config/empty_routing.yml create mode 100644 lib/symfony/twig-bundle/Tests/Functional/Resources/views/index.html.twig create mode 100644 lib/symfony/twig-bundle/Tests/Loader/FilesystemLoaderTest.php create mode 100644 lib/symfony/twig-bundle/Tests/TemplateIteratorTest.php create mode 100644 lib/symfony/twig-bundle/Tests/TestCase.php diff --git a/composer.lock b/composer.lock index 0a54b3c29..8c6f5f610 100644 --- a/composer.lock +++ b/composer.lock @@ -2200,16 +2200,16 @@ }, { "name": "symfony/twig-bundle", - "version": "v3.4.36", + "version": "v3.4.47", "source": { "type": "git", "url": "https://github.com/symfony/twig-bundle.git", - "reference": "d39ed8f5df62aeeeb27a6f3bf7f58a6c02a58ea9" + "reference": "977b3096e2df96bc8a8d2329e83466cfc30c373d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/twig-bundle/zipball/d39ed8f5df62aeeeb27a6f3bf7f58a6c02a58ea9", - "reference": "d39ed8f5df62aeeeb27a6f3bf7f58a6c02a58ea9", + "url": "https://api.github.com/repos/symfony/twig-bundle/zipball/977b3096e2df96bc8a8d2329e83466cfc30c373d", + "reference": "977b3096e2df96bc8a8d2329e83466cfc30c373d", "shasum": "" }, "require": { @@ -2242,11 +2242,6 @@ "symfony/yaml": "~2.8|~3.0|~4.0" }, "type": "symfony-bundle", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Bundle\\TwigBundle\\": "" @@ -2271,7 +2266,24 @@ ], "description": "Symfony TwigBundle", "homepage": "https://symfony.com", - "time": "2019-10-01T15:13:36+00:00" + "support": { + "source": "https://github.com/symfony/twig-bundle/tree/v3.4.47" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-24T10:57:07+00:00" }, { "name": "symfony/yaml", diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php index f797278b7..c8f16b4c6 100644 --- a/lib/composer/autoload_classmap.php +++ b/lib/composer/autoload_classmap.php @@ -17,7 +17,7 @@ return array( 'ActionChecker' => $baseDir . '/core/userrights.class.inc.php', 'ActionEmail' => $baseDir . '/core/action.class.inc.php', 'ActionNotification' => $baseDir . '/core/action.class.inc.php', - 'ApcService' => $baseDir . '/core/apc-service.class.inc.php', + 'ApcService' => $baseDir . '/core/apc-service.class.inc.php', 'ApplicationContext' => $baseDir . '/application/applicationcontext.class.inc.php', 'ApplicationException' => $baseDir . '/application/application.inc.php', 'ApplicationMenu' => $baseDir . '/application/menunode.class.inc.php', @@ -175,6 +175,7 @@ return array( 'DBProperty' => $baseDir . '/core/dbproperty.class.inc.php', 'DBSearch' => $baseDir . '/core/dbsearch.class.php', 'DBUnionSearch' => $baseDir . '/core/dbunionsearch.class.php', + 'DOMSanitizer' => $baseDir . '/core/htmlsanitizer.class.inc.php', 'DailyRotatingLogFileNameBuilder' => $baseDir . '/core/log.class.inc.php', 'Dashboard' => $baseDir . '/application/dashboard.class.inc.php', 'DashboardLayout' => $baseDir . '/application/dashboardlayout.class.inc.php', @@ -645,6 +646,7 @@ return array( 'SQLObjectQueryBuilder' => $baseDir . '/core/sqlobjectquerybuilder.class.inc.php', 'SQLQuery' => $baseDir . '/core/sqlquery.class.inc.php', 'SQLUnionQuery' => $baseDir . '/core/sqlunionquery.class.inc.php', + 'SVGDOMSanitizer' => $baseDir . '/core/htmlsanitizer.class.inc.php', 'ScalarExpression' => $baseDir . '/core/oql/expression.class.inc.php', 'ScalarOqlExpression' => $baseDir . '/core/oql/oqlquery.class.inc.php', 'ScssPhp\\ScssPhp\\Base\\Range' => $vendorDir . '/scssphp/scssphp/src/Base/Range.php', diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php index 8009a857b..cbe230767 100644 --- a/lib/composer/autoload_static.php +++ b/lib/composer/autoload_static.php @@ -247,7 +247,7 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'ActionChecker' => __DIR__ . '/../..' . '/core/userrights.class.inc.php', 'ActionEmail' => __DIR__ . '/../..' . '/core/action.class.inc.php', 'ActionNotification' => __DIR__ . '/../..' . '/core/action.class.inc.php', - 'ApcService' => __DIR__ . '/../..' . '/core/apc-service.class.inc.php', + 'ApcService' => __DIR__ . '/../..' . '/core/apc-service.class.inc.php', 'ApplicationContext' => __DIR__ . '/../..' . '/application/applicationcontext.class.inc.php', 'ApplicationException' => __DIR__ . '/../..' . '/application/application.inc.php', 'ApplicationMenu' => __DIR__ . '/../..' . '/application/menunode.class.inc.php', @@ -405,6 +405,7 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'DBProperty' => __DIR__ . '/../..' . '/core/dbproperty.class.inc.php', 'DBSearch' => __DIR__ . '/../..' . '/core/dbsearch.class.php', 'DBUnionSearch' => __DIR__ . '/../..' . '/core/dbunionsearch.class.php', + 'DOMSanitizer' => __DIR__ . '/../..' . '/core/htmlsanitizer.class.inc.php', 'DailyRotatingLogFileNameBuilder' => __DIR__ . '/../..' . '/core/log.class.inc.php', 'Dashboard' => __DIR__ . '/../..' . '/application/dashboard.class.inc.php', 'DashboardLayout' => __DIR__ . '/../..' . '/application/dashboardlayout.class.inc.php', @@ -875,6 +876,7 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'SQLObjectQueryBuilder' => __DIR__ . '/../..' . '/core/sqlobjectquerybuilder.class.inc.php', 'SQLQuery' => __DIR__ . '/../..' . '/core/sqlquery.class.inc.php', 'SQLUnionQuery' => __DIR__ . '/../..' . '/core/sqlunionquery.class.inc.php', + 'SVGDOMSanitizer' => __DIR__ . '/../..' . '/core/htmlsanitizer.class.inc.php', 'ScalarExpression' => __DIR__ . '/../..' . '/core/oql/expression.class.inc.php', 'ScalarOqlExpression' => __DIR__ . '/../..' . '/core/oql/oqlquery.class.inc.php', 'ScssPhp\\ScssPhp\\Base\\Range' => __DIR__ . '/..' . '/scssphp/scssphp/src/Base/Range.php', diff --git a/lib/composer/include_paths.php b/lib/composer/include_paths.php index 507c1ade7..d4fb96718 100644 --- a/lib/composer/include_paths.php +++ b/lib/composer/include_paths.php @@ -6,8 +6,8 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( + $vendorDir . '/pear/archive_tar', $vendorDir . '/pear/console_getopt', $vendorDir . '/pear/pear-core-minimal/src', $vendorDir . '/pear/pear_exception', - $vendorDir . '/pear/archive_tar', ); diff --git a/lib/composer/installed.json b/lib/composer/installed.json index 4676c9db6..4ee95dc23 100644 --- a/lib/composer/installed.json +++ b/lib/composer/installed.json @@ -2354,17 +2354,17 @@ }, { "name": "symfony/twig-bundle", - "version": "v3.4.36", - "version_normalized": "3.4.36.0", + "version": "v3.4.47", + "version_normalized": "3.4.47.0", "source": { "type": "git", "url": "https://github.com/symfony/twig-bundle.git", - "reference": "d39ed8f5df62aeeeb27a6f3bf7f58a6c02a58ea9" + "reference": "977b3096e2df96bc8a8d2329e83466cfc30c373d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/twig-bundle/zipball/d39ed8f5df62aeeeb27a6f3bf7f58a6c02a58ea9", - "reference": "d39ed8f5df62aeeeb27a6f3bf7f58a6c02a58ea9", + "url": "https://api.github.com/repos/symfony/twig-bundle/zipball/977b3096e2df96bc8a8d2329e83466cfc30c373d", + "reference": "977b3096e2df96bc8a8d2329e83466cfc30c373d", "shasum": "" }, "require": { @@ -2396,13 +2396,8 @@ "symfony/web-link": "~3.3|~4.0", "symfony/yaml": "~2.8|~3.0|~4.0" }, - "time": "2019-10-01T15:13:36+00:00", + "time": "2020-10-24T10:57:07+00:00", "type": "symfony-bundle", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, "installation-source": "dist", "autoload": { "psr-4": { @@ -2428,6 +2423,23 @@ ], "description": "Symfony TwigBundle", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/twig-bundle/tree/v3.4.47" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "install-path": "../symfony/twig-bundle" }, { diff --git a/lib/composer/installed.php b/lib/composer/installed.php index ac9065b0a..d48e79b7e 100644 --- a/lib/composer/installed.php +++ b/lib/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => 'fe3512cb5f5d01fa590447c2f6fa15416802b748', + 'reference' => 'b7f99d139c034935611802a6b2cf795e503427a2', 'name' => '__root__', 'dev' => true, ), @@ -16,7 +16,7 @@ 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => 'fe3512cb5f5d01fa590447c2f6fa15416802b748', + 'reference' => 'b7f99d139c034935611802a6b2cf795e503427a2', 'dev_requirement' => false, ), 'combodo/tcpdf' => array( @@ -383,12 +383,12 @@ 'dev_requirement' => false, ), 'symfony/twig-bundle' => array( - 'pretty_version' => 'v3.4.36', - 'version' => '3.4.36.0', + 'pretty_version' => 'v3.4.47', + 'version' => '3.4.47.0', 'type' => 'symfony-bundle', 'install_path' => __DIR__ . '/../symfony/twig-bundle', 'aliases' => array(), - 'reference' => 'd39ed8f5df62aeeeb27a6f3bf7f58a6c02a58ea9', + 'reference' => '977b3096e2df96bc8a8d2329e83466cfc30c373d', 'dev_requirement' => false, ), 'symfony/var-dumper' => array( diff --git a/lib/symfony/twig-bundle/CacheWarmer/TemplateCacheWarmer.php b/lib/symfony/twig-bundle/CacheWarmer/TemplateCacheWarmer.php index 23abdbf99..329e018c2 100644 --- a/lib/symfony/twig-bundle/CacheWarmer/TemplateCacheWarmer.php +++ b/lib/symfony/twig-bundle/CacheWarmer/TemplateCacheWarmer.php @@ -40,9 +40,9 @@ class TemplateCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInte $this->container = $container; } elseif ($container instanceof Environment) { $this->twig = $container; - @trigger_error(sprintf('Using a "%s" as first argument of %s is deprecated since Symfony 3.4 and will be unsupported in version 4.0. Use a %s instead.', Environment::class, __CLASS__, ContainerInterface::class), E_USER_DEPRECATED); + @trigger_error(sprintf('Using a "%s" as first argument of %s is deprecated since Symfony 3.4 and will be unsupported in version 4.0. Use a %s instead.', Environment::class, __CLASS__, ContainerInterface::class), \E_USER_DEPRECATED); } else { - throw new \InvalidArgumentException(sprintf('%s only accepts instance of Psr\Container\ContainerInterface as first argument.', __CLASS__)); + throw new \InvalidArgumentException(sprintf('"%s" only accepts instance of Psr\Container\ContainerInterface as first argument.', __CLASS__)); } $this->iterator = $iterator; diff --git a/lib/symfony/twig-bundle/Command/DebugCommand.php b/lib/symfony/twig-bundle/Command/DebugCommand.php index 107eece30..c04a28a9f 100644 --- a/lib/symfony/twig-bundle/Command/DebugCommand.php +++ b/lib/symfony/twig-bundle/Command/DebugCommand.php @@ -11,7 +11,7 @@ namespace Symfony\Bundle\TwigBundle\Command; -@trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use Symfony\Bridge\Twig\Command\DebugCommand instead.', DebugCommand::class), E_USER_DEPRECATED); +@trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use Symfony\Bridge\Twig\Command\DebugCommand instead.', DebugCommand::class), \E_USER_DEPRECATED); use Symfony\Bridge\Twig\Command\DebugCommand as BaseDebugCommand; use Symfony\Component\DependencyInjection\ContainerAwareInterface; diff --git a/lib/symfony/twig-bundle/ContainerAwareRuntimeLoader.php b/lib/symfony/twig-bundle/ContainerAwareRuntimeLoader.php index 7595f5674..47ec9a961 100644 --- a/lib/symfony/twig-bundle/ContainerAwareRuntimeLoader.php +++ b/lib/symfony/twig-bundle/ContainerAwareRuntimeLoader.php @@ -11,7 +11,7 @@ namespace Symfony\Bundle\TwigBundle; -@trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use the Twig\RuntimeLoader\ContainerRuntimeLoader class instead.', ContainerAwareRuntimeLoader::class), E_USER_DEPRECATED); +@trigger_error(sprintf('The %s class is deprecated since Symfony 3.3 and will be removed in 4.0. Use the Twig\RuntimeLoader\ContainerRuntimeLoader class instead.', ContainerAwareRuntimeLoader::class), \E_USER_DEPRECATED); use Psr\Log\LoggerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; diff --git a/lib/symfony/twig-bundle/DependencyInjection/Compiler/TwigLoaderPass.php b/lib/symfony/twig-bundle/DependencyInjection/Compiler/TwigLoaderPass.php index 51b6d9b4f..bd0c606a8 100644 --- a/lib/symfony/twig-bundle/DependencyInjection/Compiler/TwigLoaderPass.php +++ b/lib/symfony/twig-bundle/DependencyInjection/Compiler/TwigLoaderPass.php @@ -39,7 +39,7 @@ class TwigLoaderPass implements CompilerPassInterface } if (!$found) { - throw new LogicException('No twig loaders found. You need to tag at least one loader with "twig.loader"'); + throw new LogicException('No twig loaders found. You need to tag at least one loader with "twig.loader".'); } if (1 === $found) { diff --git a/lib/symfony/twig-bundle/LICENSE b/lib/symfony/twig-bundle/LICENSE index a677f4376..9e936ec04 100644 --- a/lib/symfony/twig-bundle/LICENSE +++ b/lib/symfony/twig-bundle/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2019 Fabien Potencier +Copyright (c) 2004-2020 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/lib/symfony/twig-bundle/Tests/ContainerAwareRuntimeLoaderTest.php b/lib/symfony/twig-bundle/Tests/ContainerAwareRuntimeLoaderTest.php new file mode 100644 index 000000000..88f8fb21e --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/ContainerAwareRuntimeLoaderTest.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests; + +use Psr\Log\LoggerInterface; +use Symfony\Bundle\TwigBundle\ContainerAwareRuntimeLoader; +use Symfony\Component\DependencyInjection\ContainerInterface; + +/** + * @group legacy + */ +class ContainerAwareRuntimeLoaderTest extends TestCase +{ + public function testLoad() + { + $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); + $container->expects($this->once())->method('get')->with('foo'); + + $loader = new ContainerAwareRuntimeLoader($container, [ + 'FooClass' => 'foo', + ]); + $loader->load('FooClass'); + } + + public function testLoadWithoutAMatch() + { + $logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); + $logger->expects($this->once())->method('warning')->with('Class "BarClass" is not configured as a Twig runtime. Add the "twig.runtime" tag to the related service in the container.'); + $loader = new ContainerAwareRuntimeLoader($this->getMockBuilder(ContainerInterface::class)->getMock(), [], $logger); + $this->assertNull($loader->load('BarClass')); + } +} diff --git a/lib/symfony/twig-bundle/Tests/Controller/ExceptionControllerTest.php b/lib/symfony/twig-bundle/Tests/Controller/ExceptionControllerTest.php new file mode 100644 index 000000000..800da68c9 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/Controller/ExceptionControllerTest.php @@ -0,0 +1,92 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests\Controller; + +use Symfony\Bundle\TwigBundle\Controller\ExceptionController; +use Symfony\Bundle\TwigBundle\Tests\TestCase; +use Symfony\Component\Debug\Exception\FlattenException; +use Symfony\Component\HttpFoundation\Request; +use Twig\Environment; +use Twig\Loader\ArrayLoader; + +class ExceptionControllerTest extends TestCase +{ + public function testShowActionCanBeForcedToShowErrorPage() + { + $twig = $this->createTwigEnv(['@Twig/Exception/error404.html.twig' => 'not found']); + + $request = $this->createRequest('html'); + $request->attributes->set('showException', false); + $exception = FlattenException::create(new \Exception(), 404); + $controller = new ExceptionController($twig, /* "showException" defaults to --> */ true); + + $response = $controller->showAction($request, $exception, null); + + $this->assertEquals(200, $response->getStatusCode()); // successful request + $this->assertEquals('not found', $response->getContent()); + } + + public function testFallbackToHtmlIfNoTemplateForRequestedFormat() + { + $twig = $this->createTwigEnv(['@Twig/Exception/error.html.twig' => '']); + + $request = $this->createRequest('txt'); + $exception = FlattenException::create(new \Exception()); + $controller = new ExceptionController($twig, false); + + $controller->showAction($request, $exception); + + $this->assertEquals('html', $request->getRequestFormat()); + } + + public function testFallbackToHtmlWithFullExceptionIfNoTemplateForRequestedFormatAndExceptionsShouldBeShown() + { + $twig = $this->createTwigEnv(['@Twig/Exception/exception_full.html.twig' => '']); + + $request = $this->createRequest('txt'); + $request->attributes->set('showException', true); + $exception = FlattenException::create(new \Exception()); + $controller = new ExceptionController($twig, false); + + $controller->showAction($request, $exception); + + $this->assertEquals('html', $request->getRequestFormat()); + } + + public function testResponseHasRequestedMimeType() + { + $twig = $this->createTwigEnv(['@Twig/Exception/error.json.twig' => '{}']); + + $request = $this->createRequest('json'); + $exception = FlattenException::create(new \Exception()); + $controller = new ExceptionController($twig, false); + + $response = $controller->showAction($request, $exception); + + $this->assertEquals('json', $request->getRequestFormat()); + $this->assertEquals($request->getMimeType('json'), $response->headers->get('Content-Type')); + } + + private function createRequest($requestFormat) + { + $request = Request::create('whatever'); + $request->headers->set('X-Php-Ob-Level', 1); + $request->setRequestFormat($requestFormat); + + return $request; + } + + private function createTwigEnv(array $templates) + { + return new Environment(new ArrayLoader($templates)); + } +} diff --git a/lib/symfony/twig-bundle/Tests/Controller/PreviewErrorControllerTest.php b/lib/symfony/twig-bundle/Tests/Controller/PreviewErrorControllerTest.php new file mode 100644 index 000000000..ae740e1ab --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/Controller/PreviewErrorControllerTest.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests\Controller; + +use Symfony\Bundle\TwigBundle\Controller\PreviewErrorController; +use Symfony\Bundle\TwigBundle\Tests\TestCase; +use Symfony\Component\Debug\Exception\FlattenException; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\HttpKernelInterface; + +class PreviewErrorControllerTest extends TestCase +{ + public function testForwardRequestToConfiguredController() + { + $request = Request::create('whatever'); + $response = new Response(''); + $code = 123; + $logicalControllerName = 'foo:bar:baz'; + + $kernel = $this->getMockBuilder('\Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); + $kernel + ->expects($this->once()) + ->method('handle') + ->with( + $this->callback(function (Request $request) use ($logicalControllerName, $code) { + $this->assertEquals($logicalControllerName, $request->attributes->get('_controller')); + + $exception = $request->attributes->get('exception'); + $this->assertInstanceOf(FlattenException::class, $exception); + $this->assertEquals($code, $exception->getStatusCode()); + $this->assertFalse($request->attributes->get('showException')); + + return true; + }), + $this->equalTo(HttpKernelInterface::SUB_REQUEST) + ) + ->willReturn($response); + + $controller = new PreviewErrorController($kernel, $logicalControllerName); + + $this->assertSame($response, $controller->previewErrorPageAction($request, $code)); + } +} diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php new file mode 100644 index 000000000..539a952a6 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection\Compiler; + +use PHPUnit\Framework\TestCase; +use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExtensionPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; + +class ExtensionPassTest extends TestCase +{ + public function testProcessDoesNotDropExistingFileLoaderMethodCalls() + { + $container = new ContainerBuilder(); + $container->setParameter('kernel.debug', false); + + $container->register('twig.app_variable', '\Symfony\Bridge\Twig\AppVariable'); + $container->register('templating', '\Symfony\Bundle\TwigBundle\TwigEngine'); + $container->register('twig.extension.yaml'); + $container->register('twig.extension.debug.stopwatch'); + $container->register('twig.extension.expression'); + + $nativeTwigLoader = new Definition('\Twig\Loader\FilesystemLoader'); + $nativeTwigLoader->addMethodCall('addPath', []); + $container->setDefinition('twig.loader.native_filesystem', $nativeTwigLoader); + + $filesystemLoader = new Definition('\Symfony\Bundle\TwigBundle\Loader\FilesystemLoader'); + $filesystemLoader->setArguments([null, null, null]); + $filesystemLoader->addMethodCall('addPath', []); + $container->setDefinition('twig.loader.filesystem', $filesystemLoader); + + $extensionPass = new ExtensionPass(); + $extensionPass->process($container); + + $this->assertCount(2, $filesystemLoader->getMethodCalls()); + } +} diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigEnvironmentPassTest.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigEnvironmentPassTest.php new file mode 100644 index 000000000..0af3fe4b3 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigEnvironmentPassTest.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection\Compiler; + +use PHPUnit\Framework\TestCase; +use Symfony\Bridge\Twig\Extension\FormExtension; +use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigEnvironmentPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; + +class TwigEnvironmentPassTest extends TestCase +{ + public function testTwigBridgeExtensionsAreRegisteredFirst() + { + $container = new ContainerBuilder(); + $twigDefinition = $container->register('twig'); + $container->register('other_extension', 'Foo\Bar') + ->addTag('twig.extension'); + $container->register('twig_bridge_extension', FormExtension::class) + ->addTag('twig.extension'); + + $twigEnvironmentPass = new TwigEnvironmentPass(); + $twigEnvironmentPass->process($container); + + $methodCalls = $twigDefinition->getMethodCalls(); + $this->assertCount(2, $methodCalls); + + $twigBridgeExtensionReference = $methodCalls[0][1][0]; + $this->assertInstanceOf(Reference::class, $twigBridgeExtensionReference); + $this->assertSame('twig_bridge_extension', (string) $twigBridgeExtensionReference); + + $otherExtensionReference = $methodCalls[1][1][0]; + $this->assertInstanceOf(Reference::class, $otherExtensionReference); + $this->assertSame('other_extension', (string) $otherExtensionReference); + } +} diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php new file mode 100644 index 000000000..a112b64b5 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php @@ -0,0 +1,95 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection\Compiler; + +use PHPUnit\Framework\TestCase; +use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigLoaderPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; + +class TwigLoaderPassTest extends TestCase +{ + /** + * @var ContainerBuilder + */ + private $builder; + /** + * @var Definition + */ + private $chainLoader; + /** + * @var TwigLoaderPass + */ + private $pass; + + protected function setUp() + { + $this->builder = new ContainerBuilder(); + $this->builder->register('twig'); + $this->chainLoader = new Definition('loader'); + $this->pass = new TwigLoaderPass(); + } + + public function testMapperPassWithOneTaggedLoader() + { + $this->builder->register('test_loader_1') + ->addTag('twig.loader'); + + $this->pass->process($this->builder); + + $this->assertSame('test_loader_1', (string) $this->builder->getAlias('twig.loader')); + } + + public function testMapperPassWithTwoTaggedLoaders() + { + $this->builder->setDefinition('twig.loader.chain', $this->chainLoader); + $this->builder->register('test_loader_1') + ->addTag('twig.loader'); + $this->builder->register('test_loader_2') + ->addTag('twig.loader'); + + $this->pass->process($this->builder); + + $this->assertSame('twig.loader.chain', (string) $this->builder->getAlias('twig.loader')); + $calls = $this->chainLoader->getMethodCalls(); + $this->assertCount(2, $calls); + $this->assertEquals('addLoader', $calls[0][0]); + $this->assertEquals('addLoader', $calls[1][0]); + $this->assertEquals('test_loader_1', (string) $calls[0][1][0]); + $this->assertEquals('test_loader_2', (string) $calls[1][1][0]); + } + + public function testMapperPassWithTwoTaggedLoadersWithPriority() + { + $this->builder->setDefinition('twig.loader.chain', $this->chainLoader); + $this->builder->register('test_loader_1') + ->addTag('twig.loader', ['priority' => 100]); + $this->builder->register('test_loader_2') + ->addTag('twig.loader', ['priority' => 200]); + + $this->pass->process($this->builder); + + $this->assertSame('twig.loader.chain', (string) $this->builder->getAlias('twig.loader')); + $calls = $this->chainLoader->getMethodCalls(); + $this->assertCount(2, $calls); + $this->assertEquals('addLoader', $calls[0][0]); + $this->assertEquals('addLoader', $calls[1][0]); + $this->assertEquals('test_loader_2', (string) $calls[0][1][0]); + $this->assertEquals('test_loader_1', (string) $calls[1][1][0]); + } + + public function testMapperPassWithZeroTaggedLoaders() + { + $this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException'); + $this->pass->process($this->builder); + } +} diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/ConfigurationTest.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/ConfigurationTest.php new file mode 100644 index 000000000..049d05b5c --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/ConfigurationTest.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection; + +use PHPUnit\Framework\TestCase; +use Symfony\Bundle\TwigBundle\DependencyInjection\Configuration; +use Symfony\Component\Config\Definition\Processor; + +class ConfigurationTest extends TestCase +{ + public function testDoNoDuplicateDefaultFormResources() + { + $input = [ + 'form_themes' => ['form_div_layout.html.twig'], + ]; + + $processor = new Processor(); + $config = $processor->processConfiguration(new Configuration(), [$input]); + + $this->assertEquals(['form_div_layout.html.twig'], $config['form_themes']); + } +} diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views/layout.html.twig new file mode 100644 index 000000000..bb07ecfe5 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views/layout.html.twig @@ -0,0 +1 @@ +This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views/layout.html.twig new file mode 100644 index 000000000..bb07ecfe5 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views/layout.html.twig @@ -0,0 +1 @@ +This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/views/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/views/layout.html.twig new file mode 100644 index 000000000..bb07ecfe5 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/views/layout.html.twig @@ -0,0 +1 @@ +This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/views/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/views/layout.html.twig new file mode 100644 index 000000000..bb07ecfe5 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/views/layout.html.twig @@ -0,0 +1 @@ +This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/TwigBundle/views/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/TwigBundle/views/layout.html.twig new file mode 100644 index 000000000..bb07ecfe5 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/TwigBundle/views/layout.html.twig @@ -0,0 +1 @@ +This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/views/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/views/layout.html.twig new file mode 100644 index 000000000..bb07ecfe5 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/views/layout.html.twig @@ -0,0 +1 @@ +This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php new file mode 100644 index 000000000..c9acb3c25 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php @@ -0,0 +1,6 @@ +loadFromExtension('twig', [ + 'autoescape_service' => 'my_project.some_bundle.template_escaping_guesser', + 'autoescape_service_method' => 'guess', +]); diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/empty.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/empty.php new file mode 100644 index 000000000..d107fd90d --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/empty.php @@ -0,0 +1,3 @@ +loadFromExtension('twig', []); diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/extra.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/extra.php new file mode 100644 index 000000000..49acc87a8 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/extra.php @@ -0,0 +1,7 @@ +loadFromExtension('twig', [ + 'paths' => [ + 'namespaced_path3' => 'namespace3', + ], +]); diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/formats.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/formats.php new file mode 100644 index 000000000..7e8573880 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/formats.php @@ -0,0 +1,14 @@ +loadFromExtension('twig', [ + 'date' => [ + 'format' => 'Y-m-d', + 'interval_format' => '%d', + 'timezone' => 'Europe/Berlin', + ], + 'number_format' => [ + 'decimals' => 2, + 'decimal_point' => ',', + 'thousands_separator' => '.', + ], +]); diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/full.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/full.php new file mode 100644 index 000000000..8dd2be409 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/full.php @@ -0,0 +1,27 @@ +loadFromExtension('twig', [ + 'form_themes' => [ + 'MyBundle::form.html.twig', + ], + 'globals' => [ + 'foo' => '@bar', + 'baz' => '@@qux', + 'pi' => 3.14, + 'bad' => ['key' => 'foo'], + ], + 'auto_reload' => true, + 'autoescape' => true, + 'base_template_class' => 'stdClass', + 'cache' => '/tmp', + 'charset' => 'ISO-8859-1', + 'debug' => true, + 'strict_variables' => true, + 'default_path' => '%kernel.project_dir%/Fixtures/templates', + 'paths' => [ + 'path1', + 'path2', + 'namespaced_path1' => 'namespace1', + 'namespaced_path2' => 'namespace2', + ], +]); diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/BarBundle/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/BarBundle/layout.html.twig new file mode 100644 index 000000000..bb07ecfe5 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/BarBundle/layout.html.twig @@ -0,0 +1 @@ +This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/TwigBundle/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/TwigBundle/layout.html.twig new file mode 100644 index 000000000..bb07ecfe5 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/TwigBundle/layout.html.twig @@ -0,0 +1 @@ +This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/layout.html.twig new file mode 100644 index 000000000..bb07ecfe5 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/layout.html.twig @@ -0,0 +1 @@ +This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml new file mode 100644 index 000000000..f72bed9d1 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/empty.xml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/empty.xml new file mode 100644 index 000000000..f3b51fa24 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/empty.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/extra.xml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/extra.xml new file mode 100644 index 000000000..17bcf0acd --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/extra.xml @@ -0,0 +1,12 @@ + + + + + + namespaced_path3 + + diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/formats.xml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/formats.xml new file mode 100644 index 000000000..fa888b30a --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/formats.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/full.xml new file mode 100644 index 000000000..8ece3b80b --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/full.xml @@ -0,0 +1,19 @@ + + + + + + MyBundle::form.html.twig + + @@qux + 3.14 + path1 + path2 + namespaced_path1 + namespaced_path2 + + diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml new file mode 100644 index 000000000..eb26e7165 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml @@ -0,0 +1,3 @@ +twig: + autoescape_service: my_project.some_bundle.template_escaping_guesser + autoescape_service_method: guess diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/empty.yml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/empty.yml new file mode 100644 index 000000000..a472b2698 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/empty.yml @@ -0,0 +1 @@ +twig: diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/extra.yml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/extra.yml new file mode 100644 index 000000000..3c5e6a3b5 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/extra.yml @@ -0,0 +1,3 @@ +twig: + paths: + namespaced_path3: namespace3 diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/formats.yml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/formats.yml new file mode 100644 index 000000000..290921630 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/formats.yml @@ -0,0 +1,9 @@ +twig: + date: + format: Y-m-d + interval_format: '%d' + timezone: Europe/Berlin + number_format: + decimals: 2 + decimal_point: ',' + thousands_separator: . diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/full.yml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/full.yml new file mode 100644 index 000000000..24c10c23f --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/full.yml @@ -0,0 +1,21 @@ +twig: + form_themes: + - MyBundle::form.html.twig + globals: + foo: "@bar" + baz: "@@qux" + pi: 3.14 + bad: {key: foo} + auto_reload: true + autoescape: true + base_template_class: stdClass + cache: /tmp + charset: ISO-8859-1 + debug: true + strict_variables: true + default_path: '%kernel.project_dir%/Fixtures/templates' + paths: + path1: '' + path2: '' + namespaced_path1: namespace1 + namespaced_path2: namespace2 diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/TwigExtensionTest.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/TwigExtensionTest.php new file mode 100644 index 000000000..7e14857fa --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -0,0 +1,355 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection; + +use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\RuntimeLoaderPass; +use Symfony\Bundle\TwigBundle\DependencyInjection\TwigExtension; +use Symfony\Bundle\TwigBundle\Tests\TestCase; +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\Compiler\PassConfig; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; +use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; +use Symfony\Component\DependencyInjection\Reference; + +class TwigExtensionTest extends TestCase +{ + public function testLoadEmptyConfiguration() + { + $container = $this->createContainer(); + $container->registerExtension(new TwigExtension()); + $container->loadFromExtension('twig', []); + $this->compileContainer($container); + + $this->assertEquals('Twig\Environment', $container->getDefinition('twig')->getClass(), '->load() loads the twig.xml file'); + + $this->assertContains('form_div_layout.html.twig', $container->getParameter('twig.form.resources'), '->load() includes default template for form resources'); + + // Twig options + $options = $container->getDefinition('twig')->getArgument(1); + $this->assertEquals('%kernel.cache_dir%/twig', $options['cache'], '->load() sets default value for cache option'); + $this->assertEquals('%kernel.charset%', $options['charset'], '->load() sets default value for charset option'); + $this->assertEquals('%kernel.debug%', $options['debug'], '->load() sets default value for debug option'); + } + + /** + * @dataProvider getFormats + */ + public function testLoadFullConfiguration($format) + { + $container = $this->createContainer(); + $container->registerExtension(new TwigExtension()); + $this->loadFromFile($container, 'full', $format); + $this->compileContainer($container); + + $this->assertEquals('Twig\Environment', $container->getDefinition('twig')->getClass(), '->load() loads the twig.xml file'); + + // Form resources + $resources = $container->getParameter('twig.form.resources'); + $this->assertContains('form_div_layout.html.twig', $resources, '->load() includes default template for form resources'); + $this->assertContains('MyBundle::form.html.twig', $resources, '->load() merges new templates into form resources'); + + // Globals + $calls = $container->getDefinition('twig')->getMethodCalls(); + $this->assertEquals('app', $calls[0][1][0], '->load() registers services as Twig globals'); + $this->assertEquals(new Reference('twig.app_variable'), $calls[0][1][1]); + $this->assertEquals('foo', $calls[2][1][0], '->load() registers services as Twig globals'); + $this->assertEquals(new Reference('bar'), $calls[2][1][1], '->load() registers services as Twig globals'); + $this->assertEquals('baz', $calls[3][1][0], '->load() registers variables as Twig globals'); + $this->assertEquals('@qux', $calls[3][1][1], '->load() allows escaping of service identifiers'); + $this->assertEquals('pi', $calls[4][1][0], '->load() registers variables as Twig globals'); + $this->assertEquals(3.14, $calls[4][1][1], '->load() registers variables as Twig globals'); + + // Yaml and Php specific configs + if (\in_array($format, ['yml', 'php'])) { + $this->assertEquals('bad', $calls[5][1][0], '->load() registers variables as Twig globals'); + $this->assertEquals(['key' => 'foo'], $calls[5][1][1], '->load() registers variables as Twig globals'); + } + + // Twig options + $options = $container->getDefinition('twig')->getArgument(1); + $this->assertTrue($options['auto_reload'], '->load() sets the auto_reload option'); + $this->assertTrue($options['autoescape'], '->load() sets the autoescape option'); + $this->assertEquals('stdClass', $options['base_template_class'], '->load() sets the base_template_class option'); + $this->assertEquals('/tmp', $options['cache'], '->load() sets the cache option'); + $this->assertEquals('ISO-8859-1', $options['charset'], '->load() sets the charset option'); + $this->assertTrue($options['debug'], '->load() sets the debug option'); + $this->assertTrue($options['strict_variables'], '->load() sets the strict_variables option'); + } + + /** + * @dataProvider getFormats + */ + public function testLoadCustomTemplateEscapingGuesserConfiguration($format) + { + $container = $this->createContainer(); + $container->registerExtension(new TwigExtension()); + $this->loadFromFile($container, 'customTemplateEscapingGuesser', $format); + $this->compileContainer($container); + + $options = $container->getDefinition('twig')->getArgument(1); + $this->assertEquals([new Reference('my_project.some_bundle.template_escaping_guesser'), 'guess'], $options['autoescape']); + } + + /** + * @dataProvider getFormats + */ + public function testLoadDefaultTemplateEscapingGuesserConfiguration($format) + { + $container = $this->createContainer(); + $container->registerExtension(new TwigExtension()); + $this->loadFromFile($container, 'empty', $format); + $this->compileContainer($container); + + $options = $container->getDefinition('twig')->getArgument(1); + $this->assertEquals('name', $options['autoescape']); + } + + /** + * @dataProvider getFormats + */ + public function testLoadCustomDateFormats($fileFormat) + { + $container = $this->createContainer(); + $container->registerExtension(new TwigExtension()); + $this->loadFromFile($container, 'formats', $fileFormat); + $this->compileContainer($container); + + $environmentConfigurator = $container->getDefinition('twig.configurator.environment'); + + $this->assertSame('Y-m-d', $environmentConfigurator->getArgument(0)); + $this->assertSame('%d', $environmentConfigurator->getArgument(1)); + $this->assertSame('Europe/Berlin', $environmentConfigurator->getArgument(2)); + $this->assertSame(2, $environmentConfigurator->getArgument(3)); + $this->assertSame(',', $environmentConfigurator->getArgument(4)); + $this->assertSame('.', $environmentConfigurator->getArgument(5)); + } + + public function testGlobalsWithDifferentTypesAndValues() + { + $globals = [ + 'array' => [], + 'false' => false, + 'float' => 2.0, + 'integer' => 3, + 'null' => null, + 'object' => new \stdClass(), + 'string' => 'foo', + 'true' => true, + ]; + + $container = $this->createContainer(); + $container->registerExtension(new TwigExtension()); + $container->loadFromExtension('twig', ['globals' => $globals]); + $this->compileContainer($container); + + $calls = $container->getDefinition('twig')->getMethodCalls(); + foreach (\array_slice($calls, 2) as $call) { + $this->assertEquals(key($globals), $call[1][0]); + $this->assertSame(current($globals), $call[1][1]); + + next($globals); + } + } + + /** + * @dataProvider getFormats + */ + public function testTwigLoaderPaths($format) + { + $container = $this->createContainer(); + $container->registerExtension(new TwigExtension()); + $this->loadFromFile($container, 'full', $format); + $this->loadFromFile($container, 'extra', $format); + $this->compileContainer($container); + + $def = $container->getDefinition('twig.loader.native_filesystem'); + $paths = []; + foreach ($def->getMethodCalls() as $call) { + if ('addPath' === $call[0] && false === strpos($call[1][0], 'Form')) { + $paths[] = $call[1]; + } + } + + $this->assertEquals([ + ['path1'], + ['path2'], + ['namespaced_path1', 'namespace1'], + ['namespaced_path2', 'namespace2'], + ['namespaced_path3', 'namespace3'], + [__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildChildChildChildTwig'], + [__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildChildChildTwig'], + [__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildChildChildTwig'], + [__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'Twig'], + [__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'Twig'], + [__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'Twig'], + [__DIR__.'/Fixtures/Bundle/ChildTwigBundle/Resources/views', 'Twig'], + [__DIR__.'/Fixtures/Resources/TwigBundle/views', 'Twig'], + [__DIR__.'/Fixtures/templates/bundles/TwigBundle', 'Twig'], + [realpath(__DIR__.'/../..').'/Resources/views', 'Twig'], + [realpath(__DIR__.'/../..').'/Resources/views', '!Twig'], + [__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildTwig'], + [__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildTwig'], + [__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'ChildTwig'], + [__DIR__.'/Fixtures/Bundle/ChildTwigBundle/Resources/views', 'ChildTwig'], + [__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildChildTwig'], + [__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildChildTwig'], + [__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'ChildChildTwig'], + [__DIR__.'/Fixtures/Resources/views'], + [__DIR__.'/Fixtures/templates'], + ], $paths); + } + + public function getFormats() + { + return [ + ['php'], + ['yml'], + ['xml'], + ]; + } + + /** + * @dataProvider stopwatchExtensionAvailabilityProvider + */ + public function testStopwatchExtensionAvailability($debug, $stopwatchEnabled, $expected) + { + $container = $this->createContainer(); + $container->setParameter('kernel.debug', $debug); + if ($stopwatchEnabled) { + $container->register('debug.stopwatch', 'Symfony\Component\Stopwatch\Stopwatch'); + } + $container->registerExtension(new TwigExtension()); + $container->loadFromExtension('twig', []); + $container->setAlias('test.twig.extension.debug.stopwatch', 'twig.extension.debug.stopwatch')->setPublic(true); + $this->compileContainer($container); + + $tokenParsers = $container->get('test.twig.extension.debug.stopwatch')->getTokenParsers(); + $stopwatchIsAvailable = new \ReflectionProperty($tokenParsers[0], 'stopwatchIsAvailable'); + $stopwatchIsAvailable->setAccessible(true); + + $this->assertSame($expected, $stopwatchIsAvailable->getValue($tokenParsers[0])); + } + + public function stopwatchExtensionAvailabilityProvider() + { + return [ + 'debug-and-stopwatch-enabled' => [true, true, true], + 'only-stopwatch-enabled' => [false, true, false], + 'only-debug-enabled' => [true, false, false], + 'debug-and-stopwatch-disabled' => [false, false, false], + ]; + } + + public function testRuntimeLoader() + { + $container = $this->createContainer(); + $container->registerExtension(new TwigExtension()); + $container->loadFromExtension('twig', []); + $container->setParameter('kernel.environment', 'test'); + $container->setParameter('debug.file_link_format', 'test'); + $container->setParameter('foo', 'FooClass'); + $container->register('http_kernel', 'FooClass'); + $container->register('templating.locator', 'FooClass'); + $container->register('templating.name_parser', 'FooClass'); + $container->register('foo', '%foo%')->addTag('twig.runtime'); + $container->addCompilerPass(new RuntimeLoaderPass(), PassConfig::TYPE_BEFORE_REMOVING); + $container->getCompilerPassConfig()->setRemovingPasses([]); + $container->getCompilerPassConfig()->setAfterRemovingPasses([]); + $container->compile(); + + $loader = $container->getDefinition('twig.runtime_loader'); + $args = $container->getDefinition((string) $loader->getArgument(0))->getArgument(0); + $this->assertArrayHasKey('Symfony\Component\Form\FormRenderer', $args); + $this->assertArrayHasKey('FooClass', $args); + $this->assertEquals('twig.form.renderer', $args['Symfony\Component\Form\FormRenderer']->getValues()[0]); + $this->assertEquals('foo', $args['FooClass']->getValues()[0]); + } + + private function createContainer() + { + $container = new ContainerBuilder(new ParameterBag([ + 'kernel.cache_dir' => __DIR__, + 'kernel.root_dir' => __DIR__.'/Fixtures', + 'kernel.project_dir' => __DIR__, + 'kernel.charset' => 'UTF-8', + 'kernel.debug' => false, + 'kernel.bundles' => [ + 'TwigBundle' => 'Symfony\\Bundle\\TwigBundle\\TwigBundle', + 'ChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildTwigBundle\\ChildTwigBundle', + 'ChildChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildTwigBundle\\ChildChildTwigBundle', + 'ChildChildChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildTwigBundle\\ChildChildChildTwigBundle', + 'ChildChildChildChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildChildTwigBundle\\ChildChildChildChildTwigBundle', + ], + 'kernel.bundles_metadata' => [ + 'ChildChildChildChildTwigBundle' => [ + 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildChildTwigBundle\\ChildChildChildChildTwigBundle', + 'parent' => 'ChildChildChildTwigBundle', + 'path' => __DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle', + ], + 'TwigBundle' => [ + 'namespace' => 'Symfony\\Bundle\\TwigBundle', + 'parent' => null, + 'path' => realpath(__DIR__.'/../..'), + ], + 'ChildTwigBundle' => [ + 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildTwigBundle\\ChildTwigBundle', + 'parent' => 'TwigBundle', + 'path' => __DIR__.'/Fixtures/Bundle/ChildTwigBundle', + ], + 'ChildChildChildTwigBundle' => [ + 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildTwigBundle\\ChildChildChildTwigBundle', + 'parent' => 'ChildChildTwigBundle', + 'path' => __DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle', + ], + 'ChildChildTwigBundle' => [ + 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildTwigBundle\\ChildChildTwigBundle', + 'parent' => 'ChildTwigBundle', + 'path' => __DIR__.'/Fixtures/Bundle/ChildChildTwigBundle', + ], + ], + ])); + + return $container; + } + + private function compileContainer(ContainerBuilder $container) + { + $container->getCompilerPassConfig()->setOptimizationPasses([]); + $container->getCompilerPassConfig()->setRemovingPasses([]); + $container->getCompilerPassConfig()->setAfterRemovingPasses([]); + $container->compile(); + } + + private function loadFromFile(ContainerBuilder $container, $file, $format) + { + $locator = new FileLocator(__DIR__.'/Fixtures/'.$format); + + switch ($format) { + case 'php': + $loader = new PhpFileLoader($container, $locator); + break; + case 'xml': + $loader = new XmlFileLoader($container, $locator); + break; + case 'yml': + $loader = new YamlFileLoader($container, $locator); + break; + default: + throw new \InvalidArgumentException(sprintf('Unsupported format: "%s"', $format)); + } + + $loader->load($file.'.'.$format); + } +} diff --git a/lib/symfony/twig-bundle/Tests/Fixtures/templates/BarBundle/Resources/views/index.html.twig b/lib/symfony/twig-bundle/Tests/Fixtures/templates/BarBundle/Resources/views/index.html.twig new file mode 100644 index 000000000..1975b0e15 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/Fixtures/templates/BarBundle/Resources/views/index.html.twig @@ -0,0 +1 @@ +{# Twig template #} diff --git a/lib/symfony/twig-bundle/Tests/Fixtures/templates/Foo/index.html.twig b/lib/symfony/twig-bundle/Tests/Fixtures/templates/Foo/index.html.twig new file mode 100644 index 000000000..1975b0e15 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/Fixtures/templates/Foo/index.html.twig @@ -0,0 +1 @@ +{# Twig template #} diff --git a/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/BarBundle/views/base.html.twig b/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/BarBundle/views/base.html.twig new file mode 100644 index 000000000..e69de29bb diff --git a/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/layout.html.twig b/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/layout.html.twig new file mode 100644 index 000000000..1975b0e15 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/layout.html.twig @@ -0,0 +1 @@ +{# Twig template #} diff --git a/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/sub/sub.html.twig b/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/sub/sub.html.twig new file mode 100644 index 000000000..1975b0e15 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/sub/sub.html.twig @@ -0,0 +1 @@ +{# Twig template #} diff --git a/lib/symfony/twig-bundle/Tests/Functional/CacheWarmingTest.php b/lib/symfony/twig-bundle/Tests/Functional/CacheWarmingTest.php new file mode 100644 index 000000000..63710a8e1 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/Functional/CacheWarmingTest.php @@ -0,0 +1,124 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests\Functional; + +use Symfony\Bundle\FrameworkBundle\FrameworkBundle; +use Symfony\Bundle\TwigBundle\Tests\TestCase; +use Symfony\Bundle\TwigBundle\TwigBundle; +use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\HttpKernel\Kernel; + +class CacheWarmingTest extends TestCase +{ + public function testCacheIsProperlyWarmedWhenTemplatingIsAvailable() + { + $kernel = new CacheWarmingKernel(true); + $kernel->boot(); + + $warmer = $kernel->getContainer()->get('cache_warmer'); + $warmer->enableOptionalWarmers(); + $warmer->warmUp($kernel->getCacheDir()); + + $this->assertFileExists($kernel->getCacheDir().'/twig'); + } + + public function testCacheIsProperlyWarmedWhenTemplatingIsDisabled() + { + $kernel = new CacheWarmingKernel(false); + $kernel->boot(); + + $warmer = $kernel->getContainer()->get('cache_warmer'); + $warmer->enableOptionalWarmers(); + $warmer->warmUp($kernel->getCacheDir()); + + $this->assertFileExists($kernel->getCacheDir().'/twig'); + } + + protected function setUp() + { + $this->deleteTempDir(); + } + + protected function tearDown() + { + $this->deleteTempDir(); + } + + private function deleteTempDir() + { + if (!file_exists($dir = sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel')) { + return; + } + + $fs = new Filesystem(); + $fs->remove($dir); + } +} + +class CacheWarmingKernel extends Kernel +{ + private $withTemplating; + + public function __construct($withTemplating) + { + $this->withTemplating = $withTemplating; + + parent::__construct(($withTemplating ? 'with' : 'without').'_templating', true); + } + + public function getName() + { + return 'CacheWarming'; + } + + public function registerBundles() + { + return [new FrameworkBundle(), new TwigBundle()]; + } + + public function registerContainerConfiguration(LoaderInterface $loader) + { + $loader->load(function ($container) { + $container->loadFromExtension('framework', [ + 'secret' => '$ecret', + 'form' => ['enabled' => false], + ]); + }); + + if ($this->withTemplating) { + $loader->load(function ($container) { + $container->loadFromExtension('framework', [ + 'secret' => '$ecret', + 'templating' => ['engines' => ['twig']], + 'router' => ['resource' => '%kernel.project_dir%/Resources/config/empty_routing.yml'], + 'form' => ['enabled' => false], + ]); + }); + } + } + + public function getProjectDir() + { + return __DIR__; + } + + public function getCacheDir() + { + return sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel/cache/'.$this->environment; + } + + public function getLogDir() + { + return sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel/logs'; + } +} diff --git a/lib/symfony/twig-bundle/Tests/Functional/EmptyAppTest.php b/lib/symfony/twig-bundle/Tests/Functional/EmptyAppTest.php new file mode 100644 index 000000000..86d933b55 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/Functional/EmptyAppTest.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests\Functional; + +use Symfony\Bundle\TwigBundle\Tests\TestCase; +use Symfony\Bundle\TwigBundle\TwigBundle; +use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\HttpKernel\Kernel; + +class EmptyAppTest extends TestCase +{ + public function testBootEmptyApp() + { + $kernel = new EmptyAppKernel('test', true); + $kernel->boot(); + + $this->assertTrue($kernel->getContainer()->hasParameter('twig.default_path')); + $this->assertNotEmpty($kernel->getContainer()->getParameter('twig.default_path')); + } +} + +class EmptyAppKernel extends Kernel +{ + public function registerBundles() + { + return [new TwigBundle()]; + } + + public function registerContainerConfiguration(LoaderInterface $loader) + { + } + + public function getCacheDir() + { + return sys_get_temp_dir().'/'.Kernel::VERSION.'/EmptyAppKernel/cache/'.$this->environment; + } + + public function getLogDir() + { + return sys_get_temp_dir().'/'.Kernel::VERSION.'/EmptyAppKernel/logs'; + } +} diff --git a/lib/symfony/twig-bundle/Tests/Functional/NoTemplatingEntryTest.php b/lib/symfony/twig-bundle/Tests/Functional/NoTemplatingEntryTest.php new file mode 100644 index 000000000..3d509c44e --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/Functional/NoTemplatingEntryTest.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests\Functional; + +use Symfony\Bundle\FrameworkBundle\FrameworkBundle; +use Symfony\Bundle\TwigBundle\Tests\TestCase; +use Symfony\Bundle\TwigBundle\TwigBundle; +use Symfony\Component\Config\Loader\LoaderInterface; +use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\HttpKernel\Kernel; + +class NoTemplatingEntryTest extends TestCase +{ + public function test() + { + $kernel = new NoTemplatingEntryKernel('dev', true); + $kernel->boot(); + + $container = $kernel->getContainer(); + $content = $container->get('twig')->render('index.html.twig'); + $this->assertStringContainsString('{ a: b }', $content); + } + + protected function setUp() + { + $this->deleteTempDir(); + } + + protected function tearDown() + { + $this->deleteTempDir(); + } + + protected function deleteTempDir() + { + if (!file_exists($dir = sys_get_temp_dir().'/'.Kernel::VERSION.'/NoTemplatingEntryKernel')) { + return; + } + + $fs = new Filesystem(); + $fs->remove($dir); + } +} + +class NoTemplatingEntryKernel extends Kernel +{ + public function registerBundles() + { + return [new FrameworkBundle(), new TwigBundle()]; + } + + public function registerContainerConfiguration(LoaderInterface $loader) + { + $loader->load(function ($container) { + $container->loadFromExtension('framework', [ + 'secret' => '$ecret', + 'form' => ['enabled' => false], + ]); + }); + } + + public function getCacheDir() + { + return sys_get_temp_dir().'/'.Kernel::VERSION.'/NoTemplatingEntryKernel/cache/'.$this->environment; + } + + public function getLogDir() + { + return sys_get_temp_dir().'/'.Kernel::VERSION.'/NoTemplatingEntryKernel/logs'; + } +} diff --git a/lib/symfony/twig-bundle/Tests/Functional/Resources/config/empty_routing.yml b/lib/symfony/twig-bundle/Tests/Functional/Resources/config/empty_routing.yml new file mode 100644 index 000000000..e69de29bb diff --git a/lib/symfony/twig-bundle/Tests/Functional/Resources/views/index.html.twig b/lib/symfony/twig-bundle/Tests/Functional/Resources/views/index.html.twig new file mode 100644 index 000000000..ddc4eb440 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/Functional/Resources/views/index.html.twig @@ -0,0 +1 @@ +{{ {a: 'b'}|yaml_encode }} diff --git a/lib/symfony/twig-bundle/Tests/Loader/FilesystemLoaderTest.php b/lib/symfony/twig-bundle/Tests/Loader/FilesystemLoaderTest.php new file mode 100644 index 000000000..c8958670a --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/Loader/FilesystemLoaderTest.php @@ -0,0 +1,125 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests\Loader; + +use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; +use Symfony\Bundle\TwigBundle\Loader\FilesystemLoader; +use Symfony\Bundle\TwigBundle\Tests\TestCase; + +class FilesystemLoaderTest extends TestCase +{ + public function testGetSourceContext() + { + $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); + $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $locator + ->expects($this->once()) + ->method('locate') + ->willReturn(__DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig') + ; + $loader = new FilesystemLoader($locator, $parser); + $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views', 'namespace'); + + // Twig-style + $this->assertEquals("This is a layout\n", $loader->getSourceContext('@namespace/layout.html.twig')->getCode()); + + // Symfony-style + $this->assertEquals("This is a layout\n", $loader->getSourceContext('TwigBundle::layout.html.twig')->getCode()); + } + + public function testExists() + { + // should return true for templates that Twig does not find, but Symfony does + $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); + $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $locator + ->expects($this->once()) + ->method('locate') + ->willReturn($template = __DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig') + ; + $loader = new FilesystemLoader($locator, $parser); + + $this->assertTrue($loader->exists($template)); + } + + public function testTwigErrorIfLocatorThrowsInvalid() + { + $this->expectException('Twig\Error\LoaderError'); + $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); + $parser + ->expects($this->once()) + ->method('parse') + ->with('name.format.engine') + ->willReturn(new TemplateReference('', '', 'name', 'format', 'engine')) + ; + + $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $locator + ->expects($this->once()) + ->method('locate') + ->willThrowException(new \InvalidArgumentException('Unable to find template "NonExistent".')) + ; + + $loader = new FilesystemLoader($locator, $parser); + $loader->getCacheKey('name.format.engine'); + } + + public function testTwigErrorIfLocatorReturnsFalse() + { + $this->expectException('Twig\Error\LoaderError'); + $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); + $parser + ->expects($this->once()) + ->method('parse') + ->with('name.format.engine') + ->willReturn(new TemplateReference('', '', 'name', 'format', 'engine')) + ; + + $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + $locator + ->expects($this->once()) + ->method('locate') + ->willReturn(false) + ; + + $loader = new FilesystemLoader($locator, $parser); + $loader->getCacheKey('name.format.engine'); + } + + public function testTwigErrorIfTemplateDoesNotExist() + { + $this->expectException('Twig\Error\LoaderError'); + $this->expectExceptionMessageMatches('/Unable to find template "name\.format\.engine" \(looked into: .*Tests.Loader.\.\..DependencyInjection.Fixtures.Resources.views\)/'); + $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); + $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + + $loader = new FilesystemLoader($locator, $parser); + $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views'); + + $method = new \ReflectionMethod('Symfony\Bundle\TwigBundle\Loader\FilesystemLoader', 'findTemplate'); + $method->setAccessible(true); + $method->invoke($loader, 'name.format.engine'); + } + + public function testTwigSoftErrorIfTemplateDoesNotExist() + { + $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); + $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); + + $loader = new FilesystemLoader($locator, $parser); + $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views'); + + $method = new \ReflectionMethod('Symfony\Bundle\TwigBundle\Loader\FilesystemLoader', 'findTemplate'); + $method->setAccessible(true); + $this->assertFalse($method->invoke($loader, 'name.format.engine', false)); + } +} diff --git a/lib/symfony/twig-bundle/Tests/TemplateIteratorTest.php b/lib/symfony/twig-bundle/Tests/TemplateIteratorTest.php new file mode 100644 index 000000000..b9092af3e --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/TemplateIteratorTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests; + +use Symfony\Bundle\TwigBundle\TemplateIterator; + +class TemplateIteratorTest extends TestCase +{ + public function testGetIterator() + { + $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); + $bundle->expects($this->any())->method('getName')->willReturn('BarBundle'); + $bundle->expects($this->any())->method('getPath')->willReturn(__DIR__.'/Fixtures/templates/BarBundle'); + + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock(); + $kernel->expects($this->any())->method('getBundles')->willReturn([ + $bundle, + ]); + $iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', [__DIR__.'/Fixtures/templates/Foo' => 'Foo'], __DIR__.'/DependencyInjection/Fixtures/templates'); + + $sorted = iterator_to_array($iterator); + sort($sorted); + $this->assertEquals( + [ + '@Bar/base.html.twig', + '@Bar/index.html.twig', + '@Bar/layout.html.twig', + '@Foo/index.html.twig', + 'layout.html.twig', + 'sub/sub.html.twig', + ], + $sorted + ); + } +} diff --git a/lib/symfony/twig-bundle/Tests/TestCase.php b/lib/symfony/twig-bundle/Tests/TestCase.php new file mode 100644 index 000000000..800be3008 --- /dev/null +++ b/lib/symfony/twig-bundle/Tests/TestCase.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\TwigBundle\Tests; + +use PHPUnit\Framework\TestCase as PHPUnitTestCase; + +class TestCase extends PHPUnitTestCase +{ +} diff --git a/lib/symfony/twig-bundle/TwigBundle.php b/lib/symfony/twig-bundle/TwigBundle.php index bd766c152..5a353833e 100644 --- a/lib/symfony/twig-bundle/TwigBundle.php +++ b/lib/symfony/twig-bundle/TwigBundle.php @@ -32,7 +32,8 @@ class TwigBundle extends Bundle { parent::build($container); - $container->addCompilerPass(new ExtensionPass()); + // ExtensionPass must be run before the FragmentRendererPass as it adds tags that are processed later + $container->addCompilerPass(new ExtensionPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10); $container->addCompilerPass(new TwigEnvironmentPass()); $container->addCompilerPass(new TwigLoaderPass()); $container->addCompilerPass(new ExceptionListenerPass()); diff --git a/lib/symfony/twig-bundle/composer.json b/lib/symfony/twig-bundle/composer.json index f48e3bc07..16c0888ef 100644 --- a/lib/symfony/twig-bundle/composer.json +++ b/lib/symfony/twig-bundle/composer.json @@ -50,10 +50,5 @@ "/Tests/" ] }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - } + "minimum-stability": "dev" } From 606bdc190996526a55396c9917a288223fefcc32 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Fri, 28 Jan 2022 10:27:47 +0100 Subject: [PATCH 04/14] =?UTF-8?q?N=C2=B03129=20PHP=208.0=20compat:=20Fix?= =?UTF-8?q?=20"Access=20level=20to=20MFElement::ReplaceWith()=20must=20be?= =?UTF-8?q?=20public=20(as=20in=20class=20DOMElement)"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/modelfactory.class.inc.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/setup/modelfactory.class.inc.php b/setup/modelfactory.class.inc.php index 5fff67007..a0817bfec 100644 --- a/setup/modelfactory.class.inc.php +++ b/setup/modelfactory.class.inc.php @@ -2161,7 +2161,7 @@ class MFElement extends Combodo\iTop\DesignElement EOF; throw new MFException($sExceptionMessage, MFException::COULD_NOT_BE_ADDED, $iLine, $sPath); } - $oExisting->ReplaceWith($oNode); + $oExisting->MFReplaceWith($oNode); $sFlag = 'replaced'; } else @@ -2208,7 +2208,7 @@ EOF; throw new MFException($sPath." at line $iLine: could not be modified (marked as deleted)", MFException::COULD_NOT_BE_MODIFIED_ALREADY_DELETED, $sPath, $iLine); } - $oExisting->ReplaceWith($oNode); + $oExisting->MFReplaceWith($oNode); if (!$this->IsInDefinition()) { if ($sPrevFlag == '') @@ -2253,7 +2253,7 @@ EOF; { $sFlag = $sPrevFlag; // added, replaced or '' } - $oExisting->ReplaceWith($oNode); + $oExisting->MFReplaceWith($oNode); } else { @@ -2294,8 +2294,11 @@ EOF; * Replaces a node by another one, making sure that recursive nodes are preserved * * @param MFElement $oNewNode The replacement + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 rename method (from `ReplaceWith` to `MFReplaceWith`) to avoid collision with parent `\DOMElement::replaceWith` method (different method modifier and parameters : + * throws fatal error in PHP 8.0) */ - protected function ReplaceWith($oNewNode) + protected function MFReplaceWith($oNewNode) { // Move the classes from the old node into the new one if ($this->IsClassNode()) From ebc9fa684a8002cb955635ad9f7dcf918235dbf5 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Fri, 28 Jan 2022 12:14:24 +0100 Subject: [PATCH 05/14] =?UTF-8?q?N=C2=B03129=20PHP=208.0=20compat:=20Fix?= =?UTF-8?q?=20"Private=20methods=20cannot=20be=20final=20as=20they=20are?= =?UTF-8?q?=20never=20overridden=20by=20other=20classes"=20Was=20breaking?= =?UTF-8?q?=20setup=20ajax=20compilation=20Fixed=20in:=20*=20\SetupUtils::?= =?UTF-8?q?Log=20*=20\MetaModel::SetUniquenessRuleRootClass?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/metamodel.class.php | 4 ++-- setup/setuputils.class.inc.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/metamodel.class.php b/core/metamodel.class.php index 6ae300748..a1b7ed3cb 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -589,10 +589,10 @@ abstract class MetaModel * @param string $sRuleId * * @throws \CoreException - * @since 2.6.1 N°1918 (sous les pavés, la plage) initialize in 'root_class' property the class that has the first + * @since 2.6.1 N°1968 (sous les pavés, la plage) initialize in 'root_class' property the class that has the first * definition of the rule in the hierarchy */ - final private static function SetUniquenessRuleRootClass($sRootClass, $sRuleId) + private static function SetUniquenessRuleRootClass($sRootClass, $sRuleId) { foreach (self::EnumChildClasses($sRootClass, ENUM_CHILD_CLASSES_ALL) as $sClass) { diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index f02a16239..7d82ecb05 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -2067,7 +2067,7 @@ JS unset($_SESSION['setup_token']); } - private final static function Log($sText) + private static function Log($sText) { if (class_exists('SetupPage')) { From dbc3da7bc3b404d8e996aa934e77d16fdb260147 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Fri, 28 Jan 2022 17:25:14 +0100 Subject: [PATCH 06/14] =?UTF-8?q?N=C2=B03129=20Remove=20twig-bundle=20Test?= =?UTF-8?q?=20dir=20Thanks=20to=20iTopComposerTest::testNoDeniedDirIsPrese?= =?UTF-8?q?ntForNow=20:o)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/.gitignore | 3 +- .../Tests/ContainerAwareRuntimeLoaderTest.php | 41 -- .../Controller/ExceptionControllerTest.php | 92 ----- .../Controller/PreviewErrorControllerTest.php | 53 --- .../Compiler/ExtensionPassTest.php | 46 --- .../Compiler/TwigEnvironmentPassTest.php | 45 --- .../Compiler/TwigLoaderPassTest.php | 95 ----- .../DependencyInjection/ConfigurationTest.php | 31 -- .../Resources/views/layout.html.twig | 1 - .../Resources/views/layout.html.twig | 1 - .../Resources/views/layout.html.twig | 1 - .../Resources/views/layout.html.twig | 1 - .../TwigBundle/views/layout.html.twig | 1 - .../Fixtures/Resources/views/layout.html.twig | 1 - .../php/customTemplateEscapingGuesser.php | 6 - .../Fixtures/php/empty.php | 3 - .../Fixtures/php/extra.php | 7 - .../Fixtures/php/formats.php | 14 - .../DependencyInjection/Fixtures/php/full.php | 27 -- .../bundles/BarBundle/layout.html.twig | 1 - .../bundles/TwigBundle/layout.html.twig | 1 - .../Fixtures/templates/layout.html.twig | 1 - .../xml/customTemplateEscapingGuesser.xml | 10 - .../Fixtures/xml/empty.xml | 10 - .../Fixtures/xml/extra.xml | 12 - .../Fixtures/xml/formats.xml | 12 - .../DependencyInjection/Fixtures/xml/full.xml | 19 - .../yml/customTemplateEscapingGuesser.yml | 3 - .../Fixtures/yml/empty.yml | 1 - .../Fixtures/yml/extra.yml | 3 - .../Fixtures/yml/formats.yml | 9 - .../DependencyInjection/Fixtures/yml/full.yml | 21 -- .../DependencyInjection/TwigExtensionTest.php | 355 ------------------ .../BarBundle/Resources/views/index.html.twig | 1 - .../Fixtures/templates/Foo/index.html.twig | 1 - .../Resources/BarBundle/views/base.html.twig | 0 .../Resources/views/layout.html.twig | 1 - .../Resources/views/sub/sub.html.twig | 1 - .../Tests/Functional/CacheWarmingTest.php | 124 ------ .../Tests/Functional/EmptyAppTest.php | 51 --- .../Functional/NoTemplatingEntryTest.php | 80 ---- .../Resources/config/empty_routing.yml | 0 .../Resources/views/index.html.twig | 1 - .../Tests/Loader/FilesystemLoaderTest.php | 125 ------ .../Tests/TemplateIteratorTest.php | 44 --- lib/symfony/twig-bundle/Tests/TestCase.php | 18 - 46 files changed, 2 insertions(+), 1372 deletions(-) delete mode 100644 lib/symfony/twig-bundle/Tests/ContainerAwareRuntimeLoaderTest.php delete mode 100644 lib/symfony/twig-bundle/Tests/Controller/ExceptionControllerTest.php delete mode 100644 lib/symfony/twig-bundle/Tests/Controller/PreviewErrorControllerTest.php delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigEnvironmentPassTest.php delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/ConfigurationTest.php delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views/layout.html.twig delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views/layout.html.twig delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/views/layout.html.twig delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/views/layout.html.twig delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/TwigBundle/views/layout.html.twig delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/views/layout.html.twig delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/empty.php delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/extra.php delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/formats.php delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/full.php delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/BarBundle/layout.html.twig delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/TwigBundle/layout.html.twig delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/layout.html.twig delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/empty.xml delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/extra.xml delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/formats.xml delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/full.xml delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/empty.yml delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/extra.yml delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/formats.yml delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/full.yml delete mode 100644 lib/symfony/twig-bundle/Tests/DependencyInjection/TwigExtensionTest.php delete mode 100644 lib/symfony/twig-bundle/Tests/Fixtures/templates/BarBundle/Resources/views/index.html.twig delete mode 100644 lib/symfony/twig-bundle/Tests/Fixtures/templates/Foo/index.html.twig delete mode 100644 lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/BarBundle/views/base.html.twig delete mode 100644 lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/layout.html.twig delete mode 100644 lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/sub/sub.html.twig delete mode 100644 lib/symfony/twig-bundle/Tests/Functional/CacheWarmingTest.php delete mode 100644 lib/symfony/twig-bundle/Tests/Functional/EmptyAppTest.php delete mode 100644 lib/symfony/twig-bundle/Tests/Functional/NoTemplatingEntryTest.php delete mode 100644 lib/symfony/twig-bundle/Tests/Functional/Resources/config/empty_routing.yml delete mode 100644 lib/symfony/twig-bundle/Tests/Functional/Resources/views/index.html.twig delete mode 100644 lib/symfony/twig-bundle/Tests/Loader/FilesystemLoaderTest.php delete mode 100644 lib/symfony/twig-bundle/Tests/TemplateIteratorTest.php delete mode 100644 lib/symfony/twig-bundle/Tests/TestCase.php diff --git a/lib/.gitignore b/lib/.gitignore index fe9051d17..db8232362 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -32,4 +32,5 @@ # TWIG /twig/twig/doc /twig/twig/test -/twig/twig/drupal_test.sh \ No newline at end of file +/twig/twig/drupal_test.sh +/symfony/twig-bundle/Tests diff --git a/lib/symfony/twig-bundle/Tests/ContainerAwareRuntimeLoaderTest.php b/lib/symfony/twig-bundle/Tests/ContainerAwareRuntimeLoaderTest.php deleted file mode 100644 index 88f8fb21e..000000000 --- a/lib/symfony/twig-bundle/Tests/ContainerAwareRuntimeLoaderTest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests; - -use Psr\Log\LoggerInterface; -use Symfony\Bundle\TwigBundle\ContainerAwareRuntimeLoader; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * @group legacy - */ -class ContainerAwareRuntimeLoaderTest extends TestCase -{ - public function testLoad() - { - $container = $this->getMockBuilder(ContainerInterface::class)->getMock(); - $container->expects($this->once())->method('get')->with('foo'); - - $loader = new ContainerAwareRuntimeLoader($container, [ - 'FooClass' => 'foo', - ]); - $loader->load('FooClass'); - } - - public function testLoadWithoutAMatch() - { - $logger = $this->getMockBuilder(LoggerInterface::class)->getMock(); - $logger->expects($this->once())->method('warning')->with('Class "BarClass" is not configured as a Twig runtime. Add the "twig.runtime" tag to the related service in the container.'); - $loader = new ContainerAwareRuntimeLoader($this->getMockBuilder(ContainerInterface::class)->getMock(), [], $logger); - $this->assertNull($loader->load('BarClass')); - } -} diff --git a/lib/symfony/twig-bundle/Tests/Controller/ExceptionControllerTest.php b/lib/symfony/twig-bundle/Tests/Controller/ExceptionControllerTest.php deleted file mode 100644 index 800da68c9..000000000 --- a/lib/symfony/twig-bundle/Tests/Controller/ExceptionControllerTest.php +++ /dev/null @@ -1,92 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests\Controller; - -use Symfony\Bundle\TwigBundle\Controller\ExceptionController; -use Symfony\Bundle\TwigBundle\Tests\TestCase; -use Symfony\Component\Debug\Exception\FlattenException; -use Symfony\Component\HttpFoundation\Request; -use Twig\Environment; -use Twig\Loader\ArrayLoader; - -class ExceptionControllerTest extends TestCase -{ - public function testShowActionCanBeForcedToShowErrorPage() - { - $twig = $this->createTwigEnv(['@Twig/Exception/error404.html.twig' => 'not found']); - - $request = $this->createRequest('html'); - $request->attributes->set('showException', false); - $exception = FlattenException::create(new \Exception(), 404); - $controller = new ExceptionController($twig, /* "showException" defaults to --> */ true); - - $response = $controller->showAction($request, $exception, null); - - $this->assertEquals(200, $response->getStatusCode()); // successful request - $this->assertEquals('not found', $response->getContent()); - } - - public function testFallbackToHtmlIfNoTemplateForRequestedFormat() - { - $twig = $this->createTwigEnv(['@Twig/Exception/error.html.twig' => '']); - - $request = $this->createRequest('txt'); - $exception = FlattenException::create(new \Exception()); - $controller = new ExceptionController($twig, false); - - $controller->showAction($request, $exception); - - $this->assertEquals('html', $request->getRequestFormat()); - } - - public function testFallbackToHtmlWithFullExceptionIfNoTemplateForRequestedFormatAndExceptionsShouldBeShown() - { - $twig = $this->createTwigEnv(['@Twig/Exception/exception_full.html.twig' => '']); - - $request = $this->createRequest('txt'); - $request->attributes->set('showException', true); - $exception = FlattenException::create(new \Exception()); - $controller = new ExceptionController($twig, false); - - $controller->showAction($request, $exception); - - $this->assertEquals('html', $request->getRequestFormat()); - } - - public function testResponseHasRequestedMimeType() - { - $twig = $this->createTwigEnv(['@Twig/Exception/error.json.twig' => '{}']); - - $request = $this->createRequest('json'); - $exception = FlattenException::create(new \Exception()); - $controller = new ExceptionController($twig, false); - - $response = $controller->showAction($request, $exception); - - $this->assertEquals('json', $request->getRequestFormat()); - $this->assertEquals($request->getMimeType('json'), $response->headers->get('Content-Type')); - } - - private function createRequest($requestFormat) - { - $request = Request::create('whatever'); - $request->headers->set('X-Php-Ob-Level', 1); - $request->setRequestFormat($requestFormat); - - return $request; - } - - private function createTwigEnv(array $templates) - { - return new Environment(new ArrayLoader($templates)); - } -} diff --git a/lib/symfony/twig-bundle/Tests/Controller/PreviewErrorControllerTest.php b/lib/symfony/twig-bundle/Tests/Controller/PreviewErrorControllerTest.php deleted file mode 100644 index ae740e1ab..000000000 --- a/lib/symfony/twig-bundle/Tests/Controller/PreviewErrorControllerTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests\Controller; - -use Symfony\Bundle\TwigBundle\Controller\PreviewErrorController; -use Symfony\Bundle\TwigBundle\Tests\TestCase; -use Symfony\Component\Debug\Exception\FlattenException; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\HttpKernelInterface; - -class PreviewErrorControllerTest extends TestCase -{ - public function testForwardRequestToConfiguredController() - { - $request = Request::create('whatever'); - $response = new Response(''); - $code = 123; - $logicalControllerName = 'foo:bar:baz'; - - $kernel = $this->getMockBuilder('\Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(); - $kernel - ->expects($this->once()) - ->method('handle') - ->with( - $this->callback(function (Request $request) use ($logicalControllerName, $code) { - $this->assertEquals($logicalControllerName, $request->attributes->get('_controller')); - - $exception = $request->attributes->get('exception'); - $this->assertInstanceOf(FlattenException::class, $exception); - $this->assertEquals($code, $exception->getStatusCode()); - $this->assertFalse($request->attributes->get('showException')); - - return true; - }), - $this->equalTo(HttpKernelInterface::SUB_REQUEST) - ) - ->willReturn($response); - - $controller = new PreviewErrorController($kernel, $logicalControllerName); - - $this->assertSame($response, $controller->previewErrorPageAction($request, $code)); - } -} diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php deleted file mode 100644 index 539a952a6..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection\Compiler; - -use PHPUnit\Framework\TestCase; -use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExtensionPass; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Definition; - -class ExtensionPassTest extends TestCase -{ - public function testProcessDoesNotDropExistingFileLoaderMethodCalls() - { - $container = new ContainerBuilder(); - $container->setParameter('kernel.debug', false); - - $container->register('twig.app_variable', '\Symfony\Bridge\Twig\AppVariable'); - $container->register('templating', '\Symfony\Bundle\TwigBundle\TwigEngine'); - $container->register('twig.extension.yaml'); - $container->register('twig.extension.debug.stopwatch'); - $container->register('twig.extension.expression'); - - $nativeTwigLoader = new Definition('\Twig\Loader\FilesystemLoader'); - $nativeTwigLoader->addMethodCall('addPath', []); - $container->setDefinition('twig.loader.native_filesystem', $nativeTwigLoader); - - $filesystemLoader = new Definition('\Symfony\Bundle\TwigBundle\Loader\FilesystemLoader'); - $filesystemLoader->setArguments([null, null, null]); - $filesystemLoader->addMethodCall('addPath', []); - $container->setDefinition('twig.loader.filesystem', $filesystemLoader); - - $extensionPass = new ExtensionPass(); - $extensionPass->process($container); - - $this->assertCount(2, $filesystemLoader->getMethodCalls()); - } -} diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigEnvironmentPassTest.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigEnvironmentPassTest.php deleted file mode 100644 index 0af3fe4b3..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigEnvironmentPassTest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection\Compiler; - -use PHPUnit\Framework\TestCase; -use Symfony\Bridge\Twig\Extension\FormExtension; -use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigEnvironmentPass; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; - -class TwigEnvironmentPassTest extends TestCase -{ - public function testTwigBridgeExtensionsAreRegisteredFirst() - { - $container = new ContainerBuilder(); - $twigDefinition = $container->register('twig'); - $container->register('other_extension', 'Foo\Bar') - ->addTag('twig.extension'); - $container->register('twig_bridge_extension', FormExtension::class) - ->addTag('twig.extension'); - - $twigEnvironmentPass = new TwigEnvironmentPass(); - $twigEnvironmentPass->process($container); - - $methodCalls = $twigDefinition->getMethodCalls(); - $this->assertCount(2, $methodCalls); - - $twigBridgeExtensionReference = $methodCalls[0][1][0]; - $this->assertInstanceOf(Reference::class, $twigBridgeExtensionReference); - $this->assertSame('twig_bridge_extension', (string) $twigBridgeExtensionReference); - - $otherExtensionReference = $methodCalls[1][1][0]; - $this->assertInstanceOf(Reference::class, $otherExtensionReference); - $this->assertSame('other_extension', (string) $otherExtensionReference); - } -} diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php deleted file mode 100644 index a112b64b5..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Compiler/TwigLoaderPassTest.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection\Compiler; - -use PHPUnit\Framework\TestCase; -use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\TwigLoaderPass; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Definition; - -class TwigLoaderPassTest extends TestCase -{ - /** - * @var ContainerBuilder - */ - private $builder; - /** - * @var Definition - */ - private $chainLoader; - /** - * @var TwigLoaderPass - */ - private $pass; - - protected function setUp() - { - $this->builder = new ContainerBuilder(); - $this->builder->register('twig'); - $this->chainLoader = new Definition('loader'); - $this->pass = new TwigLoaderPass(); - } - - public function testMapperPassWithOneTaggedLoader() - { - $this->builder->register('test_loader_1') - ->addTag('twig.loader'); - - $this->pass->process($this->builder); - - $this->assertSame('test_loader_1', (string) $this->builder->getAlias('twig.loader')); - } - - public function testMapperPassWithTwoTaggedLoaders() - { - $this->builder->setDefinition('twig.loader.chain', $this->chainLoader); - $this->builder->register('test_loader_1') - ->addTag('twig.loader'); - $this->builder->register('test_loader_2') - ->addTag('twig.loader'); - - $this->pass->process($this->builder); - - $this->assertSame('twig.loader.chain', (string) $this->builder->getAlias('twig.loader')); - $calls = $this->chainLoader->getMethodCalls(); - $this->assertCount(2, $calls); - $this->assertEquals('addLoader', $calls[0][0]); - $this->assertEquals('addLoader', $calls[1][0]); - $this->assertEquals('test_loader_1', (string) $calls[0][1][0]); - $this->assertEquals('test_loader_2', (string) $calls[1][1][0]); - } - - public function testMapperPassWithTwoTaggedLoadersWithPriority() - { - $this->builder->setDefinition('twig.loader.chain', $this->chainLoader); - $this->builder->register('test_loader_1') - ->addTag('twig.loader', ['priority' => 100]); - $this->builder->register('test_loader_2') - ->addTag('twig.loader', ['priority' => 200]); - - $this->pass->process($this->builder); - - $this->assertSame('twig.loader.chain', (string) $this->builder->getAlias('twig.loader')); - $calls = $this->chainLoader->getMethodCalls(); - $this->assertCount(2, $calls); - $this->assertEquals('addLoader', $calls[0][0]); - $this->assertEquals('addLoader', $calls[1][0]); - $this->assertEquals('test_loader_2', (string) $calls[0][1][0]); - $this->assertEquals('test_loader_1', (string) $calls[1][1][0]); - } - - public function testMapperPassWithZeroTaggedLoaders() - { - $this->expectException('Symfony\Component\DependencyInjection\Exception\LogicException'); - $this->pass->process($this->builder); - } -} diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/ConfigurationTest.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/ConfigurationTest.php deleted file mode 100644 index 049d05b5c..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/ConfigurationTest.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection; - -use PHPUnit\Framework\TestCase; -use Symfony\Bundle\TwigBundle\DependencyInjection\Configuration; -use Symfony\Component\Config\Definition\Processor; - -class ConfigurationTest extends TestCase -{ - public function testDoNoDuplicateDefaultFormResources() - { - $input = [ - 'form_themes' => ['form_div_layout.html.twig'], - ]; - - $processor = new Processor(); - $config = $processor->processConfiguration(new Configuration(), [$input]); - - $this->assertEquals(['form_div_layout.html.twig'], $config['form_themes']); - } -} diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views/layout.html.twig deleted file mode 100644 index bb07ecfe5..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views/layout.html.twig +++ /dev/null @@ -1 +0,0 @@ -This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views/layout.html.twig deleted file mode 100644 index bb07ecfe5..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views/layout.html.twig +++ /dev/null @@ -1 +0,0 @@ -This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/views/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/views/layout.html.twig deleted file mode 100644 index bb07ecfe5..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/views/layout.html.twig +++ /dev/null @@ -1 +0,0 @@ -This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/views/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/views/layout.html.twig deleted file mode 100644 index bb07ecfe5..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/views/layout.html.twig +++ /dev/null @@ -1 +0,0 @@ -This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/TwigBundle/views/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/TwigBundle/views/layout.html.twig deleted file mode 100644 index bb07ecfe5..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/TwigBundle/views/layout.html.twig +++ /dev/null @@ -1 +0,0 @@ -This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/views/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/views/layout.html.twig deleted file mode 100644 index bb07ecfe5..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/Resources/views/layout.html.twig +++ /dev/null @@ -1 +0,0 @@ -This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php deleted file mode 100644 index c9acb3c25..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/customTemplateEscapingGuesser.php +++ /dev/null @@ -1,6 +0,0 @@ -loadFromExtension('twig', [ - 'autoescape_service' => 'my_project.some_bundle.template_escaping_guesser', - 'autoescape_service_method' => 'guess', -]); diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/empty.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/empty.php deleted file mode 100644 index d107fd90d..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/empty.php +++ /dev/null @@ -1,3 +0,0 @@ -loadFromExtension('twig', []); diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/extra.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/extra.php deleted file mode 100644 index 49acc87a8..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/extra.php +++ /dev/null @@ -1,7 +0,0 @@ -loadFromExtension('twig', [ - 'paths' => [ - 'namespaced_path3' => 'namespace3', - ], -]); diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/formats.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/formats.php deleted file mode 100644 index 7e8573880..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/formats.php +++ /dev/null @@ -1,14 +0,0 @@ -loadFromExtension('twig', [ - 'date' => [ - 'format' => 'Y-m-d', - 'interval_format' => '%d', - 'timezone' => 'Europe/Berlin', - ], - 'number_format' => [ - 'decimals' => 2, - 'decimal_point' => ',', - 'thousands_separator' => '.', - ], -]); diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/full.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/full.php deleted file mode 100644 index 8dd2be409..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/php/full.php +++ /dev/null @@ -1,27 +0,0 @@ -loadFromExtension('twig', [ - 'form_themes' => [ - 'MyBundle::form.html.twig', - ], - 'globals' => [ - 'foo' => '@bar', - 'baz' => '@@qux', - 'pi' => 3.14, - 'bad' => ['key' => 'foo'], - ], - 'auto_reload' => true, - 'autoescape' => true, - 'base_template_class' => 'stdClass', - 'cache' => '/tmp', - 'charset' => 'ISO-8859-1', - 'debug' => true, - 'strict_variables' => true, - 'default_path' => '%kernel.project_dir%/Fixtures/templates', - 'paths' => [ - 'path1', - 'path2', - 'namespaced_path1' => 'namespace1', - 'namespaced_path2' => 'namespace2', - ], -]); diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/BarBundle/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/BarBundle/layout.html.twig deleted file mode 100644 index bb07ecfe5..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/BarBundle/layout.html.twig +++ /dev/null @@ -1 +0,0 @@ -This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/TwigBundle/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/TwigBundle/layout.html.twig deleted file mode 100644 index bb07ecfe5..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/bundles/TwigBundle/layout.html.twig +++ /dev/null @@ -1 +0,0 @@ -This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/layout.html.twig b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/layout.html.twig deleted file mode 100644 index bb07ecfe5..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/templates/layout.html.twig +++ /dev/null @@ -1 +0,0 @@ -This is a layout diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml deleted file mode 100644 index f72bed9d1..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/customTemplateEscapingGuesser.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/empty.xml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/empty.xml deleted file mode 100644 index f3b51fa24..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/empty.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/extra.xml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/extra.xml deleted file mode 100644 index 17bcf0acd..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/extra.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - namespaced_path3 - - diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/formats.xml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/formats.xml deleted file mode 100644 index fa888b30a..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/formats.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/full.xml deleted file mode 100644 index 8ece3b80b..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/xml/full.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - MyBundle::form.html.twig - - @@qux - 3.14 - path1 - path2 - namespaced_path1 - namespaced_path2 - - diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml deleted file mode 100644 index eb26e7165..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/customTemplateEscapingGuesser.yml +++ /dev/null @@ -1,3 +0,0 @@ -twig: - autoescape_service: my_project.some_bundle.template_escaping_guesser - autoescape_service_method: guess diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/empty.yml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/empty.yml deleted file mode 100644 index a472b2698..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/empty.yml +++ /dev/null @@ -1 +0,0 @@ -twig: diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/extra.yml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/extra.yml deleted file mode 100644 index 3c5e6a3b5..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/extra.yml +++ /dev/null @@ -1,3 +0,0 @@ -twig: - paths: - namespaced_path3: namespace3 diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/formats.yml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/formats.yml deleted file mode 100644 index 290921630..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/formats.yml +++ /dev/null @@ -1,9 +0,0 @@ -twig: - date: - format: Y-m-d - interval_format: '%d' - timezone: Europe/Berlin - number_format: - decimals: 2 - decimal_point: ',' - thousands_separator: . diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/full.yml b/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/full.yml deleted file mode 100644 index 24c10c23f..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/Fixtures/yml/full.yml +++ /dev/null @@ -1,21 +0,0 @@ -twig: - form_themes: - - MyBundle::form.html.twig - globals: - foo: "@bar" - baz: "@@qux" - pi: 3.14 - bad: {key: foo} - auto_reload: true - autoescape: true - base_template_class: stdClass - cache: /tmp - charset: ISO-8859-1 - debug: true - strict_variables: true - default_path: '%kernel.project_dir%/Fixtures/templates' - paths: - path1: '' - path2: '' - namespaced_path1: namespace1 - namespaced_path2: namespace2 diff --git a/lib/symfony/twig-bundle/Tests/DependencyInjection/TwigExtensionTest.php b/lib/symfony/twig-bundle/Tests/DependencyInjection/TwigExtensionTest.php deleted file mode 100644 index 7e14857fa..000000000 --- a/lib/symfony/twig-bundle/Tests/DependencyInjection/TwigExtensionTest.php +++ /dev/null @@ -1,355 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection; - -use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\RuntimeLoaderPass; -use Symfony\Bundle\TwigBundle\DependencyInjection\TwigExtension; -use Symfony\Bundle\TwigBundle\Tests\TestCase; -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\Compiler\PassConfig; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; -use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; -use Symfony\Component\DependencyInjection\Reference; - -class TwigExtensionTest extends TestCase -{ - public function testLoadEmptyConfiguration() - { - $container = $this->createContainer(); - $container->registerExtension(new TwigExtension()); - $container->loadFromExtension('twig', []); - $this->compileContainer($container); - - $this->assertEquals('Twig\Environment', $container->getDefinition('twig')->getClass(), '->load() loads the twig.xml file'); - - $this->assertContains('form_div_layout.html.twig', $container->getParameter('twig.form.resources'), '->load() includes default template for form resources'); - - // Twig options - $options = $container->getDefinition('twig')->getArgument(1); - $this->assertEquals('%kernel.cache_dir%/twig', $options['cache'], '->load() sets default value for cache option'); - $this->assertEquals('%kernel.charset%', $options['charset'], '->load() sets default value for charset option'); - $this->assertEquals('%kernel.debug%', $options['debug'], '->load() sets default value for debug option'); - } - - /** - * @dataProvider getFormats - */ - public function testLoadFullConfiguration($format) - { - $container = $this->createContainer(); - $container->registerExtension(new TwigExtension()); - $this->loadFromFile($container, 'full', $format); - $this->compileContainer($container); - - $this->assertEquals('Twig\Environment', $container->getDefinition('twig')->getClass(), '->load() loads the twig.xml file'); - - // Form resources - $resources = $container->getParameter('twig.form.resources'); - $this->assertContains('form_div_layout.html.twig', $resources, '->load() includes default template for form resources'); - $this->assertContains('MyBundle::form.html.twig', $resources, '->load() merges new templates into form resources'); - - // Globals - $calls = $container->getDefinition('twig')->getMethodCalls(); - $this->assertEquals('app', $calls[0][1][0], '->load() registers services as Twig globals'); - $this->assertEquals(new Reference('twig.app_variable'), $calls[0][1][1]); - $this->assertEquals('foo', $calls[2][1][0], '->load() registers services as Twig globals'); - $this->assertEquals(new Reference('bar'), $calls[2][1][1], '->load() registers services as Twig globals'); - $this->assertEquals('baz', $calls[3][1][0], '->load() registers variables as Twig globals'); - $this->assertEquals('@qux', $calls[3][1][1], '->load() allows escaping of service identifiers'); - $this->assertEquals('pi', $calls[4][1][0], '->load() registers variables as Twig globals'); - $this->assertEquals(3.14, $calls[4][1][1], '->load() registers variables as Twig globals'); - - // Yaml and Php specific configs - if (\in_array($format, ['yml', 'php'])) { - $this->assertEquals('bad', $calls[5][1][0], '->load() registers variables as Twig globals'); - $this->assertEquals(['key' => 'foo'], $calls[5][1][1], '->load() registers variables as Twig globals'); - } - - // Twig options - $options = $container->getDefinition('twig')->getArgument(1); - $this->assertTrue($options['auto_reload'], '->load() sets the auto_reload option'); - $this->assertTrue($options['autoescape'], '->load() sets the autoescape option'); - $this->assertEquals('stdClass', $options['base_template_class'], '->load() sets the base_template_class option'); - $this->assertEquals('/tmp', $options['cache'], '->load() sets the cache option'); - $this->assertEquals('ISO-8859-1', $options['charset'], '->load() sets the charset option'); - $this->assertTrue($options['debug'], '->load() sets the debug option'); - $this->assertTrue($options['strict_variables'], '->load() sets the strict_variables option'); - } - - /** - * @dataProvider getFormats - */ - public function testLoadCustomTemplateEscapingGuesserConfiguration($format) - { - $container = $this->createContainer(); - $container->registerExtension(new TwigExtension()); - $this->loadFromFile($container, 'customTemplateEscapingGuesser', $format); - $this->compileContainer($container); - - $options = $container->getDefinition('twig')->getArgument(1); - $this->assertEquals([new Reference('my_project.some_bundle.template_escaping_guesser'), 'guess'], $options['autoescape']); - } - - /** - * @dataProvider getFormats - */ - public function testLoadDefaultTemplateEscapingGuesserConfiguration($format) - { - $container = $this->createContainer(); - $container->registerExtension(new TwigExtension()); - $this->loadFromFile($container, 'empty', $format); - $this->compileContainer($container); - - $options = $container->getDefinition('twig')->getArgument(1); - $this->assertEquals('name', $options['autoescape']); - } - - /** - * @dataProvider getFormats - */ - public function testLoadCustomDateFormats($fileFormat) - { - $container = $this->createContainer(); - $container->registerExtension(new TwigExtension()); - $this->loadFromFile($container, 'formats', $fileFormat); - $this->compileContainer($container); - - $environmentConfigurator = $container->getDefinition('twig.configurator.environment'); - - $this->assertSame('Y-m-d', $environmentConfigurator->getArgument(0)); - $this->assertSame('%d', $environmentConfigurator->getArgument(1)); - $this->assertSame('Europe/Berlin', $environmentConfigurator->getArgument(2)); - $this->assertSame(2, $environmentConfigurator->getArgument(3)); - $this->assertSame(',', $environmentConfigurator->getArgument(4)); - $this->assertSame('.', $environmentConfigurator->getArgument(5)); - } - - public function testGlobalsWithDifferentTypesAndValues() - { - $globals = [ - 'array' => [], - 'false' => false, - 'float' => 2.0, - 'integer' => 3, - 'null' => null, - 'object' => new \stdClass(), - 'string' => 'foo', - 'true' => true, - ]; - - $container = $this->createContainer(); - $container->registerExtension(new TwigExtension()); - $container->loadFromExtension('twig', ['globals' => $globals]); - $this->compileContainer($container); - - $calls = $container->getDefinition('twig')->getMethodCalls(); - foreach (\array_slice($calls, 2) as $call) { - $this->assertEquals(key($globals), $call[1][0]); - $this->assertSame(current($globals), $call[1][1]); - - next($globals); - } - } - - /** - * @dataProvider getFormats - */ - public function testTwigLoaderPaths($format) - { - $container = $this->createContainer(); - $container->registerExtension(new TwigExtension()); - $this->loadFromFile($container, 'full', $format); - $this->loadFromFile($container, 'extra', $format); - $this->compileContainer($container); - - $def = $container->getDefinition('twig.loader.native_filesystem'); - $paths = []; - foreach ($def->getMethodCalls() as $call) { - if ('addPath' === $call[0] && false === strpos($call[1][0], 'Form')) { - $paths[] = $call[1]; - } - } - - $this->assertEquals([ - ['path1'], - ['path2'], - ['namespaced_path1', 'namespace1'], - ['namespaced_path2', 'namespace2'], - ['namespaced_path3', 'namespace3'], - [__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildChildChildChildTwig'], - [__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildChildChildTwig'], - [__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildChildChildTwig'], - [__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'Twig'], - [__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'Twig'], - [__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'Twig'], - [__DIR__.'/Fixtures/Bundle/ChildTwigBundle/Resources/views', 'Twig'], - [__DIR__.'/Fixtures/Resources/TwigBundle/views', 'Twig'], - [__DIR__.'/Fixtures/templates/bundles/TwigBundle', 'Twig'], - [realpath(__DIR__.'/../..').'/Resources/views', 'Twig'], - [realpath(__DIR__.'/../..').'/Resources/views', '!Twig'], - [__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildTwig'], - [__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildTwig'], - [__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'ChildTwig'], - [__DIR__.'/Fixtures/Bundle/ChildTwigBundle/Resources/views', 'ChildTwig'], - [__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildChildTwig'], - [__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildChildTwig'], - [__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'ChildChildTwig'], - [__DIR__.'/Fixtures/Resources/views'], - [__DIR__.'/Fixtures/templates'], - ], $paths); - } - - public function getFormats() - { - return [ - ['php'], - ['yml'], - ['xml'], - ]; - } - - /** - * @dataProvider stopwatchExtensionAvailabilityProvider - */ - public function testStopwatchExtensionAvailability($debug, $stopwatchEnabled, $expected) - { - $container = $this->createContainer(); - $container->setParameter('kernel.debug', $debug); - if ($stopwatchEnabled) { - $container->register('debug.stopwatch', 'Symfony\Component\Stopwatch\Stopwatch'); - } - $container->registerExtension(new TwigExtension()); - $container->loadFromExtension('twig', []); - $container->setAlias('test.twig.extension.debug.stopwatch', 'twig.extension.debug.stopwatch')->setPublic(true); - $this->compileContainer($container); - - $tokenParsers = $container->get('test.twig.extension.debug.stopwatch')->getTokenParsers(); - $stopwatchIsAvailable = new \ReflectionProperty($tokenParsers[0], 'stopwatchIsAvailable'); - $stopwatchIsAvailable->setAccessible(true); - - $this->assertSame($expected, $stopwatchIsAvailable->getValue($tokenParsers[0])); - } - - public function stopwatchExtensionAvailabilityProvider() - { - return [ - 'debug-and-stopwatch-enabled' => [true, true, true], - 'only-stopwatch-enabled' => [false, true, false], - 'only-debug-enabled' => [true, false, false], - 'debug-and-stopwatch-disabled' => [false, false, false], - ]; - } - - public function testRuntimeLoader() - { - $container = $this->createContainer(); - $container->registerExtension(new TwigExtension()); - $container->loadFromExtension('twig', []); - $container->setParameter('kernel.environment', 'test'); - $container->setParameter('debug.file_link_format', 'test'); - $container->setParameter('foo', 'FooClass'); - $container->register('http_kernel', 'FooClass'); - $container->register('templating.locator', 'FooClass'); - $container->register('templating.name_parser', 'FooClass'); - $container->register('foo', '%foo%')->addTag('twig.runtime'); - $container->addCompilerPass(new RuntimeLoaderPass(), PassConfig::TYPE_BEFORE_REMOVING); - $container->getCompilerPassConfig()->setRemovingPasses([]); - $container->getCompilerPassConfig()->setAfterRemovingPasses([]); - $container->compile(); - - $loader = $container->getDefinition('twig.runtime_loader'); - $args = $container->getDefinition((string) $loader->getArgument(0))->getArgument(0); - $this->assertArrayHasKey('Symfony\Component\Form\FormRenderer', $args); - $this->assertArrayHasKey('FooClass', $args); - $this->assertEquals('twig.form.renderer', $args['Symfony\Component\Form\FormRenderer']->getValues()[0]); - $this->assertEquals('foo', $args['FooClass']->getValues()[0]); - } - - private function createContainer() - { - $container = new ContainerBuilder(new ParameterBag([ - 'kernel.cache_dir' => __DIR__, - 'kernel.root_dir' => __DIR__.'/Fixtures', - 'kernel.project_dir' => __DIR__, - 'kernel.charset' => 'UTF-8', - 'kernel.debug' => false, - 'kernel.bundles' => [ - 'TwigBundle' => 'Symfony\\Bundle\\TwigBundle\\TwigBundle', - 'ChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildTwigBundle\\ChildTwigBundle', - 'ChildChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildTwigBundle\\ChildChildTwigBundle', - 'ChildChildChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildTwigBundle\\ChildChildChildTwigBundle', - 'ChildChildChildChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildChildTwigBundle\\ChildChildChildChildTwigBundle', - ], - 'kernel.bundles_metadata' => [ - 'ChildChildChildChildTwigBundle' => [ - 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildChildTwigBundle\\ChildChildChildChildTwigBundle', - 'parent' => 'ChildChildChildTwigBundle', - 'path' => __DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle', - ], - 'TwigBundle' => [ - 'namespace' => 'Symfony\\Bundle\\TwigBundle', - 'parent' => null, - 'path' => realpath(__DIR__.'/../..'), - ], - 'ChildTwigBundle' => [ - 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildTwigBundle\\ChildTwigBundle', - 'parent' => 'TwigBundle', - 'path' => __DIR__.'/Fixtures/Bundle/ChildTwigBundle', - ], - 'ChildChildChildTwigBundle' => [ - 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildTwigBundle\\ChildChildChildTwigBundle', - 'parent' => 'ChildChildTwigBundle', - 'path' => __DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle', - ], - 'ChildChildTwigBundle' => [ - 'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildTwigBundle\\ChildChildTwigBundle', - 'parent' => 'ChildTwigBundle', - 'path' => __DIR__.'/Fixtures/Bundle/ChildChildTwigBundle', - ], - ], - ])); - - return $container; - } - - private function compileContainer(ContainerBuilder $container) - { - $container->getCompilerPassConfig()->setOptimizationPasses([]); - $container->getCompilerPassConfig()->setRemovingPasses([]); - $container->getCompilerPassConfig()->setAfterRemovingPasses([]); - $container->compile(); - } - - private function loadFromFile(ContainerBuilder $container, $file, $format) - { - $locator = new FileLocator(__DIR__.'/Fixtures/'.$format); - - switch ($format) { - case 'php': - $loader = new PhpFileLoader($container, $locator); - break; - case 'xml': - $loader = new XmlFileLoader($container, $locator); - break; - case 'yml': - $loader = new YamlFileLoader($container, $locator); - break; - default: - throw new \InvalidArgumentException(sprintf('Unsupported format: "%s"', $format)); - } - - $loader->load($file.'.'.$format); - } -} diff --git a/lib/symfony/twig-bundle/Tests/Fixtures/templates/BarBundle/Resources/views/index.html.twig b/lib/symfony/twig-bundle/Tests/Fixtures/templates/BarBundle/Resources/views/index.html.twig deleted file mode 100644 index 1975b0e15..000000000 --- a/lib/symfony/twig-bundle/Tests/Fixtures/templates/BarBundle/Resources/views/index.html.twig +++ /dev/null @@ -1 +0,0 @@ -{# Twig template #} diff --git a/lib/symfony/twig-bundle/Tests/Fixtures/templates/Foo/index.html.twig b/lib/symfony/twig-bundle/Tests/Fixtures/templates/Foo/index.html.twig deleted file mode 100644 index 1975b0e15..000000000 --- a/lib/symfony/twig-bundle/Tests/Fixtures/templates/Foo/index.html.twig +++ /dev/null @@ -1 +0,0 @@ -{# Twig template #} diff --git a/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/BarBundle/views/base.html.twig b/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/BarBundle/views/base.html.twig deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/layout.html.twig b/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/layout.html.twig deleted file mode 100644 index 1975b0e15..000000000 --- a/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/layout.html.twig +++ /dev/null @@ -1 +0,0 @@ -{# Twig template #} diff --git a/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/sub/sub.html.twig b/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/sub/sub.html.twig deleted file mode 100644 index 1975b0e15..000000000 --- a/lib/symfony/twig-bundle/Tests/Fixtures/templates/Resources/views/sub/sub.html.twig +++ /dev/null @@ -1 +0,0 @@ -{# Twig template #} diff --git a/lib/symfony/twig-bundle/Tests/Functional/CacheWarmingTest.php b/lib/symfony/twig-bundle/Tests/Functional/CacheWarmingTest.php deleted file mode 100644 index 63710a8e1..000000000 --- a/lib/symfony/twig-bundle/Tests/Functional/CacheWarmingTest.php +++ /dev/null @@ -1,124 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests\Functional; - -use Symfony\Bundle\FrameworkBundle\FrameworkBundle; -use Symfony\Bundle\TwigBundle\Tests\TestCase; -use Symfony\Bundle\TwigBundle\TwigBundle; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\HttpKernel\Kernel; - -class CacheWarmingTest extends TestCase -{ - public function testCacheIsProperlyWarmedWhenTemplatingIsAvailable() - { - $kernel = new CacheWarmingKernel(true); - $kernel->boot(); - - $warmer = $kernel->getContainer()->get('cache_warmer'); - $warmer->enableOptionalWarmers(); - $warmer->warmUp($kernel->getCacheDir()); - - $this->assertFileExists($kernel->getCacheDir().'/twig'); - } - - public function testCacheIsProperlyWarmedWhenTemplatingIsDisabled() - { - $kernel = new CacheWarmingKernel(false); - $kernel->boot(); - - $warmer = $kernel->getContainer()->get('cache_warmer'); - $warmer->enableOptionalWarmers(); - $warmer->warmUp($kernel->getCacheDir()); - - $this->assertFileExists($kernel->getCacheDir().'/twig'); - } - - protected function setUp() - { - $this->deleteTempDir(); - } - - protected function tearDown() - { - $this->deleteTempDir(); - } - - private function deleteTempDir() - { - if (!file_exists($dir = sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel')) { - return; - } - - $fs = new Filesystem(); - $fs->remove($dir); - } -} - -class CacheWarmingKernel extends Kernel -{ - private $withTemplating; - - public function __construct($withTemplating) - { - $this->withTemplating = $withTemplating; - - parent::__construct(($withTemplating ? 'with' : 'without').'_templating', true); - } - - public function getName() - { - return 'CacheWarming'; - } - - public function registerBundles() - { - return [new FrameworkBundle(), new TwigBundle()]; - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - $loader->load(function ($container) { - $container->loadFromExtension('framework', [ - 'secret' => '$ecret', - 'form' => ['enabled' => false], - ]); - }); - - if ($this->withTemplating) { - $loader->load(function ($container) { - $container->loadFromExtension('framework', [ - 'secret' => '$ecret', - 'templating' => ['engines' => ['twig']], - 'router' => ['resource' => '%kernel.project_dir%/Resources/config/empty_routing.yml'], - 'form' => ['enabled' => false], - ]); - }); - } - } - - public function getProjectDir() - { - return __DIR__; - } - - public function getCacheDir() - { - return sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel/cache/'.$this->environment; - } - - public function getLogDir() - { - return sys_get_temp_dir().'/'.Kernel::VERSION.'/CacheWarmingKernel/logs'; - } -} diff --git a/lib/symfony/twig-bundle/Tests/Functional/EmptyAppTest.php b/lib/symfony/twig-bundle/Tests/Functional/EmptyAppTest.php deleted file mode 100644 index 86d933b55..000000000 --- a/lib/symfony/twig-bundle/Tests/Functional/EmptyAppTest.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests\Functional; - -use Symfony\Bundle\TwigBundle\Tests\TestCase; -use Symfony\Bundle\TwigBundle\TwigBundle; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\HttpKernel\Kernel; - -class EmptyAppTest extends TestCase -{ - public function testBootEmptyApp() - { - $kernel = new EmptyAppKernel('test', true); - $kernel->boot(); - - $this->assertTrue($kernel->getContainer()->hasParameter('twig.default_path')); - $this->assertNotEmpty($kernel->getContainer()->getParameter('twig.default_path')); - } -} - -class EmptyAppKernel extends Kernel -{ - public function registerBundles() - { - return [new TwigBundle()]; - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - } - - public function getCacheDir() - { - return sys_get_temp_dir().'/'.Kernel::VERSION.'/EmptyAppKernel/cache/'.$this->environment; - } - - public function getLogDir() - { - return sys_get_temp_dir().'/'.Kernel::VERSION.'/EmptyAppKernel/logs'; - } -} diff --git a/lib/symfony/twig-bundle/Tests/Functional/NoTemplatingEntryTest.php b/lib/symfony/twig-bundle/Tests/Functional/NoTemplatingEntryTest.php deleted file mode 100644 index 3d509c44e..000000000 --- a/lib/symfony/twig-bundle/Tests/Functional/NoTemplatingEntryTest.php +++ /dev/null @@ -1,80 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests\Functional; - -use Symfony\Bundle\FrameworkBundle\FrameworkBundle; -use Symfony\Bundle\TwigBundle\Tests\TestCase; -use Symfony\Bundle\TwigBundle\TwigBundle; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\HttpKernel\Kernel; - -class NoTemplatingEntryTest extends TestCase -{ - public function test() - { - $kernel = new NoTemplatingEntryKernel('dev', true); - $kernel->boot(); - - $container = $kernel->getContainer(); - $content = $container->get('twig')->render('index.html.twig'); - $this->assertStringContainsString('{ a: b }', $content); - } - - protected function setUp() - { - $this->deleteTempDir(); - } - - protected function tearDown() - { - $this->deleteTempDir(); - } - - protected function deleteTempDir() - { - if (!file_exists($dir = sys_get_temp_dir().'/'.Kernel::VERSION.'/NoTemplatingEntryKernel')) { - return; - } - - $fs = new Filesystem(); - $fs->remove($dir); - } -} - -class NoTemplatingEntryKernel extends Kernel -{ - public function registerBundles() - { - return [new FrameworkBundle(), new TwigBundle()]; - } - - public function registerContainerConfiguration(LoaderInterface $loader) - { - $loader->load(function ($container) { - $container->loadFromExtension('framework', [ - 'secret' => '$ecret', - 'form' => ['enabled' => false], - ]); - }); - } - - public function getCacheDir() - { - return sys_get_temp_dir().'/'.Kernel::VERSION.'/NoTemplatingEntryKernel/cache/'.$this->environment; - } - - public function getLogDir() - { - return sys_get_temp_dir().'/'.Kernel::VERSION.'/NoTemplatingEntryKernel/logs'; - } -} diff --git a/lib/symfony/twig-bundle/Tests/Functional/Resources/config/empty_routing.yml b/lib/symfony/twig-bundle/Tests/Functional/Resources/config/empty_routing.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/symfony/twig-bundle/Tests/Functional/Resources/views/index.html.twig b/lib/symfony/twig-bundle/Tests/Functional/Resources/views/index.html.twig deleted file mode 100644 index ddc4eb440..000000000 --- a/lib/symfony/twig-bundle/Tests/Functional/Resources/views/index.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ {a: 'b'}|yaml_encode }} diff --git a/lib/symfony/twig-bundle/Tests/Loader/FilesystemLoaderTest.php b/lib/symfony/twig-bundle/Tests/Loader/FilesystemLoaderTest.php deleted file mode 100644 index c8958670a..000000000 --- a/lib/symfony/twig-bundle/Tests/Loader/FilesystemLoaderTest.php +++ /dev/null @@ -1,125 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests\Loader; - -use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; -use Symfony\Bundle\TwigBundle\Loader\FilesystemLoader; -use Symfony\Bundle\TwigBundle\Tests\TestCase; - -class FilesystemLoaderTest extends TestCase -{ - public function testGetSourceContext() - { - $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); - $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); - $locator - ->expects($this->once()) - ->method('locate') - ->willReturn(__DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig') - ; - $loader = new FilesystemLoader($locator, $parser); - $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views', 'namespace'); - - // Twig-style - $this->assertEquals("This is a layout\n", $loader->getSourceContext('@namespace/layout.html.twig')->getCode()); - - // Symfony-style - $this->assertEquals("This is a layout\n", $loader->getSourceContext('TwigBundle::layout.html.twig')->getCode()); - } - - public function testExists() - { - // should return true for templates that Twig does not find, but Symfony does - $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); - $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); - $locator - ->expects($this->once()) - ->method('locate') - ->willReturn($template = __DIR__.'/../DependencyInjection/Fixtures/Resources/views/layout.html.twig') - ; - $loader = new FilesystemLoader($locator, $parser); - - $this->assertTrue($loader->exists($template)); - } - - public function testTwigErrorIfLocatorThrowsInvalid() - { - $this->expectException('Twig\Error\LoaderError'); - $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); - $parser - ->expects($this->once()) - ->method('parse') - ->with('name.format.engine') - ->willReturn(new TemplateReference('', '', 'name', 'format', 'engine')) - ; - - $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); - $locator - ->expects($this->once()) - ->method('locate') - ->willThrowException(new \InvalidArgumentException('Unable to find template "NonExistent".')) - ; - - $loader = new FilesystemLoader($locator, $parser); - $loader->getCacheKey('name.format.engine'); - } - - public function testTwigErrorIfLocatorReturnsFalse() - { - $this->expectException('Twig\Error\LoaderError'); - $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); - $parser - ->expects($this->once()) - ->method('parse') - ->with('name.format.engine') - ->willReturn(new TemplateReference('', '', 'name', 'format', 'engine')) - ; - - $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); - $locator - ->expects($this->once()) - ->method('locate') - ->willReturn(false) - ; - - $loader = new FilesystemLoader($locator, $parser); - $loader->getCacheKey('name.format.engine'); - } - - public function testTwigErrorIfTemplateDoesNotExist() - { - $this->expectException('Twig\Error\LoaderError'); - $this->expectExceptionMessageMatches('/Unable to find template "name\.format\.engine" \(looked into: .*Tests.Loader.\.\..DependencyInjection.Fixtures.Resources.views\)/'); - $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); - $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); - - $loader = new FilesystemLoader($locator, $parser); - $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views'); - - $method = new \ReflectionMethod('Symfony\Bundle\TwigBundle\Loader\FilesystemLoader', 'findTemplate'); - $method->setAccessible(true); - $method->invoke($loader, 'name.format.engine'); - } - - public function testTwigSoftErrorIfTemplateDoesNotExist() - { - $parser = $this->getMockBuilder('Symfony\Component\Templating\TemplateNameParserInterface')->getMock(); - $locator = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock(); - - $loader = new FilesystemLoader($locator, $parser); - $loader->addPath(__DIR__.'/../DependencyInjection/Fixtures/Resources/views'); - - $method = new \ReflectionMethod('Symfony\Bundle\TwigBundle\Loader\FilesystemLoader', 'findTemplate'); - $method->setAccessible(true); - $this->assertFalse($method->invoke($loader, 'name.format.engine', false)); - } -} diff --git a/lib/symfony/twig-bundle/Tests/TemplateIteratorTest.php b/lib/symfony/twig-bundle/Tests/TemplateIteratorTest.php deleted file mode 100644 index b9092af3e..000000000 --- a/lib/symfony/twig-bundle/Tests/TemplateIteratorTest.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests; - -use Symfony\Bundle\TwigBundle\TemplateIterator; - -class TemplateIteratorTest extends TestCase -{ - public function testGetIterator() - { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')->getMock(); - $bundle->expects($this->any())->method('getName')->willReturn('BarBundle'); - $bundle->expects($this->any())->method('getPath')->willReturn(__DIR__.'/Fixtures/templates/BarBundle'); - - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock(); - $kernel->expects($this->any())->method('getBundles')->willReturn([ - $bundle, - ]); - $iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', [__DIR__.'/Fixtures/templates/Foo' => 'Foo'], __DIR__.'/DependencyInjection/Fixtures/templates'); - - $sorted = iterator_to_array($iterator); - sort($sorted); - $this->assertEquals( - [ - '@Bar/base.html.twig', - '@Bar/index.html.twig', - '@Bar/layout.html.twig', - '@Foo/index.html.twig', - 'layout.html.twig', - 'sub/sub.html.twig', - ], - $sorted - ); - } -} diff --git a/lib/symfony/twig-bundle/Tests/TestCase.php b/lib/symfony/twig-bundle/Tests/TestCase.php deleted file mode 100644 index 800be3008..000000000 --- a/lib/symfony/twig-bundle/Tests/TestCase.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\TwigBundle\Tests; - -use PHPUnit\Framework\TestCase as PHPUnitTestCase; - -class TestCase extends PHPUnitTestCase -{ -} From 45b5c39af769009f496c41e12bef05df06c958d7 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Mon, 31 Jan 2022 16:39:46 +0100 Subject: [PATCH 07/14] =?UTF-8?q?N=C2=B03129=20PHP=208.0=20compat=20:=20co?= =?UTF-8?q?de=20review=20modifications=20Many=20thanks=20@Molkobain=20&=20?= =?UTF-8?q?@Hipska=20!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/displayblock.class.inc.php | 17 ++++++++--------- application/ui.extkeywidget.class.inc.php | 2 +- setup/modelfactory.class.inc.php | 8 ++++---- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/application/displayblock.class.inc.php b/application/displayblock.class.inc.php index c27996848..f89172feb 100644 --- a/application/displayblock.class.inc.php +++ b/application/displayblock.class.inc.php @@ -324,8 +324,10 @@ class DisplayBlock * @throws DictExceptionMissingString * @throws MySQLException * @throws Exception + * + * @since 2.7.7 3.0.1 3.1.0 N°3129 add type hinting to $aExtraParams */ - public function GetRenderContent(WebPage $oPage, $aExtraParams, $sId) + public function GetRenderContent(WebPage $oPage, array $aExtraParams, $sId) { $sHtml = ''; // Add the extra params into the filter if they make sense for such a filter @@ -1433,9 +1435,10 @@ class HistoryBlock extends DisplayBlock * @throws \MySQLException * @throws \MySQLHasGoneAwayException * - * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aExtraParams for PHP 8.0 compatibility (var is unused, and all calls were already made using a default value) + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aExtraParams and add type hinting for PHP 8.0 compatibility + * (var is unused, and all calls were already made using a default value) */ - public function GetRenderContent(WebPage $oPage, $aExtraParams, $sId) + public function GetRenderContent(WebPage $oPage, array $aExtraParams, $sId) { $sHtml = ''; $bTruncated = false; @@ -1575,14 +1578,10 @@ class MenuBlock extends DisplayBlock * @throws \MissingQueryArgument * @throws \MySQLException * - * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aExtraParams for PHP 8.0 compatibility (added a test at function start to handle wrong values) + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value and add type hinting on $aExtraParams for PHP 8.0 compatibility */ - public function GetRenderContent(WebPage $oPage, $aExtraParams, $sId) + public function GetRenderContent(WebPage $oPage, array $aExtraParams, $sId) { - if (empty($aExtraParams)) { - $aExtraParams = []; - } - if ($this->m_sStyle == 'popup') // popup is a synonym of 'list' for backward compatibility { $this->m_sStyle = 'list'; diff --git a/application/ui.extkeywidget.class.inc.php b/application/ui.extkeywidget.class.inc.php index 465f53c03..f6d29323c 100644 --- a/application/ui.extkeywidget.class.inc.php +++ b/application/ui.extkeywidget.class.inc.php @@ -431,7 +431,7 @@ EOF * @throws CoreException * @throws OQLException * - * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $oObj for PHP 8.0 compatibility (a null default value is awkward ?!??) + * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $oObj for PHP 8.0 compatibility */ public function AutoComplete(WebPage $oP, $sFilter, $oObj, $sContains, $sOutputFormat = self::ENUM_OUTPUT_FORMAT_CSV, $sOperation = null) { diff --git a/setup/modelfactory.class.inc.php b/setup/modelfactory.class.inc.php index a0817bfec..78ffc16fa 100644 --- a/setup/modelfactory.class.inc.php +++ b/setup/modelfactory.class.inc.php @@ -2161,7 +2161,7 @@ class MFElement extends Combodo\iTop\DesignElement EOF; throw new MFException($sExceptionMessage, MFException::COULD_NOT_BE_ADDED, $iLine, $sPath); } - $oExisting->MFReplaceWith($oNode); + $oExisting->ReplaceWithSingleNode($oNode); $sFlag = 'replaced'; } else @@ -2208,7 +2208,7 @@ EOF; throw new MFException($sPath." at line $iLine: could not be modified (marked as deleted)", MFException::COULD_NOT_BE_MODIFIED_ALREADY_DELETED, $sPath, $iLine); } - $oExisting->MFReplaceWith($oNode); + $oExisting->ReplaceWithSingleNode($oNode); if (!$this->IsInDefinition()) { if ($sPrevFlag == '') @@ -2253,7 +2253,7 @@ EOF; { $sFlag = $sPrevFlag; // added, replaced or '' } - $oExisting->MFReplaceWith($oNode); + $oExisting->ReplaceWithSingleNode($oNode); } else { @@ -2298,7 +2298,7 @@ EOF; * @since 2.7.7 3.0.1 3.1.0 N°3129 rename method (from `ReplaceWith` to `MFReplaceWith`) to avoid collision with parent `\DOMElement::replaceWith` method (different method modifier and parameters : * throws fatal error in PHP 8.0) */ - protected function MFReplaceWith($oNewNode) + protected function ReplaceWithSingleNode($oNewNode) { // Move the classes from the old node into the new one if ($this->IsClassNode()) From f0715baf7deaef796cf8f64339955e7d621c12da Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 1 Feb 2022 11:34:09 +0100 Subject: [PATCH 08/14] =?UTF-8?q?N=C2=B04714=20move=20constant=20from=20co?= =?UTF-8?q?re/config.class.inc.php=20to=20approot.inc.php=20see=20N=C2=B04?= =?UTF-8?q?406?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- approot.inc.php | 13 +++++++++++++ core/config.class.inc.php | 11 ----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/approot.inc.php b/approot.inc.php index a180e8560..e56fe770e 100644 --- a/approot.inc.php +++ b/approot.inc.php @@ -3,4 +3,17 @@ define('APPROOT', dirname(__FILE__).'/'); define('APPCONF', APPROOT.'conf/'); + +/** + * Constant containing the iTop core version, whatever application was built + * + * Note that in iTop 3.0.0 we used {@see ITOP_DESIGN_LATEST_VERSION} to get core version. + * When releasing, both constants should be updated : see `.make/release/update-versions.php` for that ! + * + * @since 2.7.7 3.0.1 3.1.0 N°4714 constant creation + * @used-by utils::GetItopPatchVersion + */ +define('ITOP_CORE_VERSION', '2.7.7'); + + require_once APPROOT.'bootstrap.inc.php'; diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 6036b8f02..2adc5023c 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -31,17 +31,6 @@ define('ITOP_APPLICATION_SHORT', 'iTop'); */ define('ITOP_VERSION', '2.7.0-dev'); -/** - * Constant containing the iTop core version, whatever application was built - * - * Note that in iTop 3.0.0 we used {@see ITOP_DESIGN_LATEST_VERSION} to get core version. - * When releasing, both constants should be updated : see `.make/release/update-versions.php` for that ! - * - * @since 2.7.7 3.0.1 3.1.0 N°4714 constant creation - * @used-by utils::GetItopPatchVersion - */ -define('ITOP_CORE_VERSION', '2.7.7'); - define('ITOP_REVISION', 'svn'); define('ITOP_BUILD_DATE', '$WCNOW$'); define('ITOP_VERSION_FULL', ITOP_VERSION.'-'.ITOP_REVISION); From fcfcf85e0d5010e4d7340d32f7c57902ef3061c2 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 1 Feb 2022 11:39:57 +0100 Subject: [PATCH 09/14] =?UTF-8?q?N=C2=B04714=20fix=20constant=20version=20?= =?UTF-8?q?usages=20in=20utils=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/utils.inc.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/application/utils.inc.php b/application/utils.inc.php index c14f340b5..90fef1059 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -2246,7 +2246,7 @@ class utils } /** - * @return string eg : '2_7_0' ITOP_VERSION is '2.7.1-dev' + * @return string eg : '2_7_0' iTop core version is '2.7.1-dev' */ public static function GetItopVersionWikiSyntax() { @@ -2255,7 +2255,7 @@ class utils } /** - * @return string eg 2.7 if ITOP_VERSION is '2.7.0-dev' + * @return string eg 2.7 if iTop core version is '2.7.0-dev' * @throws \Exception */ public static function GetItopMinorVersion() @@ -2272,11 +2272,12 @@ class utils } /** - * @return string eg '2.7.0' if ITOP_VERSION is '2.7.0-dev' + * @return string eg '2.7.0' if iTop core version is '2.7.0-dev' + * @uses ITOP_CORE_VERSION */ public static function GetItopPatchVersion() { - $aExplodedVersion = explode('-', ITOP_VERSION); + $aExplodedVersion = explode('-', ITOP_CORE_VERSION); return $aExplodedVersion[0]; } From 4e80fc0f763a539387085abdbde8b08e5d6d77c4 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 1 Feb 2022 14:50:33 +0100 Subject: [PATCH 10/14] =?UTF-8?q?N=C2=B04624=20Remove=20processIsolation?= =?UTF-8?q?=20flag=20from=20postBuild=20tests=20Was=20done=20in=20standard?= =?UTF-8?q?=20test=20suite=20(test/phpunit.xml.dist)=20with=206bf25f90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/postbuild_integration.xml.dist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/postbuild_integration.xml.dist b/test/postbuild_integration.xml.dist index d83d3199f..8128c1cb8 100644 --- a/test/postbuild_integration.xml.dist +++ b/test/postbuild_integration.xml.dist @@ -19,7 +19,7 @@ Date: Tue, 1 Feb 2022 15:19:06 +0100 Subject: [PATCH 11/14] Prepare 2.7.7 --- .make/release/update-versions.php | 2 +- css/css-variables.scss | 2 +- datamodels/2.x/authent-cas/module.authent-cas.php | 2 +- datamodels/2.x/authent-external/module.authent-external.php | 2 +- datamodels/2.x/authent-ldap/module.authent-ldap.php | 2 +- datamodels/2.x/authent-local/module.authent-local.php | 2 +- datamodels/2.x/combodo-db-tools/module.combodo-db-tools.php | 2 +- datamodels/2.x/itop-attachments/module.itop-attachments.php | 2 +- datamodels/2.x/itop-backup/module.itop-backup.php | 2 +- .../module.itop-bridge-virtualization-storage.php | 2 +- .../2.x/itop-change-mgmt-itil/module.itop-change-mgmt-itil.php | 2 +- datamodels/2.x/itop-change-mgmt/module.itop-change-mgmt.php | 2 +- datamodels/2.x/itop-config-mgmt/module.itop-config-mgmt.php | 2 +- datamodels/2.x/itop-config/module.itop-config.php | 2 +- datamodels/2.x/itop-core-update/module.itop-core-update.php | 2 +- .../2.x/itop-datacenter-mgmt/module.itop-datacenter-mgmt.php | 2 +- .../2.x/itop-endusers-devices/module.itop-endusers-devices.php | 2 +- .../itop-files-information/module.itop-files-information.php | 2 +- datamodels/2.x/itop-full-itil/module.itop-full-itil.php | 2 +- datamodels/2.x/itop-hub-connector/module.itop-hub-connector.php | 2 +- .../itop-incident-mgmt-itil/module.itop-incident-mgmt-itil.php | 2 +- .../2.x/itop-knownerror-mgmt/module.itop-knownerror-mgmt.php | 2 +- datamodels/2.x/itop-portal-base/module.itop-portal-base.php | 2 +- datamodels/2.x/itop-portal/module.itop-portal.php | 2 +- datamodels/2.x/itop-problem-mgmt/module.itop-problem-mgmt.php | 2 +- datamodels/2.x/itop-profiles-itil/module.itop-profiles-itil.php | 2 +- .../itop-request-mgmt-itil/module.itop-request-mgmt-itil.php | 2 +- datamodels/2.x/itop-request-mgmt/module.itop-request-mgmt.php | 2 +- .../module.itop-service-mgmt-provider.php | 2 +- datamodels/2.x/itop-service-mgmt/module.itop-service-mgmt.php | 2 +- .../2.x/itop-sla-computation/module.itop-sla-computation.php | 2 +- datamodels/2.x/itop-storage-mgmt/module.itop-storage-mgmt.php | 2 +- datamodels/2.x/itop-tickets/module.itop-tickets.php | 2 +- .../module.itop-virtualization-mgmt.php | 2 +- datamodels/2.x/itop-welcome-itil/module.itop-welcome-itil.php | 2 +- datamodels/2.x/version.xml | 2 +- 36 files changed, 36 insertions(+), 36 deletions(-) diff --git a/.make/release/update-versions.php b/.make/release/update-versions.php index 0bab8f82c..94ee70188 100644 --- a/.make/release/update-versions.php +++ b/.make/release/update-versions.php @@ -27,7 +27,7 @@ $aFilesUpdaters = array( new iTopVersionFileUpdater(), new CssVariablesFileUpdater(), new DatamodelsModulesFiles(), - new ConstantFileUpdater('ITOP_CORE_VERSION', 'core/config.class.inc.php'), + new ConstantFileUpdater('ITOP_CORE_VERSION', 'approot.inc.php'), ); if (count($argv) === 1) diff --git a/css/css-variables.scss b/css/css-variables.scss index 73d8f493f..5f0e52542 100644 --- a/css/css-variables.scss +++ b/css/css-variables.scss @@ -17,7 +17,7 @@ */ // Beware the version number MUST be enclosed with quotes otherwise v2.3.0 becomes v2 0.3 .0 -$version: "v2.7.6"; +$version: "v2.7.7"; $approot-relative: "../../../../../" !default; // relative to env-***/branding/themes/***/main.css // Base colors diff --git a/datamodels/2.x/authent-cas/module.authent-cas.php b/datamodels/2.x/authent-cas/module.authent-cas.php index 7eff055d9..84109eb21 100644 --- a/datamodels/2.x/authent-cas/module.authent-cas.php +++ b/datamodels/2.x/authent-cas/module.authent-cas.php @@ -5,7 +5,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'authent-cas/2.7.6', + 'authent-cas/2.7.7', array( // Identification // diff --git a/datamodels/2.x/authent-external/module.authent-external.php b/datamodels/2.x/authent-external/module.authent-external.php index ad15a042c..df4a4c33d 100755 --- a/datamodels/2.x/authent-external/module.authent-external.php +++ b/datamodels/2.x/authent-external/module.authent-external.php @@ -27,7 +27,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'authent-external/2.7.6', + 'authent-external/2.7.7', array( // Identification // diff --git a/datamodels/2.x/authent-ldap/module.authent-ldap.php b/datamodels/2.x/authent-ldap/module.authent-ldap.php index 8f6b102c2..e335994b7 100755 --- a/datamodels/2.x/authent-ldap/module.authent-ldap.php +++ b/datamodels/2.x/authent-ldap/module.authent-ldap.php @@ -9,7 +9,7 @@ if (function_exists('ldap_connect')) SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'authent-ldap/2.7.6', + 'authent-ldap/2.7.7', array( // Identification // diff --git a/datamodels/2.x/authent-local/module.authent-local.php b/datamodels/2.x/authent-local/module.authent-local.php index f73733b27..58e525c0e 100755 --- a/datamodels/2.x/authent-local/module.authent-local.php +++ b/datamodels/2.x/authent-local/module.authent-local.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'authent-local/2.7.6', + 'authent-local/2.7.7', array( // Identification // diff --git a/datamodels/2.x/combodo-db-tools/module.combodo-db-tools.php b/datamodels/2.x/combodo-db-tools/module.combodo-db-tools.php index b507fc544..2acd8175e 100644 --- a/datamodels/2.x/combodo-db-tools/module.combodo-db-tools.php +++ b/datamodels/2.x/combodo-db-tools/module.combodo-db-tools.php @@ -24,7 +24,7 @@ /** @noinspection PhpUnhandledExceptionInspection */ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'combodo-db-tools/2.7.6', + 'combodo-db-tools/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-attachments/module.itop-attachments.php b/datamodels/2.x/itop-attachments/module.itop-attachments.php index 2ef0deb59..20073f075 100644 --- a/datamodels/2.x/itop-attachments/module.itop-attachments.php +++ b/datamodels/2.x/itop-attachments/module.itop-attachments.php @@ -19,7 +19,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-attachments/2.7.6', + 'itop-attachments/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-backup/module.itop-backup.php b/datamodels/2.x/itop-backup/module.itop-backup.php index e63c1bf9c..05d2d7dc4 100644 --- a/datamodels/2.x/itop-backup/module.itop-backup.php +++ b/datamodels/2.x/itop-backup/module.itop-backup.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-backup/2.7.6', + 'itop-backup/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-bridge-virtualization-storage/module.itop-bridge-virtualization-storage.php b/datamodels/2.x/itop-bridge-virtualization-storage/module.itop-bridge-virtualization-storage.php index 414602480..2ab747ae0 100644 --- a/datamodels/2.x/itop-bridge-virtualization-storage/module.itop-bridge-virtualization-storage.php +++ b/datamodels/2.x/itop-bridge-virtualization-storage/module.itop-bridge-virtualization-storage.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-bridge-virtualization-storage/2.7.6', + 'itop-bridge-virtualization-storage/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-change-mgmt-itil/module.itop-change-mgmt-itil.php b/datamodels/2.x/itop-change-mgmt-itil/module.itop-change-mgmt-itil.php index beebadcd5..6d7dedb3b 100755 --- a/datamodels/2.x/itop-change-mgmt-itil/module.itop-change-mgmt-itil.php +++ b/datamodels/2.x/itop-change-mgmt-itil/module.itop-change-mgmt-itil.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-change-mgmt-itil/2.7.6', + 'itop-change-mgmt-itil/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-change-mgmt/module.itop-change-mgmt.php b/datamodels/2.x/itop-change-mgmt/module.itop-change-mgmt.php index 0cec8dced..4169edd89 100755 --- a/datamodels/2.x/itop-change-mgmt/module.itop-change-mgmt.php +++ b/datamodels/2.x/itop-change-mgmt/module.itop-change-mgmt.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-change-mgmt/2.7.6', + 'itop-change-mgmt/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-config-mgmt/module.itop-config-mgmt.php b/datamodels/2.x/itop-config-mgmt/module.itop-config-mgmt.php index c37a00362..68c92f797 100755 --- a/datamodels/2.x/itop-config-mgmt/module.itop-config-mgmt.php +++ b/datamodels/2.x/itop-config-mgmt/module.itop-config-mgmt.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-config-mgmt/2.7.6', + 'itop-config-mgmt/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-config/module.itop-config.php b/datamodels/2.x/itop-config/module.itop-config.php index 327e6b623..f9759b72b 100644 --- a/datamodels/2.x/itop-config/module.itop-config.php +++ b/datamodels/2.x/itop-config/module.itop-config.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-config/2.7.6', + 'itop-config/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-core-update/module.itop-core-update.php b/datamodels/2.x/itop-core-update/module.itop-core-update.php index cc3bd9cea..4cdcb6bc3 100644 --- a/datamodels/2.x/itop-core-update/module.itop-core-update.php +++ b/datamodels/2.x/itop-core-update/module.itop-core-update.php @@ -24,7 +24,7 @@ /** @noinspection PhpUnhandledExceptionInspection */ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-core-update/2.7.6', + 'itop-core-update/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-datacenter-mgmt/module.itop-datacenter-mgmt.php b/datamodels/2.x/itop-datacenter-mgmt/module.itop-datacenter-mgmt.php index 43d53c2d2..6c5750e48 100755 --- a/datamodels/2.x/itop-datacenter-mgmt/module.itop-datacenter-mgmt.php +++ b/datamodels/2.x/itop-datacenter-mgmt/module.itop-datacenter-mgmt.php @@ -18,7 +18,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-datacenter-mgmt/2.7.6', + 'itop-datacenter-mgmt/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-endusers-devices/module.itop-endusers-devices.php b/datamodels/2.x/itop-endusers-devices/module.itop-endusers-devices.php index b2ea5de96..c8d0f019f 100644 --- a/datamodels/2.x/itop-endusers-devices/module.itop-endusers-devices.php +++ b/datamodels/2.x/itop-endusers-devices/module.itop-endusers-devices.php @@ -25,7 +25,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-endusers-devices/2.7.6', + 'itop-endusers-devices/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-files-information/module.itop-files-information.php b/datamodels/2.x/itop-files-information/module.itop-files-information.php index caa098eaf..3e4a67b01 100644 --- a/datamodels/2.x/itop-files-information/module.itop-files-information.php +++ b/datamodels/2.x/itop-files-information/module.itop-files-information.php @@ -24,7 +24,7 @@ /** @noinspection PhpUnhandledExceptionInspection */ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-files-information/2.7.6', + 'itop-files-information/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-full-itil/module.itop-full-itil.php b/datamodels/2.x/itop-full-itil/module.itop-full-itil.php index 4f4b7708e..164c37595 100644 --- a/datamodels/2.x/itop-full-itil/module.itop-full-itil.php +++ b/datamodels/2.x/itop-full-itil/module.itop-full-itil.php @@ -6,7 +6,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-full-itil/2.7.6', + 'itop-full-itil/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-hub-connector/module.itop-hub-connector.php b/datamodels/2.x/itop-hub-connector/module.itop-hub-connector.php index 2c9df5dcc..25ac50219 100644 --- a/datamodels/2.x/itop-hub-connector/module.itop-hub-connector.php +++ b/datamodels/2.x/itop-hub-connector/module.itop-hub-connector.php @@ -5,7 +5,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-hub-connector/2.7.6', + 'itop-hub-connector/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-incident-mgmt-itil/module.itop-incident-mgmt-itil.php b/datamodels/2.x/itop-incident-mgmt-itil/module.itop-incident-mgmt-itil.php index 569a0d256..e04ad81c2 100755 --- a/datamodels/2.x/itop-incident-mgmt-itil/module.itop-incident-mgmt-itil.php +++ b/datamodels/2.x/itop-incident-mgmt-itil/module.itop-incident-mgmt-itil.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-incident-mgmt-itil/2.7.6', + 'itop-incident-mgmt-itil/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-knownerror-mgmt/module.itop-knownerror-mgmt.php b/datamodels/2.x/itop-knownerror-mgmt/module.itop-knownerror-mgmt.php index 4e7e537bb..564a2888e 100755 --- a/datamodels/2.x/itop-knownerror-mgmt/module.itop-knownerror-mgmt.php +++ b/datamodels/2.x/itop-knownerror-mgmt/module.itop-knownerror-mgmt.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-knownerror-mgmt/2.7.6', + 'itop-knownerror-mgmt/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-portal-base/module.itop-portal-base.php b/datamodels/2.x/itop-portal-base/module.itop-portal-base.php index ddcfc3cba..f5ce5752f 100644 --- a/datamodels/2.x/itop-portal-base/module.itop-portal-base.php +++ b/datamodels/2.x/itop-portal-base/module.itop-portal-base.php @@ -20,7 +20,7 @@ /** @noinspection PhpUnhandledExceptionInspection */ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-portal-base/2.7.6', array( + 'itop-portal-base/2.7.7', array( // Identification 'label' => 'Portal Development Library', 'category' => 'Portal', diff --git a/datamodels/2.x/itop-portal/module.itop-portal.php b/datamodels/2.x/itop-portal/module.itop-portal.php index 599c0b2ec..ae6a9e1a5 100644 --- a/datamodels/2.x/itop-portal/module.itop-portal.php +++ b/datamodels/2.x/itop-portal/module.itop-portal.php @@ -20,7 +20,7 @@ /** @noinspection PhpUnhandledExceptionInspection */ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-portal/2.7.6', array( + 'itop-portal/2.7.7', array( // Identification 'label' => 'Enhanced Customer Portal', 'category' => 'Portal', diff --git a/datamodels/2.x/itop-problem-mgmt/module.itop-problem-mgmt.php b/datamodels/2.x/itop-problem-mgmt/module.itop-problem-mgmt.php index 0fdd08c25..431421da5 100755 --- a/datamodels/2.x/itop-problem-mgmt/module.itop-problem-mgmt.php +++ b/datamodels/2.x/itop-problem-mgmt/module.itop-problem-mgmt.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-problem-mgmt/2.7.6', + 'itop-problem-mgmt/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-profiles-itil/module.itop-profiles-itil.php b/datamodels/2.x/itop-profiles-itil/module.itop-profiles-itil.php index b3e36d01c..64cb94667 100755 --- a/datamodels/2.x/itop-profiles-itil/module.itop-profiles-itil.php +++ b/datamodels/2.x/itop-profiles-itil/module.itop-profiles-itil.php @@ -19,7 +19,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-profiles-itil/2.7.6', + 'itop-profiles-itil/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-request-mgmt-itil/module.itop-request-mgmt-itil.php b/datamodels/2.x/itop-request-mgmt-itil/module.itop-request-mgmt-itil.php index 1b023944a..56c4d88fe 100755 --- a/datamodels/2.x/itop-request-mgmt-itil/module.itop-request-mgmt-itil.php +++ b/datamodels/2.x/itop-request-mgmt-itil/module.itop-request-mgmt-itil.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-request-mgmt-itil/2.7.6', + 'itop-request-mgmt-itil/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-request-mgmt/module.itop-request-mgmt.php b/datamodels/2.x/itop-request-mgmt/module.itop-request-mgmt.php index 243eaddbc..787fce01a 100755 --- a/datamodels/2.x/itop-request-mgmt/module.itop-request-mgmt.php +++ b/datamodels/2.x/itop-request-mgmt/module.itop-request-mgmt.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-request-mgmt/2.7.6', + 'itop-request-mgmt/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-service-mgmt-provider/module.itop-service-mgmt-provider.php b/datamodels/2.x/itop-service-mgmt-provider/module.itop-service-mgmt-provider.php index 618e26bc7..eadce8bb1 100755 --- a/datamodels/2.x/itop-service-mgmt-provider/module.itop-service-mgmt-provider.php +++ b/datamodels/2.x/itop-service-mgmt-provider/module.itop-service-mgmt-provider.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-service-mgmt-provider/2.7.6', + 'itop-service-mgmt-provider/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-service-mgmt/module.itop-service-mgmt.php b/datamodels/2.x/itop-service-mgmt/module.itop-service-mgmt.php index 47df6c1b9..1b99acdcf 100755 --- a/datamodels/2.x/itop-service-mgmt/module.itop-service-mgmt.php +++ b/datamodels/2.x/itop-service-mgmt/module.itop-service-mgmt.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-service-mgmt/2.7.6', + 'itop-service-mgmt/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-sla-computation/module.itop-sla-computation.php b/datamodels/2.x/itop-sla-computation/module.itop-sla-computation.php index b83928c51..97a3eed5b 100755 --- a/datamodels/2.x/itop-sla-computation/module.itop-sla-computation.php +++ b/datamodels/2.x/itop-sla-computation/module.itop-sla-computation.php @@ -18,7 +18,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-sla-computation/2.7.6', + 'itop-sla-computation/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-storage-mgmt/module.itop-storage-mgmt.php b/datamodels/2.x/itop-storage-mgmt/module.itop-storage-mgmt.php index 5d8d6b326..9e824790f 100644 --- a/datamodels/2.x/itop-storage-mgmt/module.itop-storage-mgmt.php +++ b/datamodels/2.x/itop-storage-mgmt/module.itop-storage-mgmt.php @@ -25,7 +25,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-storage-mgmt/2.7.6', + 'itop-storage-mgmt/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-tickets/module.itop-tickets.php b/datamodels/2.x/itop-tickets/module.itop-tickets.php index f1d4c7530..19f361b5c 100755 --- a/datamodels/2.x/itop-tickets/module.itop-tickets.php +++ b/datamodels/2.x/itop-tickets/module.itop-tickets.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, - 'itop-tickets/2.7.6', + 'itop-tickets/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-virtualization-mgmt/module.itop-virtualization-mgmt.php b/datamodels/2.x/itop-virtualization-mgmt/module.itop-virtualization-mgmt.php index 6062f9630..888904f9e 100644 --- a/datamodels/2.x/itop-virtualization-mgmt/module.itop-virtualization-mgmt.php +++ b/datamodels/2.x/itop-virtualization-mgmt/module.itop-virtualization-mgmt.php @@ -16,7 +16,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-virtualization-mgmt/2.7.6', + 'itop-virtualization-mgmt/2.7.7', array( // Identification // diff --git a/datamodels/2.x/itop-welcome-itil/module.itop-welcome-itil.php b/datamodels/2.x/itop-welcome-itil/module.itop-welcome-itil.php index f0226e355..e0535aff1 100755 --- a/datamodels/2.x/itop-welcome-itil/module.itop-welcome-itil.php +++ b/datamodels/2.x/itop-welcome-itil/module.itop-welcome-itil.php @@ -3,7 +3,7 @@ SetupWebPage::AddModule( __FILE__, // Path to the current file, all other file names are relative to the directory containing this file - 'itop-welcome-itil/2.7.6', + 'itop-welcome-itil/2.7.7', array( // Identification // diff --git a/datamodels/2.x/version.xml b/datamodels/2.x/version.xml index 223aeda33..ba7398a4d 100755 --- a/datamodels/2.x/version.xml +++ b/datamodels/2.x/version.xml @@ -1,4 +1,4 @@ - 2.7.6 + 2.7.7 From 17612f88d3d44cbc0d0e5d728a4ad327e095a45a Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 1 Feb 2022 15:03:06 +0100 Subject: [PATCH 12/14] =?UTF-8?q?N=C2=B04714=20utils=20version=20method=20?= =?UTF-8?q?refactoring=20-=20removes=20utils::GetItopPatchVersion=20and=20?= =?UTF-8?q?GetItopMinorVersion=20:=20unused=20and=20badly=20named=20:/=20-?= =?UTF-8?q?=20GetItopVersionWikiSyntax=20now=20uses=20core=20version=20con?= =?UTF-8?q?stant=20-=20iTopModulesPhpVersionIntegrationTest::testiTopModul?= =?UTF-8?q?esPhpVersion=20now=20uses=20ITOP=5FCORE=5FVERSION=20constant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/utils.inc.php | 32 ++++--------------- approot.inc.php | 3 +- .../iTopModulesPhpVersionChecklistTest.php | 9 +++--- 3 files changed, 13 insertions(+), 31 deletions(-) diff --git a/application/utils.inc.php b/application/utils.inc.php index 90fef1059..273345039 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -2247,38 +2247,18 @@ class utils /** * @return string eg : '2_7_0' iTop core version is '2.7.1-dev' + * @throws \ApplicationException if constant value is invalid + * @uses ITOP_CORE_VERSION */ public static function GetItopVersionWikiSyntax() { - $sMinorVersion = self::GetItopMinorVersion(); - return str_replace('.', '_', $sMinorVersion).'_0'; - } + $aExplodedVersion = explode('.', ITOP_CORE_VERSION); - /** - * @return string eg 2.7 if iTop core version is '2.7.0-dev' - * @throws \Exception - */ - public static function GetItopMinorVersion() - { - $sPatchVersion = self::GetItopPatchVersion(); - $aExplodedVersion = explode('.', $sPatchVersion); - - if (empty($aExplodedVersion[0]) || empty($aExplodedVersion[1])) - { - throw new Exception('iTop version is wrongfully configured!'); + if (empty($aExplodedVersion[0]) || empty($aExplodedVersion[1])) { + throw new ApplicationException('iTop version is wrongfully configured!'); } - return sprintf('%d.%d', $aExplodedVersion[0], $aExplodedVersion[1]); - } - - /** - * @return string eg '2.7.0' if iTop core version is '2.7.0-dev' - * @uses ITOP_CORE_VERSION - */ - public static function GetItopPatchVersion() - { - $aExplodedVersion = explode('-', ITOP_CORE_VERSION); - return $aExplodedVersion[0]; + return "{$aExplodedVersion[0]}_{$aExplodedVersion[1]}_0"; } /** diff --git a/approot.inc.php b/approot.inc.php index e56fe770e..dae2341e2 100644 --- a/approot.inc.php +++ b/approot.inc.php @@ -11,7 +11,8 @@ define('APPCONF', APPROOT.'conf/'); * When releasing, both constants should be updated : see `.make/release/update-versions.php` for that ! * * @since 2.7.7 3.0.1 3.1.0 N°4714 constant creation - * @used-by utils::GetItopPatchVersion + * @used-by utils::GetItopVersionWikiSyntax() + * @used-by iTopModulesPhpVersionIntegrationTest */ define('ITOP_CORE_VERSION', '2.7.7'); diff --git a/test/integration/iTopModulesPhpVersionChecklistTest.php b/test/integration/iTopModulesPhpVersionChecklistTest.php index c99008644..421699618 100644 --- a/test/integration/iTopModulesPhpVersionChecklistTest.php +++ b/test/integration/iTopModulesPhpVersionChecklistTest.php @@ -35,6 +35,8 @@ class iTopModulesPhpVersionIntegrationTest extends ItopTestCase * @group skipPostBuild * * @dataProvider iTopModulesPhpVersionProvider + * + * @since 2.7.7 3.0.1 3.1.0 N°4714 uses new {@link ITOP_CORE_VERSION} constant */ public function testiTopModulesPhpVersion($sExpectedVersion, $sPhpFile) { @@ -51,9 +53,8 @@ class iTopModulesPhpVersionIntegrationTest extends ItopTestCase $matches ); - $this->assertRegExp("#$sExpectedVersion#", $matches[1], - " $sPhpFile:2 file refer does not refer to current itop version ($sModuleName/$matches[1] does not match regexp $sModuleName/$sExpectedVersion)"); - + $this->assertSame($sExpectedVersion, $matches[1], + 'Module desc file does not contain the same version as the core: '.$sPhpFile); } public function iTopModulesPhpVersionProvider() @@ -74,7 +75,7 @@ class iTopModulesPhpVersionIntegrationTest extends ItopTestCase $sPath = $DatamodelsPath.'/*/module.*.php'; $aPhpFiles = glob($sPath); - $sExpectedVersion = \utils::GetItopMinorVersion().'\.\d+'; // ie: 2.7\.\d+ (and yes, the 1st dot should be escaped, but, hey, it is good enough as it, ans less complex to read) + $sExpectedVersion = ITOP_CORE_VERSION; $aTestCases = array(); foreach ($aPhpFiles as $sPhpFile) { From b4fc647845be8d426b79e7db9dec4819dac3e446 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 1 Feb 2022 15:40:43 +0100 Subject: [PATCH 13/14] =?UTF-8?q?N=C2=B04714=20Rename=20\utils::GetItopVer?= =?UTF-8?q?sionWikiSyntax=20to=20GetCoreVersionWikiSyntax=20Will=20avoid?= =?UTF-8?q?=20confusion=20between=20core=20or=20product=20version=20!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/utils.inc.php | 4 ++-- approot.inc.php | 2 +- setup/setuputils.class.inc.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/application/utils.inc.php b/application/utils.inc.php index 273345039..c473bfd11 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -2246,11 +2246,11 @@ class utils } /** - * @return string eg : '2_7_0' iTop core version is '2.7.1-dev' + * @return string eg : '2_7_0' if iTop core version is '2.7.5-2' * @throws \ApplicationException if constant value is invalid * @uses ITOP_CORE_VERSION */ - public static function GetItopVersionWikiSyntax() + public static function GetCoreVersionWikiSyntax() { $aExplodedVersion = explode('.', ITOP_CORE_VERSION); diff --git a/approot.inc.php b/approot.inc.php index dae2341e2..e00277bc9 100644 --- a/approot.inc.php +++ b/approot.inc.php @@ -11,7 +11,7 @@ define('APPCONF', APPROOT.'conf/'); * When releasing, both constants should be updated : see `.make/release/update-versions.php` for that ! * * @since 2.7.7 3.0.1 3.1.0 N°4714 constant creation - * @used-by utils::GetItopVersionWikiSyntax() + * @used-by utils::GetCoreVersionWikiSyntax() * @used-by iTopModulesPhpVersionIntegrationTest */ define('ITOP_CORE_VERSION', '2.7.7'); diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index 7d82ecb05..e8ccf497a 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -918,7 +918,7 @@ class SetupUtils $oPage, $bIsItopInstall, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $bTlsEnabled, $sTlsCA, $sNewDBName = '' ) { - $sWikiVersion = utils::GetItopVersionWikiSyntax(); //eg : '2_7_0'; + $sWikiVersion = utils::GetCoreVersionWikiSyntax(); //eg : '2_7_0'; $sMysqlTlsWikiPageUrl = 'https://www.itophub.io/wiki/page?id='.$sWikiVersion.':install:php_and_mysql_tls'; $oPage->add(''); @@ -1194,7 +1194,7 @@ EOF { $aResult['checks'][] = new CheckResult(CheckResult::INFO, "MySQL server's max_allowed_packet ($sMaxAllowedPacketFriendly) is big enough compared to upload_max_filesize ($sMaxUploadSizeFriendly)."); } else if ($iMaxAllowedPacket < $iMaxUploadSize) { - $sWikiVersion = utils::GetItopVersionWikiSyntax(); //eg : '2_7_0'; + $sWikiVersion = utils::GetCoreVersionWikiSyntax(); //eg : '2_7_0'; $sAttachmentsVarsWikiPageUrl = 'https://www.itophub.io/wiki/page?id='.$sWikiVersion .':install:php_and_mysql_configuration#attachments_upload'; From 84280a3b5f45c59e4b2558e510b8d11336d47815 Mon Sep 17 00:00:00 2001 From: acognet Date: Fri, 4 Feb 2022 16:21:53 +0100 Subject: [PATCH 14/14] =?UTF-8?q?N=C2=B04530=20-=20Bug=20with=20OQL=20and?= =?UTF-8?q?=20profiles.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/dbobjectsearch.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/dbobjectsearch.class.php b/core/dbobjectsearch.class.php index 041e31e1a..a81e1c53b 100644 --- a/core/dbobjectsearch.class.php +++ b/core/dbobjectsearch.class.php @@ -1232,7 +1232,7 @@ class DBObjectSearch extends DBSearch elseif (MetaModel::IsParentClass($oRightFilter->GetFirstJoinedClass(), $oLeftFilter->GetClass())) { // Specialize $oRightFilter - $oRightFilter->ChangeClass($oLeftFilter->GetClass()); + $oRightFilter->ChangeClass($oLeftFilter->GetFirstJoinedClass()); } else {