mirror of
https://github.com/werkraum-media/form_file_collection.git
synced 2024-12-22 17:56:11 +01:00
Daniel Siepmann
5bb586a19a
Allow to implement custom templates working with files, e.g. providing a thumbnail, link to full file, etc.
139 lines
5.2 KiB
PHP
139 lines
5.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Copyright (C) 2023 Daniel Siepmann <coding@daniel-siepmann.de>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
* 02110-1301, USA.
|
|
*/
|
|
|
|
namespace WerkraumMedia\FormFileCollection\Tests\Functional;
|
|
|
|
use Codappix\Typo3PhpDatasets\TestingFramework;
|
|
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
|
|
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
|
|
|
|
class FormIntegrationTest extends FunctionalTestCase
|
|
{
|
|
use TestingFramework;
|
|
|
|
public function setUp(): void
|
|
{
|
|
$this->coreExtensionsToLoad = [
|
|
'fluid_styled_content',
|
|
'form',
|
|
];
|
|
$this->testExtensionsToLoad = [
|
|
'typo3conf/ext/form_file_collection',
|
|
'typo3conf/ext/form_file_collection/Tests/Fixtures/form_file_collection_example',
|
|
];
|
|
$this->pathsToLinkInTestInstance = [
|
|
'typo3conf/ext/form_file_collection/Tests/Fixtures/Sites' => 'typo3conf/sites',
|
|
'typo3conf/ext/form_file_collection/Tests/Fixtures/Fileadmin/Files' => 'fileadmin/Files',
|
|
];
|
|
|
|
parent::setUp();
|
|
|
|
$this->importPHPDataSet(__DIR__ . '/../Fixtures/BasicDatabase.php');
|
|
$this->setUpFrontendRootPage(1, [
|
|
'setup' => [
|
|
'EXT:form_file_collection/Tests/Fixtures/Rendering.typoscript',
|
|
'EXT:form_file_collection_example/Configuration/TypoScript/Form.typoscript',
|
|
],
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function rendersFileFromSelectedCollection(): void
|
|
{
|
|
$this->importPHPDataSet(__DIR__ . '/../Fixtures/SingleFileDatabase.php');
|
|
|
|
$request = new InternalRequest();
|
|
|
|
$response = $this->executeFrontendRequest($request);
|
|
|
|
$content = $response->getBody()->__toString();
|
|
self::assertStringContainsString('name="tx_form_formframework[test-1][file-collection-1]"', $content);
|
|
|
|
self::assertStringContainsString('FirstResult.png', $content);
|
|
self::assertStringContainsString('value="/Files/FirstResult.png"', $content);
|
|
self::assertStringContainsString('<span>/Files/FirstResult.png</span>', $content);
|
|
|
|
self::assertStringNotContainsString('SecondResult.png', $content);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function providesMultipleFilesFromSelectedCollection(): void
|
|
{
|
|
$this->importPHPDataSet(__DIR__ . '/../Fixtures/TwoFilesDatabase.php');
|
|
|
|
$request = new InternalRequest();
|
|
|
|
$response = $this->executeFrontendRequest($request);
|
|
|
|
$content = $response->getBody()->__toString();
|
|
self::assertStringContainsString('name="tx_form_formframework[test-1][file-collection-1][]"', $content);
|
|
|
|
self::assertStringContainsString('FirstResult.png', $content);
|
|
self::assertStringContainsString('value="/Files/FirstResult.png"', $content);
|
|
self::assertStringContainsString('<span>/Files/FirstResult.png</span>', $content);
|
|
|
|
self::assertStringContainsString('SecondResult.png', $content);
|
|
self::assertStringContainsString('value="/Files/SecondResult.png"', $content);
|
|
self::assertStringContainsString('<span>/Files/SecondResult.png</span>', $content);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function rendersConfiguredLabel(): void
|
|
{
|
|
$this->importPHPDataSet(__DIR__ . '/../Fixtures/SingleFileDatabase.php');
|
|
|
|
$request = new InternalRequest();
|
|
$request = $request->withPageId(2);
|
|
|
|
$response = $this->executeFrontendRequest($request);
|
|
|
|
$content = $response->getBody()->__toString();
|
|
self::assertStringContainsString('name="tx_form_formframework[test-2][file-collection-1][]"', $content);
|
|
|
|
self::assertStringContainsString('value="29b827d0daa29658d8a0d952dfd20f559bbe3bcf"', $content);
|
|
self::assertStringContainsString('<span>image/png</span>', $content);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function rendersCustomTemplateWithAccessToFiles(): void
|
|
{
|
|
$this->importPHPDataSet(__DIR__ . '/../Fixtures/CustomTemplate.php');
|
|
|
|
$request = new InternalRequest();
|
|
$request = $request->withPageId(3);
|
|
|
|
$response = $this->executeFrontendRequest($request);
|
|
|
|
$content = $response->getBody()->__toString();
|
|
self::assertStringContainsString('name="tx_form_formframework[test-3][file-collection-1][]" value="Example title for form"', $content);
|
|
self::assertStringContainsString('<img src="/fileadmin/_processed_/2/9/csm_FirstResult_0f8fa1bb68.png" width="100" height="40" alt="Alternative" title="Example title for form" />', $content);
|
|
}
|
|
}
|