events/Tests/Functional/Import/DestinationDataTest/ImportsTextsTest.php
Daniel Siepmann (Codappix) a07c16b723
Migrate TypoScript import settings
Those are now part of the import, or hard coded.

Resolves: #11483
2024-11-04 14:30:18 +01:00

76 lines
2.5 KiB
PHP

<?php
declare(strict_types=1);
namespace WerkraumMedia\Events\Tests\Functional\Import\DestinationDataTest;
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\TestDox;
#[TestDox('DestinationData import')]
class ImportsTextsTest extends AbstractTestCase
{
protected function tearDown(): void
{
$this->assertEmptyLog();
parent::tearDown();
}
#[Test]
public function importsPlainTextIfConfigured(): void
{
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php');
$requests = &$this->setUpResponses([
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithPlainTextTexts.json') ?: ''),
]);
$tester = $this->executeCommand();
self::assertSame(0, $tester->getStatusCode());
$this->assertPHPDataSet(__DIR__ . '/Assertions/ImportsPlainTextIfConfigured.php');
}
#[Test]
public function importsHtmlTextIfConfiguredAndAvailable(): void
{
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/ImportConfigurationWithHtml.php');
$requests = &$this->setUpResponses([
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithHtmlTextTexts.json') ?: ''),
]);
$tester = $this->executeCommand();
self::assertSame(0, $tester->getStatusCode());
$this->assertPHPDataSet(__DIR__ . '/Assertions/ImportsHtmlTextIfConfigured.php');
}
#[Test]
#[DataProvider('responseWithoutHtml')]
public function importsPlainTextIfHtmlIsConfiguredButUnavailable(
string $responseName
): void {
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/ImportConfigurationWithHtml.php');
$requests = &$this->setUpResponses([
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithoutHtmlTextTextsDueTo' . $responseName . '.json') ?: ''),
]);
$tester = $this->executeCommand();
self::assertSame(0, $tester->getStatusCode());
$this->assertPHPDataSet(__DIR__ . '/Assertions/ImportsPlainTextIfHtmlIsConfiguredButUnavailable.php');
}
public static function responseWithoutHtml(): iterable
{
yield 'Missing type text/html' => [
'responseName' => 'MissingType',
];
yield 'Empty type text/html' => [
'responseName' => 'EmptyType',
];
}
}