Skip to content

Commit 20f9141

Browse files
authored
Allow Symfony 7 support (#65)
* 🐛 Allow sf7 and fix tests * 🐛 Fix test
1 parent 6983039 commit 20f9141

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
"require": {
1212
"php": "^7.2 || ^8.0",
1313
"php-translation/common": "^3.0",
14-
"symfony/translation": "^3.4 || ^4.2 || ^5.0 || ^6.0"
14+
"symfony/translation": "^3.4 || ^4.2 || ^5.0 || ^6.0 || ^7.0"
1515
},
1616
"require-dev": {
1717
"phpunit/phpunit": ">=8.5.20",
18-
"symfony/framework-bundle": " ^3.4 || ^4.2 || ^5.0 || ^6.0"
18+
"symfony/framework-bundle": " ^3.4 || ^4.2 || ^5.0 || ^6.0 || ^7.0"
1919
},
2020
"autoload": {
2121
"psr-4": {

tests/Unit/FileStorageTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testConstructorEmptyArray()
4141
public function testCreateNewCatalogue()
4242
{
4343
$writer = $this->getMockBuilder(TranslationWriter::class)
44-
->setMethods([$this->getMethodNameToWriteTranslations()])
44+
->onlyMethods([$this->getMethodNameToWriteTranslations()])
4545
->disableOriginalConstructor()
4646
->getMock();
4747
$writer->expects($this->once())
@@ -56,7 +56,7 @@ public function testCreateNewCatalogue()
5656
$storage->create(new Message('key', 'domain', 'en', 'Message'));
5757

5858
$writer = $this->getMockBuilder(TranslationWriter::class)
59-
->setMethods([$this->getMethodNameToWriteTranslations()])
59+
->onlyMethods([$this->getMethodNameToWriteTranslations()])
6060
->disableOriginalConstructor()
6161
->getMock();
6262
$writer->expects($this->once())
@@ -74,7 +74,7 @@ public function testCreateNewCatalogue()
7474
public function testCreateExistingCatalogue()
7575
{
7676
$writer = $this->getMockBuilder(TranslationWriter::class)
77-
->setMethods([$this->getMethodNameToWriteTranslations()])
77+
->onlyMethods([$this->getMethodNameToWriteTranslations()])
7878
->disableOriginalConstructor()
7979
->getMock();
8080
$writer->expects($this->once())
@@ -117,7 +117,7 @@ public function testGet()
117117
public function testUpdate()
118118
{
119119
$writer = $this->getMockBuilder(TranslationWriter::class)
120-
->setMethods([$this->getMethodNameToWriteTranslations()])
120+
->onlyMethods([$this->getMethodNameToWriteTranslations()])
121121
->disableOriginalConstructor()
122122
->getMock();
123123
$writer->expects($this->exactly(2))
@@ -139,7 +139,7 @@ public function testUpdate()
139139
public function testDelete()
140140
{
141141
$writer = $this->getMockBuilder(TranslationWriter::class)
142-
->setMethods([$this->getMethodNameToWriteTranslations()])
142+
->onlyMethods([$this->getMethodNameToWriteTranslations()])
143143
->disableOriginalConstructor()
144144
->getMock();
145145

@@ -163,7 +163,7 @@ public function testDelete()
163163
public function testImport()
164164
{
165165
$writer = $this->getMockBuilder(TranslationWriter::class)
166-
->setMethods([$this->getMethodNameToWriteTranslations()])
166+
->onlyMethods([$this->getMethodNameToWriteTranslations()])
167167
->disableOriginalConstructor()
168168
->getMock();
169169

tests/Unit/XliffConverterTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public function testCatalogueToContent()
3636
$catalogue->add(['foobar' => 'bar']);
3737
$content = XliffConverter::catalogueToContent($catalogue, 'messages');
3838

39-
$this->assertRegExp('|foobar|', $content);
39+
// If PHPUnit 9.0 or higher is used, use assertMatchesRegularExpression() instead
40+
if (method_exists($this, 'assertMatchesRegularExpression')) {
41+
$this->assertMatchesRegularExpression('/foobar/', $content);
42+
} else {
43+
$this->assertRegExp('|foobar|', $content);
44+
}
4045
}
4146
}

0 commit comments

Comments
 (0)