Skip to content

Commit

Permalink
[TASK] Assume that the venue address field has the full address
Browse files Browse the repository at this point in the history
Fixes #3922
  • Loading branch information
oliverklee committed Jan 28, 2025
1 parent a3fb0e9 commit e7a828a
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 179 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).

### Changed

- !!! Assume that the venue address field contains the full address (#4085)
- Make the flexforms more compact (#4071)
- Rename and flip `EventStatistics.hasSeatsLimit` (#4047)
- Rename `Event.allowsUnlimitedRegistrations` (#4046)
Expand Down Expand Up @@ -111,6 +112,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).

### Fixed

- Do not double ZIP code, city and country when showing a venue address (#4085)
- Avoid empty localized email subjects in some cases (#3866)
- Only display the event times if there are no time slots (#3838)
- Fix translation for flash message in BE module (#3810)
Expand Down
6 changes: 0 additions & 6 deletions Classes/OldModel/LegacyEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,6 @@ public function getPlaceWithDetails(TemplateHelper $plugin): string
$address = \implode(', ', $addressParts);
$descriptionParts[] = \htmlspecialchars($address, ENT_QUOTES | ENT_HTML5);
}
if ((string)$place['city'] !== '') {
$descriptionParts[] = \htmlspecialchars(
\trim($place['zip'] . ' ' . $place['city']),
ENT_QUOTES | ENT_HTML5
);
}
if ((string)$place['country'] !== '') {
$countryName = $this->getCountryNameFromIsoCode((string)$place['country']);
if ($countryName !== '') {
Expand Down
3 changes: 1 addition & 2 deletions Classes/Service/RegistrationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1022,9 +1022,8 @@ private function formatPlace(Place $place, string $newline): string
$address = preg_replace('/[\\n|\\r]+/', ' ', str_replace('<br />', ' ', strip_tags($place->getAddress())));

$countryName = $place->hasCountry() ? ', ' . $place->getCountry()->getLocalShortName() : '';
$zipAndCity = trim($place->getZip() . ' ' . $place->getCity());

return $place->getTitle() . $newline . $address . $newline . $zipAndCity . $countryName;
return $place->getTitle() . $newline . $address . $newline . $countryName;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions Documentation/Installation/Upgrading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ The following steps are necessary to upgrade from seminars 5.x to 6.x:
#. If you are using the seminars front-end editor, delete the page(s) on which
the FE editor content element is located. (The FE editor has been removed in
seminars 6.x.)
#. Go through the venue records and make sure that the address field contains
the full address (including ZIP code, city and country (if relevant)).
#. Upgrade to seminars 6.x
#. Update the database schema and run all upgrade wizards.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
<tx_seminars_sites>
<uid>1</uid>
<title>The Castle (without country)</title>
<address>on top of the mountain</address>
<address>On top of the mountain
12345 Hamm</address>
<zip>12345</zip>
<city>Hamm</city>
<directions>3 turns left, then always right</directions>
Expand Down
26 changes: 5 additions & 21 deletions Tests/Functional/OldModel/LegacyEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,45 +543,29 @@ public function getPlaceWithDetailsContainsTitlesOfAllRelatedPlaces(): void
/**
* @test
*/
public function getPlaceWithDetailsContainsAddressOfOnePlace(): void
public function getPlaceWithDetailsCanContainAddressOfOneVenue(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/Events/EventsWithPlaces.xml');
$plugin = $this->buildFrontEndAndPlugin();
$subject = TestingLegacyEvent::fromUid(2);

$result = $subject->getPlaceWithDetails($plugin);

self::assertStringContainsString('on top of the mountain', $result);
self::assertStringContainsString("On top of the mountain\n12345 Hamm", $result);
}

/**
* @test
*/
public function getPlaceWithDetailsForNonEmptyZipAndCityContainsZipAndCity(): void
public function getPlaceWithDetailsHasCityOfVenueOnlyOnce(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/Events/EventsWithPlaces.xml');
$plugin = $this->buildFrontEndAndPlugin();
$subject = TestingLegacyEvent::fromUid(2);

$result = $subject->getPlaceWithDetails($plugin);

self::assertStringContainsString('12345', $result);
self::assertStringContainsString('Hamm', $result);
}

/**
* @test
*/
public function getPlaceWithDetailsContainsCountryOfOnePlace(): void
{
$this->importDataSet(__DIR__ . '/Fixtures/Events/EventsWithPlaces.xml');
$this->importStaticData();
$plugin = $this->buildFrontEndAndPlugin();
$subject = TestingLegacyEvent::fromUid(4);

$result = $subject->getPlaceWithDetails($plugin);

self::assertStringContainsString('Schweiz', $result);
self::assertSame(1, substr_count($result, 'Hamm'));
}

/**
Expand Down Expand Up @@ -664,7 +648,7 @@ public function getPlaceWithDetailsRawContainsAddressOfOnePlace(): void

$result = $subject->getPlaceWithDetailsRaw();

self::assertStringContainsString('on top of the mountain', $result);
self::assertStringContainsString('On top of the mountain', $result);
}

/**
Expand Down
23 changes: 0 additions & 23 deletions Tests/Functional/Service/Fixtures/Countries.xml

This file was deleted.

145 changes: 19 additions & 126 deletions Tests/Functional/Service/RegistrationManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use OliverKlee\Oelib\Configuration\ConfigurationRegistry;
use OliverKlee\Oelib\Configuration\DummyConfiguration;
use OliverKlee\Oelib\Mapper\CountryMapper;
use OliverKlee\Oelib\Mapper\MapperRegistry;
use OliverKlee\Oelib\Templating\Template;
use OliverKlee\Oelib\Testing\TestingFramework;
Expand All @@ -27,7 +26,6 @@
use Symfony\Component\Mime\Part\DataPart;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\DateTimeAspect;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
Expand Down Expand Up @@ -207,19 +205,6 @@ private function createRegistration(): LegacyRegistration
return new LegacyRegistration($registrationUid);
}

/**
* Imports static records - but only if they aren't already available as static data.
*/
private function importStaticData(): void
{
if (
GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('static_countries')
->count('*', 'static_countries', []) === 0
) {
$this->importDataSet(__DIR__ . '/Fixtures/Countries.xml');
}
}

/**
* @return non-empty-string
*/
Expand Down Expand Up @@ -1538,14 +1523,14 @@ public function notifyAttendeeForPlaceAddressReplacesMultipleLineFeedAndCarriage
/**
* @test
*/
public function notifyAttendeeForPlaceAddressAndPlainTextMailsSendsCityOfPlace(): void
public function notifyAttendeeForPlaceAddressAndPlainTextMailsSeparatesAddressAndCityWithNewline(): void
{
$this->setUpFakeFrontEnd();
$this->configuration->setAsBoolean('sendConfirmation', true);
$this->createEventWithOrganizer();
$uid = $this->testingFramework->createRecord(
'tx_seminars_sites',
['city' => 'footown']
['address' => 'address', 'city' => 'footown']
);
$this->testingFramework->createRelationAndUpdateCounter(
'tx_seminars_seminars',
Expand All @@ -1560,20 +1545,20 @@ public function notifyAttendeeForPlaceAddressAndPlainTextMailsSendsCityOfPlace()
$registration = $this->createRegistration();
$this->subject->notifyAttendee($registration, $controller);

self::assertStringContainsString('footown', $this->extractTextBodyFromEmail($this->email));
self::assertStringContainsString("address\nfootown", $this->extractTextBodyFromEmail($this->email));
}

/**
* @test
*/
public function notifyAttendeeForPlaceAddressAndPlainTextMailsSendsZipAndCityOfPlace(): void
public function notifyAttendeeHasVenuCityOnlyOnceInPlainTextEmail(): void
{
$this->setUpFakeFrontEnd();
$this->configuration->setAsBoolean('sendConfirmation', true);
$this->createEventWithOrganizer();
$uid = $this->testingFramework->createRecord(
'tx_seminars_sites',
['zip' => '12345', 'city' => 'footown']
['address' => "On the Hill 12\n12345 Footown", 'city' => 'Footown']
);
$this->testingFramework->createRelationAndUpdateCounter(
'tx_seminars_seminars',
Expand All @@ -1588,52 +1573,26 @@ public function notifyAttendeeForPlaceAddressAndPlainTextMailsSendsZipAndCityOfP
$registration = $this->createRegistration();
$this->subject->notifyAttendee($registration, $controller);

self::assertStringContainsString('12345 footown', $this->extractTextBodyFromEmail($this->email));
$textBody = $this->extractTextBodyFromEmail($this->email);
self::assertSame(1, \substr_count($textBody, 'Footown'));
}

/**
* @test
*/
public function notifyAttendeeForPlaceAddressAndPlainTextMailsSendsCountryOfPlace(): void
public function notifyAttendeeHasVenuCityOnlyOnceInHtmlEmail(): void
{
$this->setUpFakeFrontEnd();
$this->configuration->setAsBoolean('sendConfirmation', true);

$this->importStaticData();
$this->createEventWithOrganizer();
$mapper = MapperRegistry::get(CountryMapper::class);
$country = $mapper->find(54);
$uid = $this->testingFramework->createRecord(
'tx_seminars_sites',
['city' => 'footown', 'country' => $country->getIsoAlpha2Code()]
);
$this->testingFramework->createRelationAndUpdateCounter(
'tx_seminars_seminars',
$this->seminarUid,
$uid,
'place'
$this->configuration->setAsString(
'cssFileForAttendeeMail',
'EXT:seminars/Resources/Private/CSS/thankYouMail.css'
);

$controller = new DefaultController();
$controller->init();

$registration = $this->createRegistration();
$this->subject->notifyAttendee($registration, $controller);

self::assertStringContainsString($country->getLocalShortName(), $this->extractTextBodyFromEmail($this->email));
}

/**
* @test
*/
public function notifyAttendeeForPlaceAddressAndPlainTextMailsSeparatesAddressAndCityWithNewline(): void
{
$this->setUpFakeFrontEnd();
$this->configuration->setAsBoolean('sendConfirmation', true);
$this->createEventWithOrganizer();
$uid = $this->testingFramework->createRecord(
'tx_seminars_sites',
['address' => 'address', 'city' => 'footown']
['address' => "On the Hill 12\n12345 Footown", 'city' => 'Footown']
);
$this->testingFramework->createRelationAndUpdateCounter(
'tx_seminars_seminars',
Expand All @@ -1648,13 +1607,14 @@ public function notifyAttendeeForPlaceAddressAndPlainTextMailsSeparatesAddressAn
$registration = $this->createRegistration();
$this->subject->notifyAttendee($registration, $controller);

self::assertStringContainsString("address\nfootown", $this->extractTextBodyFromEmail($this->email));
$htmlBody = $this->extractHtmlBodyFromEmail($this->email);
self::assertSame(1, \substr_count($htmlBody, 'Footown'));
}

/**
* @test
*/
public function notifyAttendeeForPlaceAddressAndHtmlMailsHasAddressAndCity(): void
public function notifyAttendeeForPlaceAddressAndHtmlMailsHasAddressWithNewlinesConvertedToBreaks(): void
{
$this->setUpFakeFrontEnd();
$this->configuration->setAsBoolean('sendConfirmation', true);
Expand All @@ -1664,48 +1624,10 @@ public function notifyAttendeeForPlaceAddressAndHtmlMailsHasAddressAndCity(): vo
);

$this->createEventWithOrganizer();
$address = "On the Hill 12\n12345 Footown";
$uid = $this->testingFramework->createRecord(
'tx_seminars_sites',
['address' => 'address', 'city' => 'footown']
);
$this->testingFramework->createRelationAndUpdateCounter(
'tx_seminars_seminars',
$this->seminarUid,
$uid,
'place'
);

$controller = new DefaultController();
$controller->init();

$registration = $this->createRegistration();
$this->subject->notifyAttendee($registration, $controller);

$emailBody = $this->extractHtmlBodyFromEmail($this->email);

self::assertStringContainsString('address', $emailBody);
self::assertStringContainsString('footown', $emailBody);
}

/**
* @test
*/
public function notifyAttendeeForPlaceAddressWithCountryAndCitySeparatesCountryAndCityWithComma(): void
{
$this->setUpFakeFrontEnd();
$this->configuration->setAsBoolean('sendConfirmation', true);

$this->importStaticData();
$this->createEventWithOrganizer();
$mapper = MapperRegistry::get(CountryMapper::class);
$country = $mapper->find(54);
$uid = $this->testingFramework->createRecord(
'tx_seminars_sites',
[
'address' => 'address',
'city' => 'footown',
'country' => $country->getIsoAlpha2Code(),
]
['address' => $address, 'city' => 'Footown']
);
$this->testingFramework->createRelationAndUpdateCounter(
'tx_seminars_seminars',
Expand All @@ -1720,38 +1642,9 @@ public function notifyAttendeeForPlaceAddressWithCountryAndCitySeparatesCountryA
$registration = $this->createRegistration();
$this->subject->notifyAttendee($registration, $controller);

self::assertStringContainsString(
'footown, ' . $country->getLocalShortName(),
$this->extractTextBodyFromEmail($this->email)
);
}

/**
* @test
*/
public function notifyAttendeeForPlaceAddressWithCityAndNoCountryNotAddsSurplusCommaAfterCity(): void
{
$this->setUpFakeFrontEnd();
$this->configuration->setAsBoolean('sendConfirmation', true);
$this->createEventWithOrganizer();
$uid = $this->testingFramework->createRecord(
'tx_seminars_sites',
['address' => 'address', 'city' => 'footown']
);
$this->testingFramework->createRelationAndUpdateCounter(
'tx_seminars_seminars',
$this->seminarUid,
$uid,
'place'
);

$controller = new DefaultController();
$controller->init();

$registration = $this->createRegistration();
$this->subject->notifyAttendee($registration, $controller);
$htmlBody = $this->extractHtmlBodyFromEmail($this->email);

self::assertStringNotContainsString('footown,', $this->extractTextBodyFromEmail($this->email));
self::assertStringContainsString('On the Hill 12<br/>12345 Footown', $htmlBody);
}

/**
Expand Down

0 comments on commit e7a828a

Please sign in to comment.