Skip to content

Commit

Permalink
Merge pull request #1872 from cultuurnet/III-6310-remove-legacy-langu…
Browse files Browse the repository at this point in the history
…age-from-multilingual-string

III-6310 Remove legacy `Language` from `MultilingualString`
  • Loading branch information
LucWollants authored Nov 8, 2024
2 parents 53577da + 9f14f33 commit a6254d9
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 50 deletions.
5 changes: 2 additions & 3 deletions src/Cdb/CdbXmlPriceInfoParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use CultureFeed_Cdb_Data_Detail;
use CultureFeed_Cdb_Data_Price;
use CultuurNet\UDB3\Language as LegacyLanguage;
use CultuurNet\UDB3\Model\ValueObject\Translation\Language;
use CultuurNet\UDB3\MoneyFactory;
use CultuurNet\UDB3\PriceInfo\BasePrice;
Expand Down Expand Up @@ -101,13 +100,13 @@ function (\CultureFeed_Cdb_Data_Detail $detail) use ($mainLanguage) {
foreach ($translatedTariffs as $tariffName => $tariffPrice) {
if (!isset($tariffs[$tariffIndex])) {
$tariff = new Tariff(
new MultilingualString(new LegacyLanguage($language), (string) $tariffName),
new MultilingualString(new Language($language), (string) $tariffName),
MoneyFactory::create($tariffPrice, new Currency('EUR'))
);
} else {
$tariff = $tariffs[$tariffIndex];
$name = $tariff->getName();
$name = $name->withTranslation(new LegacyLanguage($language), (string) $tariffName);
$name = $name->withTranslation(new Language($language), (string) $tariffName);
$tariff = new Tariff(
$name,
$tariff->getPrice()
Expand Down
4 changes: 2 additions & 2 deletions src/ValueObject/MultilingualString.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace CultuurNet\UDB3\ValueObject;

use CultuurNet\UDB3\Language;
use CultuurNet\UDB3\Model\ValueObject\Translation\Language;
use CultuurNet\UDB3\Model\ValueObject\Translation\TranslatedValueObject;

/**
Expand Down Expand Up @@ -136,7 +136,7 @@ public static function fromUdb3ModelTranslatedValueObject(TranslatedValueObject
}

$string = new MultilingualString(
Language::fromUdb3ModelLanguage($originalLanguage),
$originalLanguage,
$originalValue->toString()
);

Expand Down
7 changes: 3 additions & 4 deletions tests/BackwardsCompatiblePayloadSerializerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Broadway\Serializer\Serializer;
use CultuurNet\UDB3\Event\Events\ContactPointUpdated;
use CultuurNet\UDB3\Language as LegacyLanguage;
use CultuurNet\UDB3\Event\Events\BookingInfoUpdated;
use CultuurNet\UDB3\Event\Events\DescriptionTranslated;
use CultuurNet\UDB3\Event\Events\EventCreated;
Expand Down Expand Up @@ -455,7 +454,7 @@ public function it_replaces_deprecated_url_label_on_booking_info_updated(): void
$bookingInfoUpdated = $this->serializer->deserialize($decoded);

$this->assertEquals(
new MultilingualString(new LegacyLanguage('nl'), 'Reserveer plaatsen'),
new MultilingualString(new Language('nl'), 'Reserveer plaatsen'),
$bookingInfoUpdated->getBookingInfo()->getUrlLabel()
);
}
Expand Down Expand Up @@ -625,7 +624,7 @@ public function it_should_replace_string_names_with_translatable_objects_in_pric
->withExtraTariff(
new Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Senioren'
),
new Money(1000, new Currency('EUR'))
Expand All @@ -634,7 +633,7 @@ public function it_should_replace_string_names_with_translatable_objects_in_pric
->withExtraTariff(
new Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Studenten'
),
new Money(750, new Currency('EUR'))
Expand Down
3 changes: 2 additions & 1 deletion tests/BookingInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use CultuurNet\UDB3\Model\ValueObject\Contact\BookingAvailability;
use CultuurNet\UDB3\Model\ValueObject\Contact\TelephoneNumber;
use CultuurNet\UDB3\Model\ValueObject\Translation\Language;
use CultuurNet\UDB3\Model\ValueObject\Web\EmailAddress;
use CultuurNet\UDB3\Model\ValueObject\Web\TranslatedWebsiteLabel;
use CultuurNet\UDB3\Model\ValueObject\Web\Url;
Expand Down Expand Up @@ -64,7 +65,7 @@ public function it_should_be_creatable_from_a_complete_udb3_model_booking_info()
new WebsiteLink(
new Url('https://publiq.be'),
new TranslatedWebsiteLabel(
new \CultuurNet\UDB3\Model\ValueObject\Translation\Language('nl'),
new Language('nl'),
new WebsiteLabel('publiq')
)
),
Expand Down
2 changes: 1 addition & 1 deletion tests/Event/Commands/UpdateBookingInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use CultuurNet\UDB3\BookingInfo;
use CultuurNet\UDB3\DateTimeFactory;
use CultuurNet\UDB3\Language;
use CultuurNet\UDB3\Model\ValueObject\Translation\Language;
use CultuurNet\UDB3\ValueObject\MultilingualString;
use PHPUnit\Framework\TestCase;

Expand Down
32 changes: 16 additions & 16 deletions tests/Event/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ public function it_handles_update_booking_info_after_udb2_update(): void

$bookingInfo = new BookingInfo(
'www.publiq.be',
new MultilingualString(new LegacyLanguage('nl'), 'publiq'),
new MultilingualString(new Language('nl'), 'publiq'),
'02 123 45 67',
'[email protected]'
);
Expand Down Expand Up @@ -661,7 +661,7 @@ public function it_keeps_existing_uitpas_prices_on_price_info_update(): void
->withUiTPASTariffs([
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Tariff 1'
),
new Money(
Expand Down Expand Up @@ -691,7 +691,7 @@ public function it_keeps_existing_uitpas_prices_on_price_info_update(): void
->withUiTPASTariffs([
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Tariff 1'
),
new Money(
Expand Down Expand Up @@ -729,7 +729,7 @@ public function it_ignores_an_update_of_uitpas_prices(): void
->withUiTPASTariffs([
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Tariff 1'
),
new Money(
Expand All @@ -752,7 +752,7 @@ public function it_ignores_an_update_of_uitpas_prices(): void
))->withUiTPASTariffs([
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Tariff 1'
),
new Money(
Expand All @@ -770,7 +770,7 @@ public function it_ignores_an_update_of_uitpas_prices(): void
->withUiTPASTariffs([
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Tariff 1'
),
new Money(
Expand Down Expand Up @@ -808,7 +808,7 @@ public function it_ignores_an_update_with_equal_prices_without_uitpas(): void
->withUiTPASTariffs([
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Tariff 1'
),
new Money(
Expand Down Expand Up @@ -859,7 +859,7 @@ public function it_ignores_an_update_with_only_different_uitpas_prices(): void
->withUiTPASTariffs([
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Tariff 1'
),
new Money(
Expand All @@ -883,7 +883,7 @@ public function it_ignores_an_update_with_only_different_uitpas_prices(): void
)->withUiTPASTariffs([
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Tariff 1'
),
new Money(
Expand Down Expand Up @@ -951,7 +951,7 @@ public function it_handles_update_price_info_from_udb2_update(): void
->withTariffs([
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Met kinderen'
),
new Money(2000, new Currency('EUR'))
Expand All @@ -965,7 +965,7 @@ public function it_handles_update_price_info_from_udb2_update(): void
->withTariffs([
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Met kinderen'
),
new Money(1499, new Currency('EUR'))
Expand All @@ -980,7 +980,7 @@ public function it_handles_update_price_info_from_udb2_update(): void
->withTariffs([
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Met kinderen'
),
new Money(1499, new Currency('EUR'))
Expand Down Expand Up @@ -1926,7 +1926,7 @@ public function it_ignores_equal_uitpas_prices(): void
->withUiTPASTariffs([
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Tariff 1'
),
new Money(
Expand All @@ -1936,7 +1936,7 @@ public function it_ignores_equal_uitpas_prices(): void
),
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Tariff 2'
),
new Money(
Expand Down Expand Up @@ -2027,7 +2027,7 @@ function (Event $event): void {
->withUiTPASTariffs([
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Tariff 1'
),
new Money(
Expand All @@ -2037,7 +2037,7 @@ function (Event $event): void {
),
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Tariff 2'
),
new Money(
Expand Down
2 changes: 1 addition & 1 deletion tests/Event/Events/BookingInfoUpdatedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use CultuurNet\UDB3\BookingInfo;
use CultuurNet\UDB3\DateTimeFactory;
use CultuurNet\UDB3\Language;
use CultuurNet\UDB3\Model\ValueObject\Translation\Language;
use CultuurNet\UDB3\ValueObject\MultilingualString;
use PHPUnit\Framework\TestCase;

Expand Down
5 changes: 2 additions & 3 deletions tests/Http/Event/ImportEventRequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
use CultuurNet\UDB3\Http\Request\Psr7RequestBuilder;
use CultuurNet\UDB3\Iri\CallableIriGenerator;
use CultuurNet\UDB3\Json;
use CultuurNet\UDB3\Language as LegacyLanguage;
use CultuurNet\UDB3\Media\Image;
use CultuurNet\UDB3\Media\ImageCollection;
use CultuurNet\UDB3\Media\Properties\Description as MediaDescription;
Expand Down Expand Up @@ -672,8 +671,8 @@ public function it_creates_a_new_event_without_id_but_with_all_properties(): voi
$eventId,
new BookingInfo(
'https://www.publiq.be',
(new MultilingualString(new LegacyLanguage('nl'), 'Nederlandse label'))
->withTranslation(new LegacyLanguage('en'), 'English label'),
(new MultilingualString(new Language('nl'), 'Nederlandse label'))
->withTranslation(new Language('en'), 'English label'),
'016 12 34 56',
'[email protected]',
new DateTimeImmutable('2021-05-17T22:00:00+00:00'),
Expand Down
2 changes: 1 addition & 1 deletion tests/Http/Offer/UpdateBookingInfoRequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use CultuurNet\UDB3\Http\Request\Psr7RequestBuilder;
use CultuurNet\UDB3\Http\Response\AssertJsonResponseTrait;
use CultuurNet\UDB3\Http\Response\NoContentResponse;
use CultuurNet\UDB3\Language;
use CultuurNet\UDB3\Model\ValueObject\Translation\Language;
use CultuurNet\UDB3\Offer\Commands\AbstractUpdateBookingInfo;
use CultuurNet\UDB3\Place\Commands\UpdateBookingInfo as PlaceUpdateBookingInfo;
use CultuurNet\UDB3\ValueObject\MultilingualString;
Expand Down
3 changes: 1 addition & 2 deletions tests/Http/Place/ImportPlaceRequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use CultuurNet\UDB3\Http\Response\JsonResponse;
use CultuurNet\UDB3\Iri\CallableIriGenerator;
use CultuurNet\UDB3\Json;
use CultuurNet\UDB3\Language as LegacyLanguage;
use CultuurNet\UDB3\Media\Image;
use CultuurNet\UDB3\Media\ImageCollection;
use CultuurNet\UDB3\Media\Properties\Description;
Expand Down Expand Up @@ -864,7 +863,7 @@ public function it_updates_an_existing_place(): void
new BookingInfo(
'https://www.dehel.be/booking',
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Bestel hier je tickets'
),
'016 10 20 30',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function it_should_return_price_info_if_there_is_any(): void
);
$expected = $expected->withExtraTariff(
new \CultuurNet\UDB3\PriceInfo\Tariff(
new MultilingualString(new \CultuurNet\UDB3\Language('nl'), 'Senioren'),
new MultilingualString(new Language('nl'), 'Senioren'),
new Money(1050, new Currency('EUR'))
)
);
Expand All @@ -326,7 +326,7 @@ public function it_should_return_booking_info_if_there_is_any(): void
$expected = new \CultuurNet\UDB3\BookingInfo(
'https://www.publiq.be',
new MultilingualString(
new \CultuurNet\UDB3\Language('nl'),
new Language('nl'),
'Publiq'
),
'044/444444',
Expand Down
2 changes: 1 addition & 1 deletion tests/Offer/Commands/AbstractUpdateBookingInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use CultuurNet\UDB3\BookingInfo;
use CultuurNet\UDB3\DateTimeFactory;
use CultuurNet\UDB3\Language;
use CultuurNet\UDB3\Model\ValueObject\Translation\Language;
use CultuurNet\UDB3\ValueObject\MultilingualString;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
Expand Down
2 changes: 1 addition & 1 deletion tests/Offer/Events/AbstractBookingInfoEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use CultuurNet\UDB3\BookingInfo;
use CultuurNet\UDB3\DateTimeFactory;
use CultuurNet\UDB3\Language;
use CultuurNet\UDB3\Model\ValueObject\Translation\Language;
use CultuurNet\UDB3\ValueObject\MultilingualString;
use PHPUnit\Framework\TestCase;

Expand Down
6 changes: 3 additions & 3 deletions tests/Offer/OfferTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2013,21 +2013,21 @@ public function it_handles_booking_info_updated_events(): void

$bookingInfo = new BookingInfo(
'www.publiq.be',
new MultilingualString(new LegacyLanguage('nl'), 'publiq'),
new MultilingualString(new Language('nl'), 'publiq'),
'02 123 45 67',
'[email protected]'
);

$sameBookingInfo = new BookingInfo(
'www.publiq.be',
new MultilingualString(new LegacyLanguage('nl'), 'publiq'),
new MultilingualString(new Language('nl'), 'publiq'),
'02 123 45 67',
'[email protected]'
);

$otherBookingInfo = new BookingInfo(
'www.2dotstwice.be',
new MultilingualString(new LegacyLanguage('nl'), '2dotstwice'),
new MultilingualString(new Language('nl'), '2dotstwice'),
'016 12 34 56',
'[email protected]'
);
Expand Down
7 changes: 3 additions & 4 deletions tests/Offer/ReadModel/JSONLD/OfferLDProjectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use CultuurNet\UDB3\Facility;
use CultuurNet\UDB3\Iri\CallableIriGenerator;
use CultuurNet\UDB3\Json;
use CultuurNet\UDB3\Language as LegacyLanguage;
use CultuurNet\UDB3\Media\Image;
use CultuurNet\UDB3\Media\ImageCollection;
use CultuurNet\UDB3\Media\Properties\Description as MediaDescription;
Expand Down Expand Up @@ -763,7 +762,7 @@ public function it_projects_the_updated_price_info(): void
$priceInfo = $priceInfo->withExtraTariff(
new Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'Tarief inwoners'
),
new Money(950, new Currency('EUR'))
Expand All @@ -773,7 +772,7 @@ public function it_projects_the_updated_price_info(): void
$priceInfo = $priceInfo->withExtraUiTPASTariff(
new Tariff(
new MultilingualString(
new LegacyLanguage('nl'),
new Language('nl'),
'UiTPAS tarief'
),
new Money(650, new Currency('EUR'))
Expand Down Expand Up @@ -2468,7 +2467,7 @@ public function it_should_update_bookinginfo(): void

$event = new BookingInfoUpdated($id, new BookingInfo(
'http://www.google.be',
new MultilingualString(new LegacyLanguage('nl'), 'Dit is een booking info event'),
new MultilingualString(new Language('nl'), 'Dit is een booking info event'),
'0471123456',
'[email protected]'
));
Expand Down
Loading

0 comments on commit a6254d9

Please sign in to comment.