Skip to content

Commit

Permalink
Merge branch 'b-7.3.x' into b-8.0.x
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG-2.x.md
#	tests/Integration/Extensions/Filters/RegexReplaceExtensionTest.php
#	tests/Integration/Extensions/MailtoExtensionTest.php
#	tests/Integration/Extensions/PhpFunctionsExtensionTest.php
#	tests/Integration/Extensions/SmartyCycleExtensionTest.php
#	tests/Integration/Resolver/TemplateFileResolverTest.php
  • Loading branch information
AshrafOxid committed Nov 7, 2024
2 parents 873588f + 6cd42a2 commit 40d3420
Show file tree
Hide file tree
Showing 36 changed files with 314 additions and 247 deletions.
84 changes: 84 additions & 0 deletions CHANGELOG-2.x.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Change Log for OXID Twig engine component

## v2.6.0 - Unreleased

### Added
- Twig ^v3.14 support
- PHPUnit v11 support

### Removed
- PHPUnit v10 support

## v2.5.0 - 2024-10-14

### Removed
- PHP v8.1 support

### Fixed
- Ifcontent will parse body even if content not existing [#0007231](https://bugs.oxid-esales.com/view.php?id=7231)

## v2.4.0 - 2024-03-15

### Added
- PHPUnit v10 support

### Removed
- PHP v8.0 support

### Deprecated
- Appending missing file extensions (`".html.twig"`) to template names will be discontinued.
Since v3, the component will support only full template names.

## v2.3.0 - 2024-03-11

### Changed
- Getting cache configuration parameter using templating cache service instead of context

## v2.2.0 - 2023-11-16

### Deprecated
- `SmartyCycleExtension` will be removed

## v2.1.0 - 2023-05-04

### Added
- Service Parameter to disable template caching `oxid_esales.templating.disable_twig_template_caching`

### Removed
- Dependency to `webmozart/path-util`

### Fixed
- Loading of shop templates when a theme inheritance is used
- Can't extend ` include_dynamic` template [#0007418](https://bugs.oxid-esales.com/view.php?id=7418)

### Changed
- `Loader\FilesystemLoader` reloads template directories on admin mode change
- `TwigContext::getActiveThemeId()` throws exception instead of type error when no theme is configured
- License updated

## v2.0.1 - 2022-11-23

### Fixed
- Warnings reported with stricter `error_reporting` level

## v2.0.0 - 2022-10-28

### Added
- Twig templates multi inheritance for modules
- Support for PHP v8
- `{{ content() }}` function to load content from DB
- `{% include_content %}` tag which includes template from DB

### Changed
- Switched to Twig v3

### Removed
- Support for PHP v7
- Support for `assign_adv` plugin
- `Resolver\TemplateNameResolver`
- `TwigContextInterface::getCacheDir()`, `TwigContextInterface::getTemplateDirectories()` and `TwigEngine::getDefaultFileExtension()`
- Redundant `is_safe` from extension initiation options

### Deprecated
- `Loader\CmsLoader`,
- `Loader\CmsTemplateNameParser`
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace OxidEsales\Twig\Tests\Integration\Extensions\Filters;

use OxidEsales\Twig\Extensions\Filters\PhpFunctionsExtension;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Twig\Environment;
use Twig\Loader\ArrayLoader;
Expand All @@ -36,10 +37,7 @@ public static function dummyTemplateProvider(): array
];
}

/**
* @param mixed $expected
* @dataProvider dummyTemplateProvider
*/
#[DataProvider('dummyTemplateProvider')]
public function testIfPhpFunctionsAreCallable(string $template, $expected): void
{
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace OxidEsales\Twig\Tests\Integration\Extensions\Filters;

use OxidEsales\Twig\Extensions\Filters\RegexReplaceExtension;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Twig\Environment;
use Twig\Loader\ArrayLoader;
Expand All @@ -31,9 +32,7 @@ public static function dummyTemplateProvider(): array
];
}

/**
* @dataProvider dummyTemplateProvider
*/
#[DataProvider('dummyTemplateProvider')]
public function testIfPhpFunctionsAreCallable(string $template, string $expected): void
{
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
Expand Down
17 changes: 5 additions & 12 deletions tests/Integration/Extensions/Filters/TranslateExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OxidEsales\EshopCommunity\Core\Registry;
use OxidEsales\Twig\Extensions\Filters\TranslateExtension;
use OxidEsales\Twig\Tests\Integration\Extensions\AbstractExtensionTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use Twig\Extension\AbstractExtension;

final class TranslateExtensionTest extends AbstractExtensionTestCase
Expand All @@ -34,9 +35,7 @@ public static function simpleTranslatingProvider(): array
];
}

/**
* @dataProvider simpleTranslatingProvider
*/
#[DataProvider('simpleTranslatingProvider')]
public function testSimpleTranslating(string $template, int $languageId, string $expected): void
{
$this->setLanguage($languageId);
Expand All @@ -61,9 +60,7 @@ public static function withArgumentsProvider(): array
];
}

/**
* @dataProvider withArgumentsProvider
*/
#[DataProvider('withArgumentsProvider')]
public function testTranslatingWithArguments(string $template, int $languageId, string $expected): void
{
$this->setLanguage($languageId);
Expand All @@ -82,9 +79,7 @@ public static function missingTranslationProviderFrontend(): array
];
}

/**
* @dataProvider missingTranslationProviderFrontend
*/
#[DataProvider('missingTranslationProviderFrontend')]
public function testTranslateFrontendIsMissingTranslation(
bool $isProductiveMode,
string $template,
Expand All @@ -107,9 +102,7 @@ public static function missingTranslationProviderAdmin(): array
];
}

/**
* @dataProvider missingTranslationProviderAdmin
*/
#[DataProvider('missingTranslationProviderAdmin')]
public function testTranslateAdminIsMissingTranslation(string $template, string $expected): void
{
$this->setLanguage(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OxidEsales\EshopCommunity\Internal\Transition\Adapter\TemplateLogic\TranslateSalutationLogic;
use OxidEsales\Twig\Extensions\Filters\TranslateSalutationExtension;
use OxidEsales\Twig\Tests\Integration\Extensions\AbstractExtensionTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use Twig\Extension\AbstractExtension;

final class TranslateSalutationExtensionTest extends AbstractExtensionTestCase
Expand All @@ -32,9 +33,7 @@ public static function translateSalutationProvider(): array
];
}

/**
* @dataProvider translateSalutationProvider
*/
#[DataProvider('translateSalutationProvider')]
public function testTranslateSalutation(string $template, string $expected): void
{
$translateSalutationLogic = $this->getMockBuilder(TranslateSalutationLogic::class)
Expand Down
17 changes: 5 additions & 12 deletions tests/Integration/Extensions/Filters/TruncateExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OxidEsales\EshopCommunity\Internal\Transition\Adapter\TemplateLogic\TruncateLogic;
use OxidEsales\Twig\Extensions\Filters\TruncateExtension;
use OxidEsales\Twig\Tests\Integration\Extensions\AbstractExtensionTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use Twig\Extension\AbstractExtension;

final class TruncateExtensionTest extends AbstractExtensionTestCase
Expand All @@ -24,9 +25,7 @@ public function setUp(): void
parent::setUp();
}

/**
* @dataProvider truncateProvider
*/
#[DataProvider('truncateProvider')]
public function testTruncate(string $template, string $expected): void
{
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
Expand All @@ -49,9 +48,7 @@ public static function truncateProvider(): array
];
}

/**
* @dataProvider truncateProviderWithLength
*/
#[DataProvider('truncateProviderWithLength')]
public function testTruncateWithLength(string $template, string $expected): void
{
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
Expand All @@ -76,9 +73,7 @@ public static function truncateProviderWithLength(): array
];
}

/**
* @dataProvider truncateProviderWithSuffix
*/
#[DataProvider('truncateProviderWithSuffix')]
public function testTruncateWithSuffix(string $template, string $expected): void
{
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
Expand All @@ -95,9 +90,7 @@ public static function truncateProviderWithSuffix(): array
];
}

/**
* @dataProvider truncateProviderWithBreakWords
*/
#[DataProvider('truncateProviderWithBreakWords')]
public function testTruncateWithBreakWords(string $template, string $expected): void
{
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OxidEsales\EshopCommunity\Internal\Transition\Adapter\TemplateLogic\WordwrapLogic;
use OxidEsales\Twig\Extensions\Filters\WordwrapExtension;
use OxidEsales\Twig\Tests\Integration\Extensions\AbstractExtensionTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use Twig\Extension\AbstractExtension;

final class WordwrapExtensionTest extends AbstractExtensionTestCase
Expand All @@ -34,9 +35,7 @@ public static function nonAsciiProvider(): array
];
}

/**
* @dataProvider nonAsciiProvider
*/
#[DataProvider('nonAsciiProvider')]
public function testWordWrapWithNonAscii(string $template, string $expected): void
{
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
Expand All @@ -62,9 +61,7 @@ public static function asciiProvider(): array
];
}

/**
* @dataProvider asciiProvider
*/
#[DataProvider('asciiProvider')]
public function testWordWrapAscii(string $template, string $expected): void
{
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Extensions/FormatPriceExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use OxidEsales\EshopCommunity\Internal\Transition\Adapter\TemplateLogic\FormatPriceLogic;
use OxidEsales\Twig\Extensions\FormatPriceExtension;
use PHPUnit\Framework\Attributes\DataProvider;

final class FormatPriceExtensionTest extends AbstractExtensionTestCase
{
Expand All @@ -30,10 +31,9 @@ public static function priceProvider(): array
}

/**
*
* @dataProvider priceProvider
* @covers \OxidEsales\Twig\Extensions\FormatPriceExtension::formatPrice
*/
#[DataProvider('priceProvider')]
public function testFormatPrice($template, $expected): void
{
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace OxidEsales\Twig\Tests\Integration\Extensions;

use OxidEsales\Twig\Extensions\GetRequestVariablesExtension;
use PHPUnit\Framework\Attributes\DataProvider;
use Twig\Extension\AbstractExtension;

final class GetRequestVariablesExtensionTest extends AbstractExtensionTestCase
Expand All @@ -34,9 +35,7 @@ public static function dummyTemplateProvider(): array
];
}

/**
* @dataProvider dummyTemplateProvider
*/
#[DataProvider('dummyTemplateProvider')]
public function testIfPhpFunctionsAreCallable(string $template, string $expected): void
{
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
Expand Down
5 changes: 2 additions & 3 deletions tests/Integration/Extensions/IncludeContentExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OxidEsales\EshopCommunity\Application\Model\Content;
use OxidEsales\EshopCommunity\Internal\Transition\Adapter\TemplateLogic\ContentFactory;
use OxidEsales\Twig\Extensions\IncludeContentExtension;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockBuilder;
use PHPUnit\Framework\MockObject\MockObject;
use Twig\Environment;
Expand Down Expand Up @@ -73,9 +74,7 @@ public function setUp(): void
$this->extension = new IncludeContentExtension($contentFactoryMock);
}

/**
* @dataProvider contentProvider
*/
#[DataProvider('contentProvider')]
public function testContent(string $template, string $expected): void
{
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
Expand Down
19 changes: 5 additions & 14 deletions tests/Integration/Extensions/InputHelpExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OxidEsales\EshopCommunity\Internal\Transition\Adapter\TemplateLogic\InputHelpLogic;
use OxidEsales\Twig\Extensions\InputHelpExtension;
use OxidEsales\Twig\Tests\Integration\Extensions\AbstractExtensionTestCase;
use PHPUnit\Framework\Attributes\DataProvider;

final class InputHelpExtensionTest extends AbstractExtensionTestCase
{
Expand All @@ -33,15 +34,10 @@ public static function getIdentProvider(): array
}

/**
* @param $params
* @param $iLang
* @param $blAdmin
* @param $expected
*
* @dataProvider getIdentProvider
* @covers \OxidEsales\Twig\Extensions\InputHelpExtension::getHelpId
*/
public function testGetIdent($params, $iLang, $blAdmin, $expected): void
#[DataProvider('getIdentProvider')]
public function testGetIdent(?string $params, int $iLang, bool $blAdmin, ?string $expected): void
{
$this->setLanguage($iLang);
$this->setAdminMode($blAdmin);
Expand All @@ -59,15 +55,10 @@ public static function getHelpTextProvider(): array
}

/**
* @param $params
* @param $iLang
* @param $blAdmin
* @param $expected
*
* @dataProvider getHelpTextProvider
* @covers \OxidEsales\Twig\Extensions\InputHelpExtension::getHelpText
*/
public function testGetHelpText($params, $iLang, $blAdmin, $expected): void
#[DataProvider('getHelpTextProvider')]
public function testGetHelpText(?string $params, int $iLang, bool $blAdmin, ?string $expected): void
{
$this->setLanguage($iLang);
$this->setAdminMode($blAdmin);
Expand Down
5 changes: 2 additions & 3 deletions tests/Integration/Extensions/MailtoExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace OxidEsales\Twig\Tests\Integration\Extensions;

use OxidEsales\Twig\Extensions\MailtoExtension;
use PHPUnit\Framework\Attributes\DataProvider;

final class MailtoExtensionTest extends AbstractExtensionTestCase
{
Expand All @@ -19,9 +20,7 @@ public function setUp(): void
$this->extension = new MailtoExtension();
}

/**
* @dataProvider getMailtoTests
*/
#[DataProvider('getMailtoTests')]
public function testMailto(string $template, string $expected, array $variables = []): void
{
$this->assertEquals($expected, $this->getTemplate($template)->render($variables));
Expand Down
Loading

0 comments on commit 40d3420

Please sign in to comment.