Skip to content

Commit

Permalink
Fix fixtures, change response and add mock for userSessionManager
Browse files Browse the repository at this point in the history
  • Loading branch information
chrizzor committed Oct 8, 2024
1 parent 2f9eb29 commit cc91419
Show file tree
Hide file tree
Showing 16 changed files with 138 additions and 129 deletions.
2 changes: 1 addition & 1 deletion Tests/Fixtures/Controller/documents_local.csv
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
,"uid","uid_local","uid_foreign","tablenames","sorting","sorting_foreign","ident"
,2201,2001,1,,,,"docs_colls"
,2202,2002,1,,,,"docs_colls"
,2203,2003,1,,,,"docs_colls"
,2203,2003,1,,,,"docs_colls"
12 changes: 6 additions & 6 deletions Tests/Fixtures/Controller/pages.csv
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"pages",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,"uid","pid","tstamp","crdate","cruser_id","deleted","hidden","starttime","endtime","fe_group","sorting","rowDescription","editlock","sys_language_uid","l10n_parent","l10n_source","t3_origuid","l10n_diffsource","t3ver_oid","t3ver_wsid","t3ver_state","t3ver_stage","perms_userid","perms_groupid","perms_user","perms_group","perms_everybody","title","slug","doktype","TSconfig","is_siteroot","php_tree_stop","url","shortcut","shortcut_mode","subtitle","layout","target","media","lastUpdated","keywords","cache_timeout","cache_tags","newUntil","description","no_search","SYS_LASTCHANGED","abstract","module","extendToSubpages","author","author_email","nav_title","nav_hide","content_from_pid","mount_pid","mount_pid_ol","l18n_cfg","fe_login_mode","backend_layout","backend_layout_next_level","tsconfig_includes","categories"
,1,0,1678381239,1678381239,2,0,1,0,0,0,256,,0,0,0,0,0,,0,0,0,0,2,0,31,27,0,Testseite,,1,,0,0,,0,0,,0,,0,0,,0,,0,,0,0,,,0,,,,0,0,0,0,0,0,,,,0
,2,1,1678700400,1678700400,2,0,1,0,0,,128,,0,0,0,0,0,,0,0,0,0,2,0,31,27,0","dlf","/","254,,0,0,,0,0,,0,,0,0,,0,,0,,0,0,,,0,,,,0,0,0,0,0,0,,,,0
"sys_template",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,2,1,1678700400,1678700400,2,0,1,0,0,,128,,0,0,0,0,0,,0,0,0,0,2,0,31,27,0,"dlf","/",254,,0,0,,0,0,,0,,0,0,,0,,0,,0,0,,,0,,,,0,0,0,0,0,0,,,,0
"sys_template",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,""
,"uid","pid","tstamp","crdate","cruser_id","deleted","hidden","starttime","endtime","sorting","description","t3_origuid","t3ver_oid","t3ver_wsid","t3ver_state","title","root","clear","include_static_file","constants","config","basedOn","includeStaticAfterBasedOn","static_file_mode"
,1,1,1678881727,1678881663,2,0,0,0,0,256,,0,0,0,0,"NEW SITE",1,3,"EXT:fluid_styled_content/Configuration/TypoScript/,EXT:dlf/Configuration/TypoScript/","plugin.tx_dlf.persistence.storagePid = 2",,,0,0
"tt_content",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,"uid","rowDescription","pid","tstamp","crdate","cruser_id","deleted","hidden","starttime","endtime","fe_group","sorting","editlock","sys_language_uid","l18n_parent","l10n_source","t3_origuid","l18n_diffsource","t3ver_oid","t3ver_wsid","t3ver_state","t3ver_stage","t3ver_tstamp","t3ver_move_id","CType","header","header_position","bodytext","bullets_type","uploads_description","uploads_type","assets","image","imagewidth","imageorient","imagecols","imageborder","media","layout","frame_class","cols","space_before_class","space_after_class","records","pages","colPos","subheader","header_link","image_zoom","header_layout","list_type","sectionIndex","linkToTop","file_collections","filelink_size","filelink_sorting","filelink_sorting_direction","target","date","recursive","imageheight","pi_flexform","accessibility_title","accessibility_bypass","accessibility_bypass_text","selected_categories","category_field","table_class","table_caption","table_delimiter","table_enclosure","table_header_position","table_tfoot","categories"
,1,,1,1678700622,1678700488,2,0,0,0,0,,256,0,0,0,0,0,"a:23:{s:5:&quot;CType&quot;;N;s:6:&quot;colPos&quot;;N;s:6:&quot;header&quot;;N;s:13:&quot;header_layout&quot;;N;s:15:&quot;header_position&quot;;N;s:4:&quot;date&quot;;N;s:11:&quot;header_link&quot;;N;s:9:&quot;subheader&quot;;N;s:9:&quot;list_type&quot;;N;s:11:&quot;pi_flexform&quot;;N;s:11:&quot;frame_class&quot;;N;s:18:&quot;space_before_class&quot;;N;s:17:&quot;space_after_class&quot;;N;s:12:&quot;sectionIndex&quot;;N;s:9:&quot;linkToTop&quot;;N;s:16:&quot;sys_language_uid&quot;;N;s:6:&quot;hidden&quot;;N;s:9:&quot;starttime&quot;;N;s:7:&quot;endtime&quot;;N;s:8:&quot;fe_group&quot;;N;s:8:&quot;editlock&quot;;N;s:10:&quot;categories&quot;;N;s:14:&quot;rowDescription&quot;;N;}",0,0,0,0,0,"list",,,,0,0,0,0,0,0,0,2,0,0,0,"default",0,,,,,0,,,0,0,"dlf_collection",1,0,,0,,,,0,0,0,"<![CDATA[
,"uid","rowDescription","pid","tstamp","crdate","cruser_id","deleted","hidden","starttime","endtime","fe_group","sorting","editlock","sys_language_uid","l18n_parent","l10n_source","t3_origuid","l18n_diffsource","t3ver_oid","t3ver_wsid","t3ver_state","t3ver_stage","CType","header","header_position","bodytext","bullets_type","uploads_description","uploads_type","assets","image","imagewidth","imageorient","imagecols","imageborder","media","layout","frame_class","cols","space_before_class","space_after_class","records","pages","colPos","subheader","header_link","image_zoom","header_layout","list_type","sectionIndex","linkToTop","file_collections","filelink_size","filelink_sorting","filelink_sorting_direction","target","date","recursive","imageheight","pi_flexform","accessibility_title","accessibility_bypass","accessibility_bypass_text","selected_categories","category_field","table_class","table_caption","table_delimiter","table_enclosure","table_header_position","table_tfoot","categories"
,1,,1,1678700622,1678700488,2,0,0,0,0,,256,0,0,0,0,0,"a:23:{s:5:&quot;CType&quot;;N;s:6:&quot;colPos&quot;;N;s:6:&quot;header&quot;;N;s:13:&quot;header_layout&quot;;N;s:15:&quot;header_position&quot;;N;s:4:&quot;date&quot;;N;s:11:&quot;header_link&quot;;N;s:9:&quot;subheader&quot;;N;s:9:&quot;list_type&quot;;N;s:11:&quot;pi_flexform&quot;;N;s:11:&quot;frame_class&quot;;N;s:18:&quot;space_before_class&quot;;N;s:17:&quot;space_after_class&quot;;N;s:12:&quot;sectionIndex&quot;;N;s:9:&quot;linkToTop&quot;;N;s:16:&quot;sys_language_uid&quot;;N;s:6:&quot;hidden&quot;;N;s:9:&quot;starttime&quot;;N;s:7:&quot;endtime&quot;;N;s:8:&quot;fe_group&quot;;N;s:8:&quot;editlock&quot;;N;s:10:&quot;categories&quot;;N;s:14:&quot;rowDescription&quot;;N;}",0,0,0,0,list,,,,0,0,0,0,0,0,0,2,0,0,0,default,0,,,,,0,,,0,0,dlf_collection,1,0,,0,,,,0,0,0,"<![CDATA[
<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes"" ?>
<T3FlexForms>
<data>
Expand Down Expand Up @@ -42,7 +42,7 @@
</data>
</T3FlexForms>
]]>",,0,,,,,,124,0,0,0,0
,2,,1,1678700622,1678700488,2,0,0,0,0,,256,0,0,0,0,0,"a:23:{s:5:&quot;CType&quot;;N;s:6:&quot;colPos&quot;;N;s:6:&quot;header&quot;;N;s:13:&quot;header_layout&quot;;N;s:15:&quot;header_position&quot;;N;s:4:&quot;date&quot;;N;s:11:&quot;header_link&quot;;N;s:9:&quot;subheader&quot;;N;s:9:&quot;list_type&quot;;N;s:11:&quot;pi_flexform&quot;;N;s:11:&quot;frame_class&quot;;N;s:18:&quot;space_before_class&quot;;N;s:17:&quot;space_after_class&quot;;N;s:12:&quot;sectionIndex&quot;;N;s:9:&quot;linkToTop&quot;;N;s:16:&quot;sys_language_uid&quot;;N;s:6:&quot;hidden&quot;;N;s:9:&quot;starttime&quot;;N;s:7:&quot;endtime&quot;;N;s:8:&quot;fe_group&quot;;N;s:8:&quot;editlock&quot;;N;s:10:&quot;categories&quot;;N;s:14:&quot;rowDescription&quot;;N;}"",0,0,0,0,0,"list",,,,0,0,0,0,0,0,0,2,0,0,0,"default",0,,,,,0,,,0,0,"dlf_calendar",1,0,,0,,,,0,0,0,"<![CDATA[
,2,,1,1678700622,1678700488,2,0,0,0,0,,256,0,0,0,0,0,"a:23:{s:5:&quot;CType&quot;;N;s:6:&quot;colPos&quot;;N;s:6:&quot;header&quot;;N;s:13:&quot;header_layout&quot;;N;s:15:&quot;header_position&quot;;N;s:4:&quot;date&quot;;N;s:11:&quot;header_link&quot;;N;s:9:&quot;subheader&quot;;N;s:9:&quot;list_type&quot;;N;s:11:&quot;pi_flexform&quot;;N;s:11:&quot;frame_class&quot;;N;s:18:&quot;space_before_class&quot;;N;s:17:&quot;space_after_class&quot;;N;s:12:&quot;sectionIndex&quot;;N;s:9:&quot;linkToTop&quot;;N;s:16:&quot;sys_language_uid&quot;;N;s:6:&quot;hidden&quot;;N;s:9:&quot;starttime&quot;;N;s:7:&quot;endtime&quot;;N;s:8:&quot;fe_group&quot;;N;s:8:&quot;editlock&quot;;N;s:10:&quot;categories&quot;;N;s:14:&quot;rowDescription&quot;;N;}"",0,0,0,0,0,"list",0,0,0,0,list,,,,0,0,0,0,0,0,0,2,0,0,0,default,0,,,,,0,,,0,0,dlf_calendar,1,0,,0,,,,0,0,0,"<![CDATA[
<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes"" ?>
<T3FlexForms>
<data>
Expand Down Expand Up @@ -79,4 +79,4 @@
]]>",,0,,,,,,124,0,0,0,0
"tx_dlf_collections",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
,"uid","pid","tstamp","crdate","cruser_id","deleted","sys_language_uid","l18n_parent","l18n_diffsource","hidden","fe_group","fe_cruser_id","fe_admin_lock","label","index_name","index_search","oai_name","description","thumbnail","priority","documents","owner","status"
,1,0,1678700538,1678700538,2,0,0,0,"a:16:{s:16:&quot;sys_language_uid&quot;;N;s:11:&quot;l18n_parent&quot;;N;s:6:&quot;hidden&quot;;N;s:8:&quot;fe_group&quot;;N;s:5:&quot;label&quot;;N;s:10:&quot;index_name&quot;;N;s:12:&quot;index_search&quot;;N;s:8:&quot;oai_name&quot;;N;s:11:&quot;description&quot;;N;s:8:&quot;priority&quot;;N;s:9:&quot;documents&quot;;N;s:5:&quot;owner&quot;;N;s:12:&quot;fe_cruser_id&quot;;N;s:13:&quot;fe_admin_lock&quot;;N;s:6:&quot;status&quot;;N;s:9:&quot;thumbnail&quot;;N;}"",0,,0,0,"Test Collection","test-collection",,"test-collection",,,3,0,0,0
,1,0,1678700538,1678700538,2,0,0,0,"a:16:{s:16:&quot;sys_language_uid&quot;;N;s:11:&quot;l18n_parent&quot;;N;s:6:&quot;hidden&quot;;N;s:8:&quot;fe_group&quot;;N;s:5:&quot;label&quot;;N;s:10:&quot;index_name&quot;;N;s:12:&quot;index_search&quot;;N;s:8:&quot;oai_name&quot;;N;s:11:&quot;description&quot;;N;s:8:&quot;priority&quot;;N;s:9:&quot;documents&quot;;N;s:5:&quot;owner&quot;;N;s:12:&quot;fe_cruser_id&quot;;N;s:13:&quot;fe_admin_lock&quot;;N;s:6:&quot;status&quot;;N;s:9:&quot;thumbnail&quot;;N;}"",0,,0,0,"Test Collection",0,,0,0,Test Collection,test-collection,,test-collection,,,3,0,0,0
7 changes: 1 addition & 6 deletions Tests/Functional/Controller/AbstractControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Kitodo\Dlf\Domain\Repository\SolrCoreRepository;
use Kitodo\Dlf\Tests\Functional\FunctionalTestCase;
use TYPO3\CMS\Extbase\Mvc\Request;
use TYPO3\CMS\Extbase\Mvc\Response;
use TYPO3\CMS\Extbase\Mvc\View\GenericViewResolver;
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
use TYPO3\CMS\Fluid\View\StandaloneView;
Expand Down Expand Up @@ -63,6 +62,7 @@ protected function setUpSolr($uid, $storagePid, $solrFixtures, $name = '')

$coreModel = new SolrCore();
$coreModel->setIndexName($coreName);
$coreModel->setLabel($coreName);
$this->solrCoreRepository->add($coreModel);
$this->persistenceManager->persistAll();
$this->currentSolrUid = $coreModel->getUid();
Expand Down Expand Up @@ -92,9 +92,4 @@ protected function setUpController($class, $settings, $templateHtml = ''): Abstr
return $controller;
}

protected function getResponse(): Response
{
return $this->objectManager->get(Response::class);
}

}
5 changes: 2 additions & 3 deletions Tests/Functional/Controller/AudioPlayerControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ public function canMainAction()
$templateHtml = 'This template should be returned.';
$controller = $this->setUpController(AudioPlayerController::class, [], $templateHtml);
$request = $this->setUpRequest('main');
$response = $this->getResponse();

$controller->processRequest($request, $response);
$response = $controller->processRequest($request);

$actual = $response->getContent();
$actual = $response->getBody()->getContents();
$expected = 'This template should be returned.';
$this->assertEquals($expected, $actual);
}
Expand Down
17 changes: 7 additions & 10 deletions Tests/Functional/Controller/CalendarControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function setUp(): void
*/
public function canCalendarAction()
{
$settings = ['solrcore' => $this->currentSolrUid];
$settings = ['solrcore' => $this->currentCoreName];
$templateHtml = '<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers">
calendarData:<f:for each="{calendarData}" as="month">
<f:for each="{month.week}" as="week"><f:for each="{week}" as="day"><f:if condition="{day.issues}">
Expand All @@ -49,10 +49,9 @@ public function canCalendarAction()
$controller = $this->setUpController(CalendarController::class, $settings, $templateHtml);
$arguments = ['id' => 2001];
$request = $this->setUpRequest('calendar', $arguments);
$response = $this->getResponse();

$controller->processRequest($request, $response);
$actual = $response->getContent();
$response = $controller->processRequest($request);
$actual = $response->getBody()->getContents();
$expected = '<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers">
calendarData:
xxx[01:issue 1]x[03:issue 2]x|xxxxxxx|xxxxxxx|xxxxxxx|xxxxxxx|xxxxxxx|
Expand All @@ -77,19 +76,18 @@ public function canMainAction()
'page' => '2',
];
$controller = $this->setUpController(CalendarController::class, $settings, '');
$response = $this->getResponse();

$request = $this->setUpRequest('main');
$this->expectException(StopActionException::class);
$controller->processRequest($request, $response);
$response = $controller->processRequest($request);
}

/**
* @test
*/
public function canYearsAction()
{
$settings = ['solrcore' => $this->currentSolrUid];
$settings = ['solrcore' => $this->currentCoreName];
$templateHtml = '<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers">
documentId: {documentId}
allYearDocTitle: {allYearDocTitle}
Expand All @@ -98,10 +96,9 @@ public function canYearsAction()
$controller = $this->setUpController(CalendarController::class, $settings, $templateHtml);
$arguments = ['id' => "2002"];
$request = $this->setUpRequest('years', $arguments);
$response = $this->getResponse();

$controller->processRequest($request, $response);
$actual = $response->getContent();
$response = $controller->processRequest($request);
$actual = $response->getBody()->getContents();
$expected = '<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers">
documentId: 2002
allYearDocTitle: Newspaper for testing purposes
Expand Down
29 changes: 13 additions & 16 deletions Tests/Functional/Controller/CollectionControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,18 @@ public function setUp(): void
public function canListAction()
{
$settings = [
'solrcore' => $this->currentSolrUid,
'solrcore' => $this->currentCoreName,
'collections' => '1',
'dont_show_single' => 'some_value',
'randomize' => ''
];
$templateHtml = '<html><f:for each="{collections}" as="item">{item.collection.indexName}</f:for></html>';
$subject = $this->setUpController(CollectionController::class, $settings, $templateHtml);
$request = $this->setUpRequest('list', ['id' => 1]);
$response = $this->getResponse();

$subject->processRequest($request, $response);
$response = $subject->processRequest($request);

$actual = $response->getContent();
$actual = $response->getBody()->getContents();
$expected = '<html>test-collection</html>';
$this->assertEquals($expected, $actual);
}
Expand All @@ -62,16 +61,15 @@ public function canListAction()
public function canListActionForwardToShow()
{
$settings = [
'solrcore' => $this->currentSolrUid,
'solrcore' => $this->currentCoreName,
'collections' => '1',
'randomize' => ''
];
$subject = $this->setUpController(CollectionController::class, $settings);
$request = $this->setUpRequest('list', ['id' => 1]);
$response = $this->getResponse();

$this->expectException(StopActionException::class);
$subject->processRequest($request, $response);
$response = $subject->processRequest($request);
}

/**
Expand All @@ -80,20 +78,20 @@ public function canListActionForwardToShow()
public function canShowAction()
{
$settings = [
'solrcore' => $this->currentSolrUid,
'solrcore' => $this->currentCoreName,
'collections' => '1',
'dont_show_single' => 'some_value',
'randomize' => ''
'randomize' => '',
'storagePid' => 0
];
$templateHtml = '<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"><f:for each="{documents.solrResults.documents}" as="page" iteration="docIterator">{page.title},</f:for></html>';

$subject = $this->setUpController(CollectionController::class, $settings, $templateHtml);
$request = $this->setUpRequest('show', ['collection' => '1']);
$response = $this->getResponse();

$subject->processRequest($request, $response);
$actual = $response->getContent();
$expected = '<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers">10 Keyboard pieces - Go. S. 658,Beigefügte Quellenbeschreibung,Beigefügtes Inhaltsverzeichnis,</html>';
$response = $subject->processRequest($request);
$actual = $response->getBody()->getContents();
$expected = '<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers">10 Keyboard pieces - Go. S. 658,</html>';
$this->assertEquals($expected, $actual);

}
Expand All @@ -104,16 +102,15 @@ public function canShowAction()
public function canShowSortedAction()
{
$settings = [
'solrcore' => $this->currentSolrUid,
'solrcore' => $this->currentCoreName,
'collections' => '1',
'dont_show_single' => 'some_value',
'randomize' => ''
];
$subject = $this->setUpController(CollectionController::class, $settings);
$request = $this->setUpRequest('showSorted');
$response = $this->getResponse();

$this->expectException(StopActionException::class);
$subject->processRequest($request, $response);
$response = $subject->processRequest($request);
}
}
7 changes: 3 additions & 4 deletions Tests/Functional/Controller/FeedsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function canMainAction()
{
$GLOBALS['LANG'] = LanguageService::create('default');
$settings = [
'solrcore' => $this->currentSolrUid,
'solrcore' => $this->currentCoreName,
'collections' => '1',
'limit' => 1
];
Expand All @@ -49,10 +49,9 @@ public function canMainAction()
'collection' => '1'
];
$request = $this->setUpRequest('main', $arguments);
$response = $this->getResponse();

$controller->processRequest($request, $response);
$actual = $response->getContent();
$response = $controller->processRequest($request);
$actual = $response->getBody()->getContents();
$expected = '<html>
1003 – NEW: 6 Fugues - Go. S. 317
feedMeta:0
Expand Down
8 changes: 3 additions & 5 deletions Tests/Functional/Controller/ListViewControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function canMainAction(): void
]
];
$settings = [
'solrcore' => $this->currentSolrUid,
'solrcore' => $this->currentCoreName,
'storagePid' => 2,
'dont_show_single' => 'some_value',
'randomize' => ''
Expand All @@ -60,16 +60,14 @@ public function canMainAction(): void
</html>';
$request = $this->setUpRequest('main', $arguments);
$controller = $this->setUpController(ListViewController::class, $settings, $templateHtml);
$response = $this->getResponse();
$GLOBALS['TSFE']->fe_user = new FrontendUserAuthentication();

$controller->processRequest($request, $response);
$actual = $response->getContent();
$response = $controller->processRequest($request);
$actual = $response->getBody()->getContents();
$expected = '<html xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers">
uniqueId-length: 13
page: 1
double: 0
widgetPage: 1
lastSearch.query: 10 Keyboard pieces
numResults: 1
</html>';
Expand Down
Loading

0 comments on commit cc91419

Please sign in to comment.