Skip to content

Commit

Permalink
OXDEV-8498 Deprecate DateformatExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
AshrafOxid committed Dec 6, 2024
1 parent a44ad4c commit 6c8fc9e
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG-2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
### Removed
- PHPUnit v10 support

### Deprecated
- `DateFormatExtension` will be replaced by twig date filter

## v2.5.0 - 2024-10-14

### Removed
Expand Down
3 changes: 3 additions & 0 deletions src/Extensions/Filters/DateFormatExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;

/**
* @deprecated in next major version, use twig date filter
*/
class DateFormatExtension extends AbstractExtension
{
public function __construct(private DateFormatHelper $dateFormatHelper)
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Extensions/IncludeContentExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ protected function setUp(): void

$contentFactoryMock
->method('getContent')
->will($this->returnValueMap([
->willReturnMap([
['ident', 'german', $deContentMock],
['ident', 'english', $enContentMock],
['ident', 'twig_code', $twigContentMock],
['ident', 'dynamic_content', $dynamicContentMock],
['ident', 'not_active', $notActiveContentMock]
]));
]);

$this->extension = new IncludeContentExtension($contentFactoryMock);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
use OxidEsales\EshopCommunity\Tests\ContainerTrait;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateNotInChainException;
use OxidEsales\Twig\Tests\Integration\TestingFixturesTrait;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PHPUnit\Framework\TestCase;
use Twig\Error\LoaderError;

/** @runTestsInSeparateProcesses */
#[RunTestsInSeparateProcesses]
final class ModulesTemplateChainTest extends TestCase
{
use ContainerTrait;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
use OxidEsales\EshopCommunity\Tests\ContainerTrait;
use OxidEsales\Twig\Tests\Integration\TestingFixturesTrait;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PHPUnit\Framework\TestCase;

/** @runTestsInSeparateProcesses */
#[RunTestsInSeparateProcesses]
final class ModulesTemplateChainSortingTest extends TestCase
{
use ContainerTrait;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateEngineInterface;
use OxidEsales\EshopCommunity\Tests\ContainerTrait;
use OxidEsales\Twig\Tests\Integration\TestingFixturesTrait;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
use PHPUnit\Framework\TestCase;

/**
* @runTestsInSeparateProcesses
*/
#[RunTestsInSeparateProcesses]
final class ShopTemplateDirectoryResolvingTest extends TestCase
{
use ContainerTrait;
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/Extensions/Filters/DateFormatExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OxidEsales\EshopCommunity\Internal\Transition\Adapter\TemplateLogic\DateFormatHelper;
use OxidEsales\Twig\Extensions\Filters\DateFormatExtension;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use PHPUnit\Framework\TestCase;

final class DateFormatExtensionTest extends TestCase
Expand Down Expand Up @@ -49,6 +50,7 @@ public static function provider(): array
}

#[DataProvider('provider')]
#[IgnoreDeprecations]
public function testDateFormat($string, $format, $default_date, $expectedDate): void
{
$actualDate = $this->dateFormatExtension->dateFormat($string, $format, $default_date);
Expand Down
18 changes: 8 additions & 10 deletions tests/Unit/Loader/CmsLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,14 @@ public function setUp(): void

$contentFactoryMock
->method('getContent')
->will(
$this->returnValueMap(
[
['ident', 'valid', $validContentMock],
['oxid', 'english', $englishContentMock],
['ident', 'field', $fieldContentMock],
['oxid', 'notFresh', $notFreshContentMock],
['ident', 'notValid', $notValidContentMock]
]
)
->willReturnMap(
[
['ident', 'valid', $validContentMock],
['oxid', 'english', $englishContentMock],
['ident', 'field', $fieldContentMock],
['oxid', 'notFresh', $notFreshContentMock],
['ident', 'notValid', $notValidContentMock]
]
);

/** @var ContentFactory $contentFactoryMock */
Expand Down

0 comments on commit 6c8fc9e

Please sign in to comment.