Skip to content

Commit

Permalink
OXDEV-7518 Upgrade phpunit from 9 to 10
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniil Tkachev committed Nov 29, 2023
1 parent 5dc0c77 commit 2f02c0b
Show file tree
Hide file tree
Showing 45 changed files with 187 additions and 137 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## v2.2.0 - unreleased

### Added
- PHPUnit v10 support

### Removed
- PHPUnit v9 support

### Deprecated
- `SmartyCycleExtension` will be removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function setUp(): void
$this->extension = new PhpFunctionsExtension();
}

public function dummyTemplateProvider(): array
public static function dummyTemplateProvider(): array
{
return [
["{% set foo = 'bar'|parse_url %}{{ foo['path'] }}", 'bar'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ protected function setUp(): void
$this->extension = new RegexReplaceExtension();
}

public function dummyTemplateProvider(): array
public static function dummyTemplateProvider(): array
{
return [
["{{ '1-foo-2'|regex_replace('/[0-9]/', 'bar') }}", "bar-foo-bar"],
];
}

/**
*
* @dataProvider dummyTemplateProvider
*/
public function testIfPhpFunctionsAreCallable(string $template, string $expected)
Expand Down
35 changes: 11 additions & 24 deletions tests/Integration/Extensions/Filters/TranslateExtensionTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php //phpcs:disable

/**
* Copyright © OXID eSales AG. All rights reserved.
Expand Down Expand Up @@ -28,10 +28,7 @@ protected function setUp(): void
$this->extension = $this->get(TranslateExtension::class);
}

/**
* Provides data to testSimpleTranslating
*/
public function simpleTranslatingProvider(): array
public static function simpleTranslatingProvider(): array
{
return [
["{{ 'FIRST_NAME'|translate }}", 0, 'Vorname'],
Expand All @@ -41,9 +38,6 @@ public function simpleTranslatingProvider(): array
}

/**
* Tests simple translating, where only translation is fetched
*
*
* @dataProvider simpleTranslatingProvider
*/
public function testSimpleTranslating(string $template, int $languageId, string $expected): void
Expand All @@ -52,10 +46,7 @@ public function testSimpleTranslating(string $template, int $languageId, string
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
}

/**
* Provides data to testTranslatingWithArguments
*/
public function withArgumentsProvider(): array
public static function withArgumentsProvider(): array
{
return [
["{{ 'MANUFACTURER_S'|translate('Opel') }}", 0, '| Hersteller: Opel'],
Expand All @@ -66,8 +57,6 @@ public function withArgumentsProvider(): array
}

/**
* Tests value translating when translating strings containing %s
*
* @dataProvider withArgumentsProvider
*/
public function testTranslatingWithArguments(string $template, int $languageId, string $expected): void
Expand All @@ -76,21 +65,22 @@ public function testTranslatingWithArguments(string $template, int $languageId,
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
}

/**
* Provides data to testTranslateFrontend_isMissingTranslation
*/
public function missingTranslationProviderFrontend(): array
public static function missingTranslationProviderFrontend(): array
{
return [
[true, "{{ 'MY_MISING_TRANSLATION'|translate }}", 'MY_MISING_TRANSLATION'],
[false, "{{ 'MY_MISING_TRANSLATION'|translate }}", 'ERROR: Translation for MY_MISING_TRANSLATION not found!'],
[false, "{{ 'MY_MISING_TRANSLATION'|translate }}", 'ERROR: Translation for MY_MISING_TRANSLATION not found!'], //phpcs:disable
];
}

/**
* @dataProvider missingTranslationProviderFrontend
*/
public function testTranslateFrontendIsMissingTranslation(bool $isProductiveMode, string $template, string $expected): void
public function testTranslateFrontendIsMissingTranslation(
bool $isProductiveMode,
string $template,
string $expected
): void
{
$this->setAdminMode(false);
$this->setLanguage(1);
Expand All @@ -102,10 +92,7 @@ public function testTranslateFrontendIsMissingTranslation(bool $isProductiveMode
$this->assertStringContainsString($expected, $this->getTemplate($template)->render([]));
}

/**
* Provides data to testTranslateAdmin_isMissingTranslation
*/
public function missingTranslationProviderAdmin(): array
public static function missingTranslationProviderAdmin(): array
{
return [
["{{ 'MY_MISING_TRANSLATION'|translate }}", 'ERROR: Translation for MY_MISING_TRANSLATION not found!'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function setUp(): void
$this->setLanguage(0);
}

public function translateSalutationProvider(): array
public static function translateSalutationProvider(): array
{
return [
["{{ 'MR'|translate_salutation }}", 'Herr'],
Expand All @@ -39,7 +39,7 @@ public function testTranslateSalutation(string $template, string $expected): voi
{
$translateSalutationLogic = $this->getMockBuilder(TranslateSalutationLogic::class)
->disableOriginalConstructor()
->setMethods(['translateSalutation'])->getMock();
->onlyMethods(['translateSalutation'])->getMock();

$translateSalutationLogic->expects($this->once())->method('translateSalutation')->willReturn(
$expected
Expand Down
10 changes: 5 additions & 5 deletions tests/Integration/Extensions/Filters/TruncateExtensionTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php //phpcs:disable

/**
* Copyright © OXID eSales AG. All rights reserved.
Expand Down Expand Up @@ -32,7 +32,7 @@ public function testTruncate(string $template, string $expected): void
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
}

public function truncateProvider(): array
public static function truncateProvider(): array
{
return [
[
Expand All @@ -54,7 +54,7 @@ public function testTruncateWithLength(string $template, string $expected): void
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
}

public function truncateProviderWithLength(): array
public static function truncateProviderWithLength(): array
{
return [
[
Expand All @@ -80,7 +80,7 @@ public function testTruncateWithSuffix(string $template, string $expected): void
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
}

public function truncateProviderWithSuffix(): array
public static function truncateProviderWithSuffix(): array
{
return [
[
Expand All @@ -98,7 +98,7 @@ public function testTruncateWithBreakWords(string $template, string $expected):
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
}

public function truncateProviderWithBreakWords(): array
public static function truncateProviderWithBreakWords(): array
{
return [
[
Expand Down
12 changes: 4 additions & 8 deletions tests/Integration/Extensions/Filters/WordwrapExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ protected function setUp(): void
$this->extension = new WordwrapExtension(new WordwrapLogic());
}

/**
* Provides data for testWordWrapWithNonAscii
*/
public function nonAsciiProvider(): array
public static function nonAsciiProvider(): array
{
return [
['{{ "HÖ HÖ"|wordwrap(2) }}', "\n"],
Expand All @@ -45,10 +42,8 @@ public function testWordWrapWithNonAscii(string $template, string $expected): vo
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
}

/**
* Provides data for testWordWrapAscii
*/
public function asciiProvider(): array
//phpcs:disable
public static function asciiProvider(): array
{
return [
['{{ "aaa aaa"|wordwrap(2) }}', "aaa\naaa"],
Expand All @@ -65,6 +60,7 @@ public function asciiProvider(): array
]
];
}
//phpcs:enable

/**
* @dataProvider asciiProvider
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Extensions/FormatPriceExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function setUp(): void
$this->extension = new FormatPriceExtension($formatPriceLogic);
}

public function priceProvider(): array
public static function priceProvider(): array
{
return [
['{{ format_price(100) }}', '100,00 €'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function tearDown(): void
unset($_GET['foo']);
}

public function dummyTemplateProvider(): array
public static function dummyTemplateProvider(): array
{
return [
['{{ get_global_cookie("foo") }}', 'bar'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function testContent(string $template, string $expected): void
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
}

public function contentProvider(): array
public static function contentProvider(): array
{
return [
[
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Extensions/InputHelpExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function setUp(): void
$this->inputHelpExtension = new InputHelpExtension($inputHelpLogic);
}

public function getIdentProvider(): array
public static function getIdentProvider(): array
{
return [
[null, 1, false, null],
Expand All @@ -48,7 +48,7 @@ public function testGetIdent($params, $iLang, $blAdmin, $expected): void
$this->assertEquals($expected, $this->inputHelpExtension->getHelpId($params));
}

public function getHelpTextProvider(): array
public static function getHelpTextProvider(): array
{
return [
[null, 1, false, null],
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/Extensions/MailtoExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function testMailto(string $template, string $expected, array $variables
$this->assertEquals($expected, $this->getTemplate($template)->render($variables));
}

public function getMailtoTests(): array
//phpcs:disable
public static function getMailtoTests(): array
{
return [
[
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Extensions/PhpFunctionsExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected function setUp(): void
$this->extension = new PhpFunctionsExtension();
}

public function dummyTemplateProvider(): array
public static function dummyTemplateProvider(): array
{
return [
["{{ count({0:0, 1:1, 2:2}) }}", 3],
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Extensions/ScriptExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public function testScript(string $template, string $expected): void
$this->assertEquals($expected, $this->getTemplate($template)->render([]));
}

public function getScriptTests(): array
//phpcs:disable
public static function getScriptTests(): array
{
return [
// Empty buffer
[
"{{ script() }}",
""
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Extensions/SmartyCycleExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testStaticCycle(string $template, string $expected, array $varia
$this->assertEquals($expected, $this->getTemplate($template)->render($variables));
}

public function getStaticCycle(): array
public static function getStaticCycle(): array
{
return [
[
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Extensions/TranslateExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected function setUp(): void
$this->translateExtension = $this->get(TranslateExtension::class);
}

public function dataProvider(): array
public static function dataProvider(): array
{
return [
[['ident' => 'foobar'], 'ERROR: Translation for foobar not found!'],
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Extensions/UrlExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testAddUrlParameters(string $template, string $expected, array $
$this->assertEquals($expected, $this->getTemplate($template)->render($variables));
}

public function getSeoUrlTests(): array
public static function getSeoUrlTests(): array
{
return [
[
Expand All @@ -48,7 +48,7 @@ public function getSeoUrlTests(): array
];
}

public function getAddUrlParametersTests(): array
public static function getAddUrlParametersTests(): array
{
return [
[
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Resolver/TemplateFileResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function testResolveSmartyTemplate(string $templateName, string $expected
$this->assertEquals($expectedFilename, $filename);
}

public function templateNameFileDataProvider(): array
public static function templateNameFileDataProvider(): array
{
return [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@

class ModuleController extends FrontendController
{
protected $_sThisTemplate = '@module1/module_controller';
protected $_sThisTemplate = '@module1/module_controller'; //phpcs:disable
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use OxidEsales\Eshop\Application\Controller\FrontendController;

//phpcs:disable
class ModuleControllerMissingTemplate extends FrontendController
{
protected $_sThisTemplate = '@module1/module_controller_missing_template';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function testRenderWithShopTemplateAndSorting(string $sorting, string $ex
$this->assertStringContainsString($expectedResult, $actual);
}

public function renderShopTemplateDataProvider(): array
public static function renderShopTemplateDataProvider(): array
{
return [
[
Expand Down Expand Up @@ -124,7 +124,7 @@ public function testRenderWithModuleTemplateAndSorting(string $sorting, string $
$this->assertStringContainsString($expectedResult, $actual);
}

public function renderModuleTemplateDataProvider(): array
public static function renderModuleTemplateDataProvider(): array
{
return [
[
Expand Down Expand Up @@ -176,7 +176,7 @@ public function testRenderWithShopTemplateAmdFaultySortingConfiguration(
$this->assertStringContainsString($expectedResult, $actual);
}

public function renderWithShopTemplateAndFaultySortingConfigDataProvider(): array
public static function renderWithShopTemplateAndFaultySortingConfigDataProvider(): array
{
return [
[
Expand Down Expand Up @@ -223,7 +223,7 @@ public function testRenderWithModuleTemplateAndFaultySortingConfiguration(
$this->assertStringContainsString($expectedResult, $actual);
}

public function renderWithModuleTemplateAndFaultySortingConfigDataProvider(): array
public static function renderWithModuleTemplateAndFaultySortingConfigDataProvider(): array
{
return [
[
Expand Down
Loading

0 comments on commit 2f02c0b

Please sign in to comment.