Commit 6e9e1334 authored by Thomas Löffler's avatar Thomas Löffler

Merge branch 'ci/improve-tests' into 'develop'

[TASK] Improve tests

See merge request !630
parents 708082a1 6def2ea9
Pipeline #10452 passed with stages
in 6 minutes and 36 seconds
......@@ -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(10);
self::assertEquals(
3000,
3010,
$extension->getDownloads()
);
}
......
......@@ -199,4 +199,87 @@ class ExtensionIndexServiceTest extends UnitTestCase
$resultString = preg_replace('/\<!--Index created(.*)--\>\n/m', '', $resultString);
self::assertEquals($expected, $resultString);
}
/**
* @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 &amp; Jerry'
],
'String with double quote' => [
'"Sarcasm"',
'&quot;Sarcasm&quot;'
],
// The mutation went away, but still missing two test cases, but they failed to me.
/*'String with single quote' => [
"'Sarcasm'",
'&apos;Sarcasm&apos;'
],
'String with <>' => [
'1 <> 2',
'1 &lt;&gt; 2'
]*/
];
// ['&', '"', "'", '<', '>'], ['&amp;', '&quot;', '&apos;', '&lt;', '&gt;']
}
}
......@@ -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];
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment