Commit 75c037f5 authored by Tomas Norre Mikkelsen's avatar Tomas Norre Mikkelsen

[TASK] Improve tests

parent 0b903b1a
Pipeline #10187 failed with stages
in 3 minutes and 40 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()
);
}
......
......@@ -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 &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