Skip to content

Commit 16071fb

Browse files
committed
OXDEV-9270 Update to phpunit 12.5
1 parent 896f110 commit 16071fb

20 files changed

Lines changed: 57 additions & 85 deletions

.github/oxid-esales/twig-component.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ install:
1919
"mikey179/vfsstream": "~1.6.8",
2020
"oxid-esales/developer-tools": "{{ .Data.install.composer.dev_ref }}",
2121
"phpspec/prophecy-phpunit": "^v2.0.1",
22-
"phpunit/phpunit": "^11.4"
22+
"phpunit/phpunit": "^12.5"
2323
},
2424
"autoload-dev":{
2525
"psr-4":{

tests/Integration/Extensions/IncludeContentExtensionTest.php

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
use OxidEsales\EshopCommunity\Tests\ContainerTrait;
1717
use OxidEsales\Twig\Extensions\IncludeContentExtension;
1818
use PHPUnit\Framework\Attributes\DataProvider;
19-
use PHPUnit\Framework\MockObject\MockBuilder;
20-
use PHPUnit\Framework\MockObject\MockObject;
2119
use Twig\Environment;
2220
use Twig\Error\LoaderError;
2321
use Twig\Extension\StringLoaderExtension;
@@ -28,25 +26,16 @@ final class IncludeContentExtensionTest extends AbstractExtensionTestCase
2826
{
2927
use ContainerTrait;
3028

31-
private MockBuilder $contentMockBuilder;
32-
private MockObject&ContentFactory $contentFactoryMock;
29+
private ContentFactory $contentFactoryStub;
3330
private string $spamContent = 'not spam<script>alert("spam")</script>';
3431

3532
protected function setUp(): void
3633
{
3734
parent::setUp();
3835

39-
$this->contentMockBuilder = $this
40-
->getMockBuilder(Content::class)
41-
->disableOriginalConstructor()
42-
->onlyMethods(['getLanguage']);
36+
$this->contentFactoryStub = $this->createStub(ContentFactory::class);
4337

44-
$this->contentFactoryMock = $this
45-
->getMockBuilder(ContentFactory::class)
46-
->onlyMethods(['getContent'])
47-
->getMock();
48-
49-
$this->contentFactoryMock
38+
$this->contentFactoryStub
5039
->method('getContent')
5140
->willReturnMap($this->getContentMap());
5241
}
@@ -113,49 +102,49 @@ private function initializeExtension(bool $sanitizerEnabled): void
113102
$this->attachContainerToContainerFactory();
114103

115104
$this->extension = new IncludeContentExtension(
116-
$this->contentFactoryMock,
105+
$this->contentFactoryStub,
117106
ContainerFacade::get(HtmlSanitizerInterface::class)
118107
);
119108
}
120109

121-
private function prepareContentMock(int $language, array $fields): MockObject
110+
private function prepareContent(int $language, array $fields): Content
122111
{
123-
$mock = $this->contentMockBuilder->getMock();
124-
$mock->method('getLanguage')->willReturn($language);
112+
$content = new Content();
113+
$content->setLanguage($language);
125114

126115
foreach ($fields as $field => $value) {
127116
$property = 'oxcontents__' . $field;
128-
$mock->$property = (object)['value' => $value];
117+
$content->$property = (object)['value' => $value];
129118
}
130119

131-
return $mock;
120+
return $content;
132121
}
133122

134-
/** Build the content return map for the mock factory */
123+
/** Build the content return map for the stub factory */
135124
private function getContentMap(): array
136125
{
137126
return [
138-
['ident', 'german', $this->prepareContentMock(0, [
127+
['ident', 'german', $this->prepareContent(0, [
139128
'oxactive' => true,
140129
'oxcontent' => 'Template code (DE)',
141130
])],
142-
['ident', 'english', $this->prepareContentMock(1, [
131+
['ident', 'english', $this->prepareContent(1, [
143132
'oxactive' => true,
144133
'oxcontent' => 'Template code (EN)',
145134
])],
146-
['ident', 'twig_code', $this->prepareContentMock(0, [
135+
['ident', 'twig_code', $this->prepareContent(0, [
147136
'oxactive' => true,
148137
'oxcontent' => 'In my_var I have {{ my_var }} value',
149138
])],
150-
['ident', 'dynamic_content', $this->prepareContentMock(0, [
139+
['ident', 'dynamic_content', $this->prepareContent(0, [
151140
'oxactive' => true,
152141
'oxcontent' => 'Dynamic content',
153142
])],
154-
['ident', 'not_active', $this->prepareContentMock(0, [
143+
['ident', 'not_active', $this->prepareContent(0, [
155144
'oxactive' => false,
156145
'oxcontent' => 'Not active content',
157146
])],
158-
['ident', 'spam', $this->prepareContentMock(0, [
147+
['ident', 'spam', $this->prepareContent(0, [
159148
'oxactive' => true,
160149
'oxcontent' => $this->spamContent,
161150
])],

tests/Integration/TwigEngineTest.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use org\bovigo\vfs\vfsStream;
1313
use OxidEsales\Twig\Resolver\TemplateChain\TemplateChainResolverInterface;
1414
use OxidEsales\Twig\TwigEngine;
15-
use OxidEsales\Twig\TwigEngineConfigurationInterface;
1615
use PHPUnit\Framework\TestCase;
1716
use Prophecy\PhpUnit\ProphecyTrait;
1817
use Prophecy\Prophecy\ObjectProphecy;
@@ -87,15 +86,6 @@ public function testRenderFragment(): void
8786

8887
private function getEngine(): TwigEngine
8988
{
90-
/** @var TwigEngineConfigurationInterface $configuration */
91-
$configuration = $this->getMockBuilder(TwigEngineConfigurationInterface::class)->getMock();
92-
$configuration->method('getParameters')
93-
->willReturn([
94-
'template_dir' => [$this->templateDirPath],
95-
'is_debug' => 'false',
96-
'cache_dir' => 'foo',
97-
]);
98-
9989
$loader = new FilesystemLoader($this->templateDirPath);
10090

10191
$engine = new Environment($loader);

tests/Unit/Escaper/DecEntityEscaperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function setUp(): void
2424
{
2525
parent::setUp();
2626
$this->escaper = new DecEntityEscaper();
27-
$this->environment = $this->createMock(Environment::class);
27+
$this->environment = $this->createStub(Environment::class);
2828
}
2929

3030
public function testEscape(): void

tests/Unit/Escaper/HexEntityEscaperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function setUp(): void
2424
{
2525
parent::setUp();
2626
$this->escaper = new HexEntityEscaper();
27-
$this->environment = $this->createMock(Environment::class);
27+
$this->environment = $this->createStub(Environment::class);
2828
}
2929

3030
public function testEscape(): void

tests/Unit/Escaper/HexEscaperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function setUp(): void
2424
{
2525
parent::setUp();
2626
$this->escaper = new HexEscaper();
27-
$this->environment = $this->createMock(Environment::class);
27+
$this->environment = $this->createStub(Environment::class);
2828
}
2929

3030
public function testEscape(): void

tests/Unit/Escaper/HtmlAllEscaperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function setUp(): void
2525
{
2626
parent::setUp();
2727
$this->escaper = new HtmlAllEscaper();
28-
$this->environment = $this->createMock(Environment::class);
28+
$this->environment = $this->createStub(Environment::class);
2929
}
3030

3131
public static function escapeProvider(): array

tests/Unit/Escaper/MailEscaperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function setUp(): void
2525
{
2626
parent::setUp();
2727
$this->escaper = new MailEscaper();
28-
$this->environment = $this->createMock(Environment::class);
28+
$this->environment = $this->createStub(Environment::class);
2929
}
3030

3131
public static function escapeProvider(): array

tests/Unit/Escaper/NonStdEscaperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function setUp(): void
2424
{
2525
parent::setUp();
2626
$this->escaper = new NonStdEscaper();
27-
$this->environment = $this->createMock(Environment::class);
27+
$this->environment = $this->createStub(Environment::class);
2828
}
2929

3030
public function testEscape(): void

tests/Unit/Escaper/QuotesEscaperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected function setUp(): void
2424
{
2525
parent::setUp();
2626
$this->escaper = new QuotesEscaper();
27-
$this->environment = $this->createMock(Environment::class);
27+
$this->environment = $this->createStub(Environment::class);
2828
}
2929

3030
public function testEscape(): void

0 commit comments

Comments
 (0)