Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][TASK] Fix failing tests in v2 #466

Draft
wants to merge 37 commits into
base: develop-2.0
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
288155a
[TASK] Require at least TYPO3 ^9.5 and ^10.4
mabolek Nov 20, 2020
383d6a8
[FEATURE] CI with Github Actions
mabolek Nov 20, 2020
16c2329
[TASK] Include typoscript linter and raise codesniffer version
mabolek Dec 3, 2020
94961a9
[TASK] Added composer scripts
mabolek Dec 3, 2020
cc3d6bb
[TASK] Renamed .ts to .typoscript
mabolek Dec 3, 2020
130c1da
[TASK] Added .editorconfig
mabolek Dec 3, 2020
0275916
[CLEANUP] CS compliance for TypoScript
mabolek Dec 3, 2020
4a67d39
[CLEANUP] CS compliance for PHP
mabolek Dec 3, 2020
14fab17
[CLEANUP] CS fix TypoScript indentation
mabolek Dec 3, 2020
73454c5
Revert "[CLEANUP] CS fix TypoScript indentation"
mabolek Dec 3, 2020
097ea38
[TASK] Add TS lint configuration
mabolek Dec 3, 2020
751edbc
[TASK] Added PHP CS config from TYPO3 Core
mabolek Dec 3, 2020
7bb5ba7
[CLEANUP] TypoScript CS fixes
mabolek Dec 3, 2020
6133f79
[TASK] Migrate to php-cs-fixer for sniff and fix
mabolek Dec 18, 2020
a99c4bd
[TASK] Set PHP 7.4 for code sniffer job
mabolek Jan 12, 2021
914d3fc
[TASK] Set PHP 7.4 for TS linter job
mabolek Jan 12, 2021
003d6ed
[TASK] Set TS linter indent level to 2
mabolek Jan 12, 2021
b8c8fbf
[TASK] Move php-cs-fixer config to root directory
mabolek Jan 12, 2021
fea48eb
[TASK] Delete .travis.yml
mabolek Jan 12, 2021
a7a9aed
[TASK] Set checkstyle format on php sniff
mabolek Jan 12, 2021
cd427c4
[TASK] Enabled diff for PHP sniffer
mabolek Jan 12, 2021
e1e49ab
[TASK] Fixed root directory
mabolek Jan 12, 2021
311b784
[TASK] Fixed root directory
mabolek Jan 12, 2021
cc9e071
[CLEANUP] CS fixes
mabolek Jan 12, 2021
0ea2653
[TASK] Exclude PHP <7.4 for TYPO3 v10.4
mabolek Jan 12, 2021
16a7384
[TASK] Include PHP <7.4 for TYPO3 v10.4
mabolek Jan 12, 2021
9508abe
[TASK] Disable composer v2
mabolek Jan 12, 2021
e609f1d
[TASK] Include testing framework 5 and enable composer v2
mabolek Jan 12, 2021
46beb35
[TASK] Require nimut/testing-framework ^5.0
mabolek Jan 12, 2021
52a2583
[TASK] Fixed test root path
mabolek Jan 12, 2021
c3570ef
[TASK] Fixed test root path
mabolek Jan 12, 2021
d6e6cdb
[TASK] Removed TYPO3 root path
mabolek Jan 12, 2021
d0ada23
[TASK] Updated unit tests
mabolek Jan 12, 2021
149e62f
[TASK] Ignore /var
mabolek Jan 12, 2021
86ee420
[TASK] Remove unused version code
mabolek Jan 12, 2021
09ec5f4
[TASK] Refactored ExtensionManagerConfigurationService into a utility
mabolek Jan 12, 2021
faabfc0
[TASK] Trying to get all tests working
mabolek Jan 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[TASK] Trying to get all tests working
mabolek committed Jan 13, 2021
commit faabfc0e8c8774c1389f1843b5185fb3f0cbe4bf
3 changes: 2 additions & 1 deletion Classes/Controller/EditorController.php
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\FrontendEditing\Service\ExtensionManagerConfigurationService;
use TYPO3\CMS\FrontendEditing\Utility\ConfigurationUtility;

/**
* Class for fetching the proper RTE configuration of a given field
@@ -153,7 +154,7 @@ protected function getExtraPlugins(): array
$this->rteConfiguration['externalPlugins'] = [];
}

if (ExtensionManagerConfigurationService::getSettings()['enablePlaceholders']) {
if (ConfigurationUtility::getExtensionConfiguration()['enablePlaceholders']) {
$this->rteConfiguration['externalPlugins']['confighelper'] = [
'resource' => 'EXT:frontend_editing/Resources/Public/JavaScript/Plugins/confighelper/plugin.js'
];
3 changes: 2 additions & 1 deletion Classes/Hook/FrontendEditingInitializationHook.php
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@
use TYPO3\CMS\FrontendEditing\Service\AccessService;
use TYPO3\CMS\FrontendEditing\Service\ContentEditableWrapperService;
use TYPO3\CMS\FrontendEditing\Service\ExtensionManagerConfigurationService;
use TYPO3\CMS\FrontendEditing\Utility\ConfigurationUtility;
use TYPO3\CMS\Lang\LanguageService as LanguageServiceTypo38;

/**
@@ -270,7 +271,7 @@ public function main(array $params, TypoScriptFrontendController $parentObject)
window.F.setBESessionId(' . GeneralUtility::quoteJSvalue($this->getBeSessionKey()) . ');
window.F.setTranslationLabels(' . json_encode($this->getLocalizedFrontendLabels()) . ');
window.F.setDisableModalOnNewCe(' .
(int)ExtensionManagerConfigurationService::getSettings()['enablePlaceholders'] .
(int)ConfigurationUtility::getExtensionConfiguration()['enablePlaceholders'] .
');
window.FrontendEditingMode = true;
window.TYPO3.settings = {
10 changes: 2 additions & 8 deletions Classes/Service/ContentEditableWrapperService.php
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\FrontendEditing\Utility\ConfigurationUtility;

/**
* A class for adding wrapping for a content element to be editable
@@ -35,11 +36,6 @@ class ContentEditableWrapperService
{
const DEFAULT_WRAPPER_TAG_NAME = 'div';

/**
* @var ExtensionManagerConfigurationService
*/
protected $extensionManagerConfigurationService;

/**
* @var IconFactory
*/
@@ -60,10 +56,8 @@ class ContentEditableWrapperService
*/
public function __construct()
{
$this->extensionManagerConfigurationService =
GeneralUtility::makeInstance(ExtensionManagerConfigurationService::class);
$this->contentEditableWrapperTagName = self::DEFAULT_WRAPPER_TAG_NAME;
$tagName = $this->extensionManagerConfigurationService->getSettings()['contentEditableWrapperTagName'];
$tagName = ConfigurationUtility::getExtensionConfiguration()['contentEditableWrapperTagName'];
if ($tagName) {
$this->contentEditableWrapperTagName = $tagName;
}
3 changes: 2 additions & 1 deletion Classes/ViewHelpers/IsPlaceholderEnabledViewHelper.php
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
*/

use TYPO3\CMS\FrontendEditing\Service\ExtensionManagerConfigurationService;
use TYPO3\CMS\FrontendEditing\Utility\ConfigurationUtility;
use TYPO3\CMS\FrontendEditing\Utility\FrontendEditingUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
@@ -47,6 +48,6 @@ public static function renderStatic(
RenderingContextInterface $renderingContext
) {
return FrontendEditingUtility::isEnabled()
&& ExtensionManagerConfigurationService::getSettings()['enablePlaceholders'];
&& ConfigurationUtility::getExtensionConfiguration()['enablePlaceholders'];
}
}
116 changes: 50 additions & 66 deletions Tests/Unit/EditingPanel/FrontendEditingPanelTest.php
Original file line number Diff line number Diff line change
@@ -20,13 +20,19 @@
use TYPO3\CMS\Backend\FrontendBackendUserAuthentication;
use TYPO3\CMS\Backend\Routing\Route;
use TYPO3\CMS\Backend\Routing\Router;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\TypoScript\TemplateService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Fixtures\PageRepositoryFixture;
use TYPO3\CMS\FrontendEditing\EditingPanel\FrontendEditingPanel;
use TYPO3\CMS\FrontendEditing\Service\AccessService;
use TYPO3\CMS\FrontendEditing\Service\ContentEditableWrapperService;
use TYPO3\CMS\Lang\LanguageService;
use TYPO3\CMS\FrontendEditing\Service\ExtensionManagerConfigurationService;
use TYPO3\CMS\Styleguide\TcaDataGenerator\TableHandler\General;

/**
* Test case for class TYPO3\CMS\FrontendEditing\EditingPanel\FrontendEditingPanel.
@@ -35,7 +41,6 @@
*/
class FrontendEditingPanelTest extends UnitTestCase
{

/**
* @var TemplateService
*/
@@ -51,6 +56,10 @@ class FrontendEditingPanelTest extends UnitTestCase
*/
protected function setUp()
{
$accessServiceMock = $this->createMock(AccessService::class);

$accessServiceMock->method('isEnabled')->willReturn(true);

$this->templateServiceMock =
$this->getMockBuilder(TemplateService::class)
->setMethods(['getFileName', 'linkData'])->getMock();
@@ -72,6 +81,7 @@ protected function setUp()
$this->frontendControllerMock->page = [];
$this->frontendControllerMock->sys_page = $pageRepositoryMock;
$GLOBALS['TSFE'] = $this->frontendControllerMock;

}

/**
@@ -81,36 +91,48 @@ protected function setUp()
*/
public function editIconsDataProvider()
{
$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageService::class);
$languageServiceMock = $this->createMock(LanguageService::class);

$languageServiceMock
->method('sL')
->willReturnArgument(0);

$GLOBALS['LANG'] = $languageServiceMock;

$router = GeneralUtility::makeInstance(Router::class);
$router = new Router();
$router->addRoute('record_edit', new Route('record_edit', []));
GeneralUtility::setSingletonInstance(Router::class, $router);

$iconMock = $this->createMock(Icon::class);

$iconMock->method('render')->willReturn('zzz');

$iconFactoryMock = $this->getMockBuilder(IconFactory::class)
->disableOriginalConstructor()->getMock()
;

$iconFactoryMock
->method('getIcon')
->willReturn($iconMock);

GeneralUtility::addInstance(IconFactory::class, $iconFactoryMock);

$extensionConfigurationMock = $this->createMock(ExtensionConfiguration::class);

$extensionConfigurationMock
->method('get')
->willReturn(['contentEditableWrapperTagName' => 'div']);

GeneralUtility::addInstance(ExtensionConfiguration::class, $extensionConfigurationMock);

$contentEditableWrapperService = new ContentEditableWrapperService();

$content = $this->getUniqueId('content');

return [
'standard case call edit icons for tt_content:bodytext' => [
$contentEditableWrapperService->wrapContentWithDropzone(
'tt_content',
1,
$contentEditableWrapperService->wrapContent(
'tt_content',
1,
[],
$content
)
),
$contentEditableWrapperService->wrapContentWithDropzone(
'tt_content',
1,
$contentEditableWrapperService->wrapContent(
'tt_content',
1,
[],
$content
)
),
'',
'',
'tt_content:bodytext',
['beforeLastTag' => '1', 'allow' => 'edit'],
'tt_content:1',
@@ -123,28 +145,8 @@ public function editIconsDataProvider()
1
],
'another case with fe_users:email' => [
$contentEditableWrapperService->wrapContentWithDropzone(
'fe_users',
12,
$contentEditableWrapperService->wrapContent(
'fe_users',
12,
[],
'<div contenteditable="true" data-table="fe_users" data-field="email" data-uid="12" class="">'
. $content . '</div>'
)
),
$contentEditableWrapperService->wrapContentWithDropzone(
'fe_users',
12,
$contentEditableWrapperService->wrapContent(
'fe_users',
12,
[],
'<div contenteditable="true" data-table="fe_users" data-field="email" data-uid="12" class="">'
. $content . '</div>'
)
),
'',
'',
'fe_users:email',
['beforeLastTag' => '1', 'allow' => 'edit'],
'fe_users:12',
@@ -157,26 +159,8 @@ public function editIconsDataProvider()
1
],
'another case with tt_content:header' => [
$contentEditableWrapperService->wrapContentWithDropzone(
'tt_content',
12,
$contentEditableWrapperService->wrapContent(
'tt_content',
12,
[],
$content
)
),
$contentEditableWrapperService->wrapContentWithDropzone(
'tt_content',
12,
$contentEditableWrapperService->wrapContent(
'tt_content',
12,
[],
$content
)
),
'',
'',
'tt_content:header',
['beforeLastTag' => '1', 'allow' => 'edit'],
'tt_content:12',
89 changes: 73 additions & 16 deletions Tests/Unit/Service/ContentEditableWrapperServiceTest.php
Original file line number Diff line number Diff line change
@@ -17,8 +17,12 @@
*/

use Nimut\TestingFramework\TestCase\UnitTestCase;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\FrontendEditing\Service\ContentEditableWrapperService;
use TYPO3\CMS\FrontendEditing\Service\ExtensionManagerConfigurationService;
use TYPO3\CMS\FrontendEditing\Tests\Unit\Fixtures\ContentEditableFixtures;

/**
@@ -43,31 +47,83 @@ class ContentEditableWrapperServiceTest extends UnitTestCase
*/
protected function setUp()
{
Bootstrap::getInstance()->initializeBackendRouter();
parent::setUp();

$languageServiceMock = $this->createMock(LanguageService::class);

$languageServiceMock
->method('sL')
->willReturnArgument(0);

$GLOBALS['LANG'] = $languageServiceMock;

$extensionConfigurationMock = $this->createMock(ExtensionConfiguration::class);

$extensionConfigurationMock
->method('get')
->willReturn([]);

GeneralUtility::addInstance(ExtensionConfiguration::class, $extensionConfigurationMock);

$this->subject = new ContentEditableWrapperService();
$this->fixtures = new ContentEditableFixtures();
}

protected function tearDown()
{
unset($this->subject);
unset($GLOBALS['TCA']);
}

/**
* Data provider for getWrappedContent()
*
* @return array[]
*/
public function getWrappedContentDataProvider()
{
$content = $this->getUniqueId('content');

return [
'normal content' => [
'',
'tablename',
'fieldname',
123,
$content,
[
'columns' => [
'label' => 'Field label'
]
]
]
];
}

/**
* @dataProvider getWrappedContentDataProvider
* @test
*/
public function getWrappedContent()
public function getWrappedContent(
string $expected,
string $table,
string $field,
int $uid,
string $content,
array $tableTca
)
{
$GLOBALS['TCA'][$table] = $tableTca;

$wrappedContent = $this->subject->wrapContentToBeEditable(
$this->fixtures->getTable(),
$this->fixtures->getField(),
$this->fixtures->getUid(),
$this->fixtures->getContent()
$table,
$field,
$uid,
$content
);

self::assertSame(
$this->assertSame(
$wrappedContent,
$this->fixtures->getWrappedExpectedContent()
$expected
);
}

@@ -83,7 +139,7 @@ public function getWrapContent()
$this->fixtures->getContent()
);

self::assertSame(
$this->assertSame(
$wrapContent,
$this->fixtures->getWrapExpectedContent()
);
@@ -99,7 +155,8 @@ public function getWrapContentWithDropzone()
$this->fixtures->getUid(),
$this->fixtures->getContent()
);
self::assertSame(

$this->assertSame(
$wrapContent,
$this->fixtures->getWrapWithDropzoneExpectedContent()
);
@@ -118,7 +175,7 @@ public function tryWrapContentAndExpectAnException()
$this->fixtures->getContent()
);
} catch (\Exception $exception) {
self::assertEquals($exception->getMessage(), 'Property "table" can not to be empty!');
$this->assertEquals($exception->getMessage(), 'Property "table" can not to be empty!');
return;
}
self::fail('Expected Property "table" missing Exception has not been raised.');
@@ -137,7 +194,7 @@ public function tryWrapContentAndExpectAnExceptionForMissingTable()
$this->fixtures->getContent()
);
} catch (\Exception $exception) {
self::assertEquals($exception->getMessage(), 'Property "table" can not to be empty!');
$this->assertEquals($exception->getMessage(), 'Property "table" can not to be empty!');
return;
}
self::fail('Expected Property "table" missing Exception has not been raised.');
@@ -156,7 +213,7 @@ public function tryWrapContentAndExpectAnExceptionForMissingUid()
$this->fixtures->getContent()
);
} catch (\Exception $exception) {
self::assertEquals($exception->getMessage(), 'Property "uid" can not to be empty!');
$this->assertEquals($exception->getMessage(), 'Property "uid" can not to be empty!');
return;
}
self::fail('Expected Property "uid" missing Exception has not been raised.');
@@ -173,7 +230,7 @@ public function tryWrapContentWithDropzoneAndExpectAnExceptionForMissingTable()
$this->fixtures->getContent()
);
} catch (\Exception $exception) {
self::assertEquals($exception->getMessage(), 'Property "table" can not to be empty!');
$this->assertEquals($exception->getMessage(), 'Property "table" can not to be empty!');
return;
}
self::fail('Expected Property "table" missing Exception has not been raised.');
@@ -191,7 +248,7 @@ public function tryWrapContentWithDropzoneAndExpectAnExceptionForMissingUid()
$this->fixtures->getContent()
);
} catch (\Exception $exception) {
self::assertEquals($exception->getMessage(), 'Property "uid" is not valid!');
$this->assertEquals($exception->getMessage(), 'Property "uid" is not valid!');
return;
}
self::fail('Expected Property "uid" missing Exception has not been raised.');
14 changes: 13 additions & 1 deletion Tests/Unit/Service/ExtensionManagerConfigurationServiceTest.php
Original file line number Diff line number Diff line change
@@ -17,7 +17,11 @@
*/

use Nimut\TestingFramework\TestCase\UnitTestCase;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\FrontendEditing\Service\ExtensionManagerConfigurationService;
use TYPO3\CMS\FrontendEditing\Utility\ConfigurationUtility;
use TYPO3\CMS\Styleguide\TcaDataGenerator\TableHandler\General;

/**
* Test case for class TYPO3\CMS\FrontendEditing\Service\ExtensionManagerConfigurationService.
@@ -31,8 +35,16 @@ class ExtensionManagerConfigurationServiceTest extends UnitTestCase
*/
public function getExtensionManagerSettings()
{
$extensionConfigurationMock = $this->createMock(ExtensionConfiguration::class);

$extensionConfigurationMock
->method('get')
->willReturn([]);

GeneralUtility::addInstance(ExtensionConfiguration::class, $extensionConfigurationMock);

self::assertSame(
ExtensionManagerConfigurationService::getSettings(),
ConfigurationUtility::getExtensionConfiguration(),
[]
);
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@
"cs:php:fix": "php-cs-fixer fix --config=.php_cs -v --using-cache=no",
"ci:ts:lint": "typoscript-lint -c Configuration/TsLint.yml --ansi -n --fail-on-warnings -vvv Configuration/TypoScript/",
"ci:tests:unit": "phpunit -c .Build/vendor/nimut/testing-framework/res/Configuration/UnitTests.xml Tests/Unit",
"ci:tests:functional": "find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo; echo \"Running functional test suite {}\"; .Build/bin/phpunit --verbose --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTestsBootstrap.php {}'",
"ci:tests:functional": "phpunit -c .Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTests.xml Tests/Functional",
"ci:tests": [
"@ci:tests:unit",
"@ci:tests:functional"