From 624240c16c83c67967814c5114644025d10149d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6hr?= Date: Fri, 19 May 2023 12:12:43 +0200 Subject: [PATCH] Add tests for ItemsProcFunc --- Tests/Fixtures/Hooks/pages.xml | 181 +++++++++++++++++++ Tests/Functional/Hooks/ItemsProcFuncTest.php | 106 +++++++++++ 2 files changed, 287 insertions(+) create mode 100644 Tests/Fixtures/Hooks/pages.xml create mode 100644 Tests/Functional/Hooks/ItemsProcFuncTest.php diff --git a/Tests/Fixtures/Hooks/pages.xml b/Tests/Fixtures/Hooks/pages.xml new file mode 100644 index 000000000..8feddf088 --- /dev/null +++ b/Tests/Fixtures/Hooks/pages.xml @@ -0,0 +1,181 @@ + + + + + 19999 + 0 + 1644840191 + 1644840051 + 1 + 0 + 0 + 0 + 0 + + 764 + + 0 + 0 + 0 + 0 + + 0 + a:47:{s:7:"doktype";N;s:5:"title";N;s:4:"slug";N;s:9:"nav_title";N;s:8:"subtitle";N;s:9:"seo_title";N;s:8:"no_index";N;s:9:"no_follow";N;s:14:"canonical_link";N;s:8:"og_title";N;s:14:"og_description";N;s:8:"og_image";N;s:13:"twitter_title";N;s:19:"twitter_description";N;s:13:"twitter_image";N;s:8:"abstract";N;s:8:"keywords";N;s:11:"description";N;s:6:"author";N;s:12:"author_email";N;s:11:"lastUpdated";N;s:6:"layout";N;s:8:"newUntil";N;s:14:"backend_layout";N;s:25:"backend_layout_next_level";N;s:16:"content_from_pid";N;s:6:"target";N;s:13:"cache_timeout";N;s:10:"cache_tags";N;s:11:"is_siteroot";N;s:9:"no_search";N;s:13:"php_tree_stop";N;s:6:"module";N;s:5:"media";N;s:17:"tsconfig_includes";N;s:8:"TSconfig";N;s:8:"l18n_cfg";N;s:6:"hidden";N;s:8:"nav_hide";N;s:9:"starttime";N;s:7:"endtime";N;s:16:"extendToSubpages";N;s:8:"fe_group";N;s:13:"fe_login_mode";N;s:8:"editlock";N;s:10:"categories";N;s:14:"rowDescription";N;} + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 31 + 27 + 0 + DLF Testing Site + / + 254 + + 1 + 0 + + 0 + 0 + + 0 + + 0 + 0 + + 0 + + 0 + + 0 + 1644840191 + + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + + + + + 20000 + 19999 + 1644840191 + 1644840051 + 1 + 0 + 0 + 0 + 0 + + 764 + + 0 + 0 + 0 + 0 + + 0 + a:47:{s:7:"doktype";N;s:5:"title";N;s:4:"slug";N;s:9:"nav_title";N;s:8:"subtitle";N;s:9:"seo_title";N;s:8:"no_index";N;s:9:"no_follow";N;s:14:"canonical_link";N;s:8:"og_title";N;s:14:"og_description";N;s:8:"og_image";N;s:13:"twitter_title";N;s:19:"twitter_description";N;s:13:"twitter_image";N;s:8:"abstract";N;s:8:"keywords";N;s:11:"description";N;s:6:"author";N;s:12:"author_email";N;s:11:"lastUpdated";N;s:6:"layout";N;s:8:"newUntil";N;s:14:"backend_layout";N;s:25:"backend_layout_next_level";N;s:16:"content_from_pid";N;s:6:"target";N;s:13:"cache_timeout";N;s:10:"cache_tags";N;s:11:"is_siteroot";N;s:9:"no_search";N;s:13:"php_tree_stop";N;s:6:"module";N;s:5:"media";N;s:17:"tsconfig_includes";N;s:8:"TSconfig";N;s:8:"l18n_cfg";N;s:6:"hidden";N;s:8:"nav_hide";N;s:9:"starttime";N;s:7:"endtime";N;s:16:"extendToSubpages";N;s:8:"fe_group";N;s:13:"fe_login_mode";N;s:8:"editlock";N;s:10:"categories";N;s:14:"rowDescription";N;} + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 31 + 27 + 0 + Data + /data + 254 + + 0 + 0 + + 0 + 0 + + 0 + + 0 + 0 + + 0 + + 0 + + 0 + 1644840191 + + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + + + + 21001 + 19999 + 1644856416 + 1644856388 + 1 + 0 + 0 + 0 + 0 + 256 + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + OAI-PMH Template + + 1 + 3 + EXT:fluid_styled_content/Configuration/TypoScript/,EXT:dlf/Configuration/TypoScript/Plugins/OaiPmh/,EXT:dlf/Configuration/TypoScript/ + plugin.tx_dlf.persistence.storagePid = 20000 + + + 0 + 0 + + + diff --git a/Tests/Functional/Hooks/ItemsProcFuncTest.php b/Tests/Functional/Hooks/ItemsProcFuncTest.php new file mode 100644 index 000000000..9b0928eeb --- /dev/null +++ b/Tests/Functional/Hooks/ItemsProcFuncTest.php @@ -0,0 +1,106 @@ + + * + * This file is part of the Kitodo and TYPO3 projects. + * + * @license GNU General Public License version 3 or later. + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + */ + +namespace Kitodo\Dlf\Tests\Functional\Hooks; + +use Kitodo\Dlf\Domain\Repository\DocumentRepository; +use Kitodo\Dlf\Hooks\ItemsProcFunc; +use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; +use TYPO3\CMS\Core\Localization\LanguageService; +use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; + +class ItemsProcFuncTest extends FunctionalTestCase +{ + public function setUp(): void + { + parent::setUp(); + + $this->importDataSet(__DIR__ . '/../../Fixtures/Hooks/pages.xml'); + $this->importDataSet(__DIR__ . '/../../Fixtures/Hooks/metadata.xml'); + $this->persistenceManager = $this->objectManager->get(PersistenceManager::class); + $this->documentRepository = $this->initializeRepository(DocumentRepository::class, 0); + + } + + /** + * @test + */ + public function canToollist() + { + $GLOBALS['LANG'] = LanguageService::create('default'); + $itemsProcFunc = new ItemsProcFunc(); + + $params = []; + $itemsProcFunc->toolList($params); + $expected = [ + 'items' => [ + ['Fulltext', 'tx_dlf_fulltexttool'], + ['IIIF Annotations', 'tx_dlf_annotationtool'], + ['Fulltext Download', 'tx_dlf_fulltextdownloadtool'], + ['Image Download', 'tx_dlf_imagedownloadtool'], + ['Image Manipulation', 'tx_dlf_imagemanipulationtool'], + ['PDF Download', 'tx_dlf_pdfdownloadtool'], + ['Search in Document', 'tx_dlf_searchindocumenttool'] + ] + ]; + $this->assertEquals($expected, $params); + } + + /** + * @test + */ + public function canExtendedSearchList() + { + $itemsProcFunc = new ItemsProcFunc(); + + $params = [ + 'flexParentDatabaseRow' => [ + 'pid' => 19999 + ] + ]; + $itemsProcFunc->extendedSearchList($params); + $expected = [ + 'items' => [ + ['Sammlungen', 'collection'], + ['Titel', 'title'] + ], + 'flexParentDatabaseRow' => [ + 'pid' => 19999 + ] + ]; + $this->assertEquals($expected, $params); + } + + /** + * @test + */ + public function canGetFacetList() + { + $itemsProcFunc = new ItemsProcFunc(); + + $params = [ + 'flexParentDatabaseRow' => [ + 'pid' => 19999 + ] + ]; + $itemsProcFunc->getFacetsList($params); + $expected = [ + 'items' => [ + ['Sammlungen', 'collection'] + ], + 'flexParentDatabaseRow' => [ + 'pid' => 19999 + ] + ]; + $this->assertEquals($expected, $params); + } +}