mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-22 19:56:11 +01:00
Daniel Siepmann (Codappix)
a07c16b723
Those are now part of the import, or hard coded. Resolves: #11483
127 lines
3.5 KiB
PHP
127 lines
3.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace WerkraumMedia\Events\Tests\Functional\Import\DestinationDataTest;
|
|
|
|
use Codappix\Typo3PhpDatasets\PhpDataSet;
|
|
use GuzzleHttp\Psr7\Response;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use PHPUnit\Framework\Attributes\TestDox;
|
|
|
|
#[TestDox('DestinationData import')]
|
|
class ImportHandlesPricesTest extends AbstractTestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php');
|
|
}
|
|
|
|
#[Test]
|
|
public function addsNewPriceFromPriceInfo(): void
|
|
{
|
|
$this->setUpResponses([
|
|
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithNewPriceInfo.json') ?: ''),
|
|
]);
|
|
|
|
$this->executeCommand();
|
|
|
|
self::assertSame(
|
|
'Preis Info',
|
|
$this->getAllRecords('tx_events_domain_model_event')[0]['price_info'] ?? ''
|
|
);
|
|
|
|
$this->assertEmptyLog();
|
|
}
|
|
|
|
#[Test]
|
|
public function addsNewPriceFromPriceInfoExtra(): void
|
|
{
|
|
$this->setUpResponses([
|
|
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithNewPriceInfoExtra.json') ?: ''),
|
|
]);
|
|
|
|
$this->executeCommand();
|
|
|
|
self::assertSame(
|
|
'Preis Info Extra',
|
|
$this->getAllRecords('tx_events_domain_model_event')[0]['price_info'] ?? ''
|
|
);
|
|
|
|
$this->assertEmptyLog();
|
|
}
|
|
|
|
#[Test]
|
|
public function keepsNoLongerExistingPrice(): void
|
|
{
|
|
(new PhpDataSet())->import(['tx_events_domain_model_event' => [0 => [
|
|
'uid' => 1,
|
|
'pid' => 2,
|
|
'global_id' => 'e_100350503',
|
|
'price_info' => 'Existing price info',
|
|
]]]);
|
|
|
|
$this->setUpResponses([
|
|
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithNoPriceInfo.json') ?: ''),
|
|
]);
|
|
|
|
$this->executeCommand();
|
|
|
|
self::assertSame(
|
|
'Existing price info',
|
|
$this->getAllRecords('tx_events_domain_model_event')[0]['price_info'] ?? ''
|
|
);
|
|
|
|
$this->assertEmptyLog();
|
|
}
|
|
|
|
#[Test]
|
|
public function updatesExistingPriceFromPriceInfo(): void
|
|
{
|
|
(new PhpDataSet())->import(['tx_events_domain_model_event' => [0 => [
|
|
'uid' => 1,
|
|
'pid' => 2,
|
|
'global_id' => 'e_100350503',
|
|
'price_info' => 'Existing price info',
|
|
]]]);
|
|
|
|
$this->setUpResponses([
|
|
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithNewPriceInfo.json') ?: ''),
|
|
]);
|
|
|
|
$this->executeCommand();
|
|
|
|
self::assertSame(
|
|
'Preis Info',
|
|
$this->getAllRecords('tx_events_domain_model_event')[0]['price_info'] ?? ''
|
|
);
|
|
|
|
$this->assertEmptyLog();
|
|
}
|
|
|
|
#[Test]
|
|
public function updatesExistingPriceFromPriceInfoExtra(): void
|
|
{
|
|
(new PhpDataSet())->import(['tx_events_domain_model_event' => [0 => [
|
|
'uid' => 1,
|
|
'pid' => 2,
|
|
'global_id' => 'e_100350503',
|
|
'price_info' => 'Existing price info',
|
|
]]]);
|
|
|
|
$this->setUpResponses([
|
|
new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithNewPriceInfoExtra.json') ?: ''),
|
|
]);
|
|
|
|
$this->executeCommand();
|
|
|
|
self::assertSame(
|
|
'Preis Info Extra',
|
|
$this->getAllRecords('tx_events_domain_model_event')[0]['price_info'] ?? ''
|
|
);
|
|
|
|
$this->assertEmptyLog();
|
|
}
|
|
}
|