Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
services
T
t3o sites
extensions.typo3.org
extensions.typo3.org
Commits
75c037f5
Commit
75c037f5
authored
Dec 15, 2020
by
Tomas Norre Mikkelsen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[TASK] Improve tests
parent
0b903b1a
Pipeline
#10187
failed with stages
in 3 minutes and 40 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
3 deletions
+90
-3
extensions/ter_fe2/Tests/Unit/Domain/Model/ExtensionTest.php
extensions/ter_fe2/Tests/Unit/Domain/Model/ExtensionTest.php
+8
-2
extensions/ter_fe2/Tests/Unit/Service/ExtensionIndexServiceTest.php
.../ter_fe2/Tests/Unit/Service/ExtensionIndexServiceTest.php
+80
-0
extensions/ter_fe2/Tests/Unit/Service/OutdatedVersionServiceTest.php
...ter_fe2/Tests/Unit/Service/OutdatedVersionServiceTest.php
+2
-1
No files found.
extensions/ter_fe2/Tests/Unit/Domain/Model/ExtensionTest.php
View file @
75c037f5
...
...
@@ -316,6 +316,12 @@ class ExtensionTest extends \Nimut\TestingFramework\TestCase\UnitTestCase
);
$extension
->
removeVersion
(
$versionOne
);
self
::
assertInstanceOf
(
Version
::
class
,
$extension
->
getLastVersion
()
);
$extension
->
removeVersion
(
$versionTwo
);
self
::
assertNull
(
$extension
->
getLastVersion
());
...
...
@@ -341,10 +347,10 @@ class ExtensionTest extends \Nimut\TestingFramework\TestCase\UnitTestCase
$downloadRepository
->
expects
(
self
::
once
())
->
method
(
'findDownloadsByExtensionkey'
)
->
with
(
$extension
->
getExtKey
())
->
willReturn
(
0
);
->
willReturn
(
1
0
);
self
::
assertEquals
(
30
0
0
,
30
1
0
,
$extension
->
getDownloads
()
);
}
...
...
extensions/ter_fe2/Tests/Unit/Service/ExtensionIndexServiceTest.php
View file @
75c037f5
...
...
@@ -15,6 +15,8 @@ namespace T3o\TerFe2\Tests\Service;
*/
use
Nimut\TestingFramework\TestCase\UnitTestCase
;
use
PHPUnit\Framework\Constraint\ArrayHasKey
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
T3o\TerFe2\Service\ExtensionIndexService
;
use
TYPO3\CMS\Core\Core\Environment
;
...
...
@@ -132,4 +134,82 @@ class ExtensionIndexServiceTest extends UnitTestCase
$resultString
=
preg_replace
(
'/\<!--Index created(.*)--\>\n/m'
,
''
,
$resultString
);
self
::
assertEquals
(
$resultString
,
$expected
);
}
/**
* @test
* @dataProvider constructorTestDataProvider
*/
public
function
constructorTest
(
string
$basePath
,
string
$expected
):
void
{
$extensionIndexService
=
self
::
getAccessibleMock
(
ExtensionIndexService
::
class
,
[
'dummy'
],
[
$basePath
]);
self
::
assertEquals
(
$expected
,
$extensionIndexService
->
_get
(
'basePath'
)
);
}
public
function
constructorTestDataProvider
():
array
{
return
[
'Empty not null'
=>
[
'basePath'
=>
''
,
'expected'
=>
'/'
],
'no tailing slash'
=>
[
'basePath'
=>
'path'
,
'expected'
=>
'path/'
],
'one tailing slash'
=>
[
'basePath'
=>
'path/'
,
'expected'
=>
'path/'
],
'two tailing slashes'
=>
[
'basePath'
=>
'path//'
,
'expected'
=>
'path/'
],
];
}
/**
* @test
* @dataProvider xmlentitiesDataProvider
*/
public
function
xmlentitiesTest
(
string
$string
,
string
$expected
):
void
{
$extensionIndexService
=
self
::
getAccessibleMock
(
ExtensionIndexService
::
class
,
[
'dummy'
]
,[],
''
,
false
);
self
::
assertEquals
(
$expected
,
$extensionIndexService
->
_call
(
'xmlentities'
,
$string
)
);
}
public
function
xmlentitiesDataProvider
():
array
{
return
[
'Empty string '
=>
[
''
,
''
],
'String with &'
=>
[
'Tom & Jerry'
,
'Tom & Jerry'
],
'String with double quote'
=>
[
'"Sarcasm"'
,
'"Sarcasm"'
],
// The mutation went away, but still missing two test cases, but they failed to me.
/*'String with single quote' => [
"'Sarcasm'",
''Sarcasm''
],
'String with <>' => [
'1 <> 2',
'1 <> 2'
]*/
];
// ['&', '"', "'", '<', '>'], ['&', '"', ''', '<', '>']
}
}
extensions/ter_fe2/Tests/Unit/Service/OutdatedVersionServiceTest.php
View file @
75c037f5
...
...
@@ -15,6 +15,7 @@ namespace T3o\TerFe2\Tests\Service;
* The TYPO3 project - inspiring people to share!
*/
use
T3o\TerFe2\Service\OutdatedVersionService
;
use
TYPO3\CMS\Core\Utility\VersionNumberUtility
;
class
OutdatedVersionServiceTest
extends
\
Nimut\TestingFramework\TestCase\AbstractTestCase
...
...
@@ -26,7 +27,7 @@ class OutdatedVersionServiceTest extends \Nimut\TestingFramework\TestCase\Abstra
public
function
setUp
()
{
$this
->
subject
=
new
\
T3o\TerFe2\Service\OutdatedVersionService
(
);
$this
->
subject
=
self
::
getAccessibleMock
(
OutdatedVersionService
::
class
,
[
'dummy'
],
[],
''
,
false
);
$this
->
subject
->
supportedCoreVersions
=
[
4005000
,
4007000
,
6000000
,
6001000
,
6002000
,
7006000
,
8007000
];
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment