Skip to content

Commit

Permalink
Add tests for ItemsProcFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-stoehr committed Dec 20, 2023
1 parent 0dec881 commit 624240c
Show file tree
Hide file tree
Showing 2 changed files with 287 additions and 0 deletions.
181 changes: 181 additions & 0 deletions Tests/Fixtures/Hooks/pages.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
<?xml version="1.0" encoding="utf-8"?>
<dataset>
<!-- Default siteroot -->
<pages>
<uid>19999</uid>
<pid>0</pid>
<tstamp>1644840191</tstamp>
<crdate>1644840051</crdate>
<cruser_id>1</cruser_id>
<deleted>0</deleted>
<hidden>0</hidden>
<starttime>0</starttime>
<endtime>0</endtime>
<fe_group></fe_group>
<sorting>764</sorting>
<rowDescription></rowDescription>
<editlock>0</editlock>
<sys_language_uid>0</sys_language_uid>
<l10n_parent>0</l10n_parent>
<l10n_source>0</l10n_source>
<l10n_state></l10n_state>
<t3_origuid>0</t3_origuid>
<l10n_diffsource>a:47:{s:7:&quot;doktype&quot;;N;s:5:&quot;title&quot;;N;s:4:&quot;slug&quot;;N;s:9:&quot;nav_title&quot;;N;s:8:&quot;subtitle&quot;;N;s:9:&quot;seo_title&quot;;N;s:8:&quot;no_index&quot;;N;s:9:&quot;no_follow&quot;;N;s:14:&quot;canonical_link&quot;;N;s:8:&quot;og_title&quot;;N;s:14:&quot;og_description&quot;;N;s:8:&quot;og_image&quot;;N;s:13:&quot;twitter_title&quot;;N;s:19:&quot;twitter_description&quot;;N;s:13:&quot;twitter_image&quot;;N;s:8:&quot;abstract&quot;;N;s:8:&quot;keywords&quot;;N;s:11:&quot;description&quot;;N;s:6:&quot;author&quot;;N;s:12:&quot;author_email&quot;;N;s:11:&quot;lastUpdated&quot;;N;s:6:&quot;layout&quot;;N;s:8:&quot;newUntil&quot;;N;s:14:&quot;backend_layout&quot;;N;s:25:&quot;backend_layout_next_level&quot;;N;s:16:&quot;content_from_pid&quot;;N;s:6:&quot;target&quot;;N;s:13:&quot;cache_timeout&quot;;N;s:10:&quot;cache_tags&quot;;N;s:11:&quot;is_siteroot&quot;;N;s:9:&quot;no_search&quot;;N;s:13:&quot;php_tree_stop&quot;;N;s:6:&quot;module&quot;;N;s:5:&quot;media&quot;;N;s:17:&quot;tsconfig_includes&quot;;N;s:8:&quot;TSconfig&quot;;N;s:8:&quot;l18n_cfg&quot;;N;s:6:&quot;hidden&quot;;N;s:8:&quot;nav_hide&quot;;N;s:9:&quot;starttime&quot;;N;s:7:&quot;endtime&quot;;N;s:16:&quot;extendToSubpages&quot;;N;s:8:&quot;fe_group&quot;;N;s:13:&quot;fe_login_mode&quot;;N;s:8:&quot;editlock&quot;;N;s:10:&quot;categories&quot;;N;s:14:&quot;rowDescription&quot;;N;}</l10n_diffsource>
<t3ver_oid>0</t3ver_oid>
<t3ver_wsid>0</t3ver_wsid>
<t3ver_state>0</t3ver_state>
<t3ver_stage>0</t3ver_stage>
<t3ver_count>0</t3ver_count>
<t3ver_tstamp>0</t3ver_tstamp>
<t3ver_move_id>0</t3ver_move_id>
<perms_userid>1</perms_userid>
<perms_groupid>0</perms_groupid>
<perms_user>31</perms_user>
<perms_group>27</perms_group>
<perms_everybody>0</perms_everybody>
<title>DLF Testing Site</title>
<slug>/</slug>
<doktype>254</doktype>
<TSconfig></TSconfig>
<is_siteroot>1</is_siteroot>
<php_tree_stop>0</php_tree_stop>
<url></url>
<shortcut>0</shortcut>
<shortcut_mode>0</shortcut_mode>
<subtitle></subtitle>
<layout>0</layout>
<target></target>
<media>0</media>
<lastUpdated>0</lastUpdated>
<keywords></keywords>
<cache_timeout>0</cache_timeout>
<cache_tags></cache_tags>
<newUntil>0</newUntil>
<description></description>
<no_search>0</no_search>
<SYS_LASTCHANGED>1644840191</SYS_LASTCHANGED>
<abstract></abstract>
<module></module>
<extendToSubpages>0</extendToSubpages>
<author></author>
<author_email></author_email>
<nav_title></nav_title>
<nav_hide>0</nav_hide>
<content_from_pid>0</content_from_pid>
<mount_pid>0</mount_pid>
<mount_pid_ol>0</mount_pid_ol>
<l18n_cfg>0</l18n_cfg>
<fe_login_mode>0</fe_login_mode>
<backend_layout></backend_layout>
<backend_layout_next_level></backend_layout_next_level>
<tsconfig_includes></tsconfig_includes>
<legacy_overlay_uid>0</legacy_overlay_uid>
<categories>0</categories>
</pages>

<!-- Default data folder -->
<pages>
<uid>20000</uid>
<pid>19999</pid>
<tstamp>1644840191</tstamp>
<crdate>1644840051</crdate>
<cruser_id>1</cruser_id>
<deleted>0</deleted>
<hidden>0</hidden>
<starttime>0</starttime>
<endtime>0</endtime>
<fe_group></fe_group>
<sorting>764</sorting>
<rowDescription></rowDescription>
<editlock>0</editlock>
<sys_language_uid>0</sys_language_uid>
<l10n_parent>0</l10n_parent>
<l10n_source>0</l10n_source>
<l10n_state></l10n_state>
<t3_origuid>0</t3_origuid>
<l10n_diffsource>a:47:{s:7:&quot;doktype&quot;;N;s:5:&quot;title&quot;;N;s:4:&quot;slug&quot;;N;s:9:&quot;nav_title&quot;;N;s:8:&quot;subtitle&quot;;N;s:9:&quot;seo_title&quot;;N;s:8:&quot;no_index&quot;;N;s:9:&quot;no_follow&quot;;N;s:14:&quot;canonical_link&quot;;N;s:8:&quot;og_title&quot;;N;s:14:&quot;og_description&quot;;N;s:8:&quot;og_image&quot;;N;s:13:&quot;twitter_title&quot;;N;s:19:&quot;twitter_description&quot;;N;s:13:&quot;twitter_image&quot;;N;s:8:&quot;abstract&quot;;N;s:8:&quot;keywords&quot;;N;s:11:&quot;description&quot;;N;s:6:&quot;author&quot;;N;s:12:&quot;author_email&quot;;N;s:11:&quot;lastUpdated&quot;;N;s:6:&quot;layout&quot;;N;s:8:&quot;newUntil&quot;;N;s:14:&quot;backend_layout&quot;;N;s:25:&quot;backend_layout_next_level&quot;;N;s:16:&quot;content_from_pid&quot;;N;s:6:&quot;target&quot;;N;s:13:&quot;cache_timeout&quot;;N;s:10:&quot;cache_tags&quot;;N;s:11:&quot;is_siteroot&quot;;N;s:9:&quot;no_search&quot;;N;s:13:&quot;php_tree_stop&quot;;N;s:6:&quot;module&quot;;N;s:5:&quot;media&quot;;N;s:17:&quot;tsconfig_includes&quot;;N;s:8:&quot;TSconfig&quot;;N;s:8:&quot;l18n_cfg&quot;;N;s:6:&quot;hidden&quot;;N;s:8:&quot;nav_hide&quot;;N;s:9:&quot;starttime&quot;;N;s:7:&quot;endtime&quot;;N;s:16:&quot;extendToSubpages&quot;;N;s:8:&quot;fe_group&quot;;N;s:13:&quot;fe_login_mode&quot;;N;s:8:&quot;editlock&quot;;N;s:10:&quot;categories&quot;;N;s:14:&quot;rowDescription&quot;;N;}</l10n_diffsource>
<t3ver_oid>0</t3ver_oid>
<t3ver_wsid>0</t3ver_wsid>
<t3ver_state>0</t3ver_state>
<t3ver_stage>0</t3ver_stage>
<t3ver_count>0</t3ver_count>
<t3ver_tstamp>0</t3ver_tstamp>
<t3ver_move_id>0</t3ver_move_id>
<perms_userid>1</perms_userid>
<perms_groupid>0</perms_groupid>
<perms_user>31</perms_user>
<perms_group>27</perms_group>
<perms_everybody>0</perms_everybody>
<title>Data</title>
<slug>/data</slug>
<doktype>254</doktype>
<TSconfig></TSconfig>
<is_siteroot>0</is_siteroot>
<php_tree_stop>0</php_tree_stop>
<url></url>
<shortcut>0</shortcut>
<shortcut_mode>0</shortcut_mode>
<subtitle></subtitle>
<layout>0</layout>
<target></target>
<media>0</media>
<lastUpdated>0</lastUpdated>
<keywords></keywords>
<cache_timeout>0</cache_timeout>
<cache_tags></cache_tags>
<newUntil>0</newUntil>
<description></description>
<no_search>0</no_search>
<SYS_LASTCHANGED>1644840191</SYS_LASTCHANGED>
<abstract></abstract>
<module></module>
<extendToSubpages>0</extendToSubpages>
<author></author>
<author_email></author_email>
<nav_title></nav_title>
<nav_hide>0</nav_hide>
<content_from_pid>0</content_from_pid>
<mount_pid>0</mount_pid>
<mount_pid_ol>0</mount_pid_ol>
<l18n_cfg>0</l18n_cfg>
<fe_login_mode>0</fe_login_mode>
<backend_layout></backend_layout>
<backend_layout_next_level></backend_layout_next_level>
<tsconfig_includes></tsconfig_includes>
<legacy_overlay_uid>0</legacy_overlay_uid>
<categories>0</categories>
</pages>

<sys_template>
<uid>21001</uid>
<pid>19999</pid>
<tstamp>1644856416</tstamp>
<crdate>1644856388</crdate>
<cruser_id>1</cruser_id>
<deleted>0</deleted>
<hidden>0</hidden>
<starttime>0</starttime>
<endtime>0</endtime>
<sorting>256</sorting>
<description></description>
<t3_origuid>0</t3_origuid>
<t3ver_oid>0</t3ver_oid>
<t3ver_wsid>0</t3ver_wsid>
<t3ver_state>0</t3ver_state>
<t3ver_stage>0</t3ver_stage>
<t3ver_count>0</t3ver_count>
<t3ver_tstamp>0</t3ver_tstamp>
<t3ver_move_id>0</t3ver_move_id>
<title>OAI-PMH Template</title>
<sitetitle></sitetitle>
<root>1</root>
<clear>3</clear>
<include_static_file>EXT:fluid_styled_content/Configuration/TypoScript/,EXT:dlf/Configuration/TypoScript/Plugins/OaiPmh/,EXT:dlf/Configuration/TypoScript/</include_static_file>
<constants>plugin.tx_dlf.persistence.storagePid = 20000</constants>
<config></config>
<basedOn></basedOn>
<includeStaticAfterBasedOn>0</includeStaticAfterBasedOn>
<static_file_mode>0</static_file_mode>
</sys_template>

</dataset>
106 changes: 106 additions & 0 deletions Tests/Functional/Hooks/ItemsProcFuncTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php

/**
* (c) Kitodo. Key to digital objects e.V. <[email protected]>
*
* 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);
}
}

0 comments on commit 624240c

Please sign in to comment.