Skip to content

Commit

Permalink
Update tests to use BookingAvailability
Browse files Browse the repository at this point in the history
  • Loading branch information
LucWollants committed Nov 25, 2024
1 parent 8e1366b commit 155a535
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 55 deletions.
17 changes: 7 additions & 10 deletions tests/BackwardsCompatiblePayloadSerializerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,7 @@ public function it_replaces_event_id_with_item_id_on_event_booking_info_updated(
/* @var BookingInfoUpdated $bookingInfoUpdated */
$bookingInfoUpdated = $this->serializer->deserialize($decoded);

$this->assertNull($bookingInfoUpdated->getBookingInfo()->getAvailabilityStarts());
$this->assertNull($bookingInfoUpdated->getBookingInfo()->getAvailabilityEnds());
$this->assertNull($bookingInfoUpdated->getBookingInfo()->getAvailability());

$this->assertEventIdReplacedWithItemId($sampleFile);
}
Expand All @@ -422,12 +421,12 @@ public function it_replaces_deprecated_availability_date_formats_on_booking_info

$this->assertEquals(
DateTimeFactory::fromAtom('2018-02-20T15:11:26+00:00'),
$bookingInfoUpdated->getBookingInfo()->getAvailabilityStarts()
$bookingInfoUpdated->getBookingInfo()->getAvailability()->getFrom()
);

$this->assertEquals(
DateTimeFactory::fromAtom('2018-04-30T14:11:26+00:00'),
$bookingInfoUpdated->getBookingInfo()->getAvailabilityEnds()
$bookingInfoUpdated->getBookingInfo()->getAvailability()->getTo()
);
}

Expand All @@ -444,8 +443,7 @@ public function it_replaces_invalid_availability_date_formats_on_booking_info_up
/* @var BookingInfoUpdated $bookingInfoUpdated */
$bookingInfoUpdated = $this->serializer->deserialize($decoded);

$this->assertNull($bookingInfoUpdated->getBookingInfo()->getAvailabilityStarts());
$this->assertNull($bookingInfoUpdated->getBookingInfo()->getAvailabilityEnds());
$this->assertNull($bookingInfoUpdated->getBookingInfo()->getAvailability());
}

/**
Expand Down Expand Up @@ -482,12 +480,12 @@ public function it_keeps_valid_availability_date_formats_on_booking_info_updated

$this->assertEquals(
DateTimeFactory::fromAtom('2018-02-20T15:11:26+01:00'),
$bookingInfoUpdated->getBookingInfo()->getAvailabilityStarts()
$bookingInfoUpdated->getBookingInfo()->getAvailability()->getFrom()
);

$this->assertEquals(
DateTimeFactory::fromAtom('2018-04-30T14:11:26+01:00'),
$bookingInfoUpdated->getBookingInfo()->getAvailabilityEnds()
$bookingInfoUpdated->getBookingInfo()->getAvailability()->getTo()
);
}

Expand All @@ -504,8 +502,7 @@ public function it_replaces_missing_availability_dates_with_null_on_booking_info
/* @var BookingInfoUpdated $bookingInfoUpdated */
$bookingInfoUpdated = $this->serializer->deserialize($decoded);

$this->assertNull($bookingInfoUpdated->getBookingInfo()->getAvailabilityStarts());
$this->assertNull($bookingInfoUpdated->getBookingInfo()->getAvailabilityEnds());
$this->assertNull($bookingInfoUpdated->getBookingInfo()->getAvailability());
}

/**
Expand Down
23 changes: 11 additions & 12 deletions tests/BookingInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ public function it_should_be_creatable_from_a_complete_udb3_model_booking_info()
),
new TelephoneNumber('044/444444'),
new EmailAddress('[email protected]'),
DateTimeFactory::fromAtom('2018-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2018-01-10T00:00:00+01:00')
BookingAvailability::fromTo(
DateTimeFactory::fromAtom('2018-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2018-01-10T00:00:00+01:00')
)
);

$actual = BookingInfo::fromUdb3ModelBookingInfo($udb3ModelBookingInfo);
Expand Down Expand Up @@ -125,7 +127,6 @@ public function it_should_return_null_for_empty_properties(): void
null,
null,
null,
null,
null
);

Expand All @@ -137,24 +138,21 @@ public function it_should_return_null_for_empty_properties(): void
$this->assertNull($bookingInfo->getWebsite());
$this->assertNull($bookingInfo->getPhone());
$this->assertNull($bookingInfo->getEmail());
$this->assertNull($bookingInfo->getAvailabilityStarts());
$this->assertNull($bookingInfo->getAvailabilityEnds());
$this->assertNull($bookingInfo->getAvailability());
$this->assertEquals($expectedSerialized, $bookingInfo->serialize());
$this->assertEquals($expectedJson, $bookingInfo->toJsonLd());

$this->assertNull($bookingInfoWithEmptyString->getWebsite());
$this->assertNull($bookingInfoWithEmptyString->getPhone());
$this->assertNull($bookingInfoWithEmptyString->getEmail());
$this->assertNull($bookingInfoWithEmptyString->getAvailabilityStarts());
$this->assertNull($bookingInfoWithEmptyString->getAvailabilityEnds());
$this->assertNull($bookingInfoWithEmptyString->getAvailability());
$this->assertEquals($expectedSerialized, $bookingInfoWithEmptyString->serialize());
$this->assertEquals($expectedJson, $bookingInfoWithEmptyString->toJsonLd());

$this->assertNull($deserialized->getWebsite());
$this->assertNull($deserialized->getPhone());
$this->assertNull($deserialized->getEmail());
$this->assertNull($deserialized->getAvailabilityStarts());
$this->assertNull($deserialized->getAvailabilityEnds());
$this->assertNull($deserialized->getAvailability());
$this->assertEquals($expectedSerialized, $deserialized->serialize());
$this->assertEquals($expectedJson, $deserialized->toJsonLd());
}
Expand All @@ -171,7 +169,6 @@ public function it_can_serialize_and_deserialize_partial_booking_info(): void
null,
$phone,
$email,
null,
null
);

Expand Down Expand Up @@ -215,8 +212,10 @@ public function it_ignores_obsolete_properties_when_deserializing(): void
),
new TelephoneNumber('044/444444'),
new EmailAddress('[email protected]'),
DateTimeFactory::fromAtom('2018-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2018-01-14T23:59:59+01:00')
BookingAvailability::fromTo(
DateTimeFactory::fromAtom('2018-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2018-01-14T23:59:59+01:00')
)
);

$actual = BookingInfo::deserialize($data);
Expand Down
13 changes: 9 additions & 4 deletions tests/Event/Commands/UpdateBookingInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use CultuurNet\UDB3\BookingInfo;
use CultuurNet\UDB3\DateTimeFactory;
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;
Expand Down Expand Up @@ -33,8 +34,10 @@ public function setUp(): void
),
new TelephoneNumber('0123456789'),
new EmailAddress('[email protected]'),
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
BookingAvailability::fromTo(
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
)
)
);
}
Expand All @@ -56,8 +59,10 @@ public function it_is_possible_to_instantiate_the_command_with_parameters(): voi
),
new TelephoneNumber('0123456789'),
new EmailAddress('[email protected]'),
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
BookingAvailability::fromTo(
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
)
)
);

Expand Down
7 changes: 5 additions & 2 deletions tests/Event/Events/BookingInfoUpdatedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use CultuurNet\UDB3\BookingInfo;
use CultuurNet\UDB3\DateTimeFactory;
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;
Expand Down Expand Up @@ -72,8 +73,10 @@ public function serializationDataProvider(): array
),
new TelephoneNumber('0123456789'),
new EmailAddress('[email protected]'),
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
BookingAvailability::fromTo(
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
)
)
),
],
Expand Down
7 changes: 5 additions & 2 deletions tests/Http/Event/ImportEventRequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use CultuurNet\UDB3\Model\Serializer\Event\EventDenormalizer;
use CultuurNet\UDB3\Model\ValueObject\Audience\AudienceType;
use CultuurNet\UDB3\Model\ValueObject\Calendar\CalendarType;
use CultuurNet\UDB3\Model\ValueObject\Contact\BookingAvailability;
use CultuurNet\UDB3\Model\ValueObject\Contact\ContactPoint;
use CultuurNet\UDB3\Model\ValueObject\Contact\TelephoneNumber;
use CultuurNet\UDB3\Model\ValueObject\Contact\TelephoneNumbers;
Expand Down Expand Up @@ -684,8 +685,10 @@ public function it_creates_a_new_event_without_id_but_with_all_properties(): voi
),
new TelephoneNumber('016 12 34 56'),
new EmailAddress('[email protected]'),
new DateTimeImmutable('2021-05-17T22:00:00+00:00'),
new DateTimeImmutable('2021-05-21T22:00:00+00:00')
BookingAvailability::fromTo(
new DateTimeImmutable('2021-05-17T22:00:00+00:00'),
new DateTimeImmutable('2021-05-21T22:00:00+00:00')
)
)
),
new UpdateContactPoint(
Expand Down
13 changes: 9 additions & 4 deletions tests/Http/Offer/UpdateBookingInfoRequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use CultuurNet\UDB3\Http\Request\Psr7RequestBuilder;
use CultuurNet\UDB3\Http\Response\AssertJsonResponseTrait;
use CultuurNet\UDB3\Http\Response\NoContentResponse;
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;
Expand Down Expand Up @@ -109,8 +110,10 @@ public function offerTypeDataProvider(): array
),
new TelephoneNumber('02/1232323'),
new EmailAddress('[email protected]'),
DateTimeFactory::fromAtom('2023-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2028-01-31T23:59:59+01:00')
BookingAvailability::fromTo(
DateTimeFactory::fromAtom('2023-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2028-01-31T23:59:59+01:00')
)
);

$bookingInfoSpecialCharactersUrl = new BookingInfo(
Expand All @@ -123,8 +126,10 @@ public function offerTypeDataProvider(): array
),
new TelephoneNumber('02/1232323'),
new EmailAddress('[email protected]'),
DateTimeFactory::fromAtom('2023-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2028-01-31T23:59:59+01:00')
BookingAvailability::fromTo(
DateTimeFactory::fromAtom('2023-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2028-01-31T23:59:59+01:00')
)
);

return [
Expand Down
7 changes: 5 additions & 2 deletions tests/Http/Place/ImportPlaceRequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use CultuurNet\UDB3\Model\ValueObject\Calendar\StatusReason;
use CultuurNet\UDB3\Model\ValueObject\Calendar\StatusType;
use CultuurNet\UDB3\Model\ValueObject\Calendar\TranslatedStatusReason;
use CultuurNet\UDB3\Model\ValueObject\Contact\BookingAvailability;
use CultuurNet\UDB3\Model\ValueObject\Contact\ContactPoint;
use CultuurNet\UDB3\Model\ValueObject\Contact\TelephoneNumber;
use CultuurNet\UDB3\Model\ValueObject\Contact\TelephoneNumbers;
Expand Down Expand Up @@ -872,8 +873,10 @@ public function it_updates_an_existing_place(): void
),
new TelephoneNumber('016 10 20 30'),
new EmailAddress('[email protected]'),
new DateTimeImmutable('2020-05-17T22:00:00+00:00'),
new DateTimeImmutable('2028-05-17T22:00:00+00:00'),
BookingAvailability::fromTo(
new DateTimeImmutable('2020-05-17T22:00:00+00:00'),
new DateTimeImmutable('2028-05-17T22:00:00+00:00')
)
)
),
new UpdateContactPoint(
Expand Down
11 changes: 7 additions & 4 deletions tests/Model/Import/Offer/Udb3ModelToLegacyOfferAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace CultuurNet\UDB3\Model\Import\Offer;

use CultuurNet\UDB3\BookingInfo as LegacyBookingInfo;
use CultuurNet\UDB3\Calendar\Calendar;
use CultuurNet\UDB3\DateTimeFactory;
use CultuurNet\UDB3\Event\EventType;
Expand Down Expand Up @@ -311,7 +312,7 @@ public function it_should_return_price_info_if_there_is_any(): void
*/
public function it_should_return_empty_booking_info_by_default(): void
{
$expected = new \CultuurNet\UDB3\BookingInfo();
$expected = new LegacyBookingInfo();
$actual = $this->adapter->getBookingInfo();
$this->assertEquals($expected, $actual);
}
Expand All @@ -321,7 +322,7 @@ public function it_should_return_empty_booking_info_by_default(): void
*/
public function it_should_return_booking_info_if_there_is_any(): void
{
$expected = new \CultuurNet\UDB3\BookingInfo(
$expected = new LegacyBookingInfo(
new WebsiteLink(
new Url('https://www.publiq.be'),
new TranslatedWebsiteLabel(
Expand All @@ -331,8 +332,10 @@ public function it_should_return_booking_info_if_there_is_any(): void
),
new TelephoneNumber('044/444444'),
new EmailAddress('[email protected]'),
new DateTimeImmutable('2018-01-01T10:00:00+01:00'),
new DateTimeImmutable('2018-01-10T10:00:00+01:00')
BookingAvailability::fromTo(
new DateTimeImmutable('2018-01-01T10:00:00+01:00'),
new DateTimeImmutable('2018-01-10T10:00:00+01:00')
)
);
$actual = $this->completeAdapter->getBookingInfo();
$this->assertEquals($expected, $actual);
Expand Down
13 changes: 9 additions & 4 deletions tests/Offer/Commands/AbstractUpdateBookingInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use CultuurNet\UDB3\BookingInfo;
use CultuurNet\UDB3\DateTimeFactory;
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;
Expand Down Expand Up @@ -40,8 +41,10 @@ public function setUp(): void
),
new TelephoneNumber('0123456789'),
new EmailAddress('[email protected]'),
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
BookingAvailability::fromTo(
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
)
);

$this->updateBookingInfo = $this->getMockForAbstractClass(
Expand All @@ -66,8 +69,10 @@ public function it_can_return_its_properties(): void
),
new TelephoneNumber('0123456789'),
new EmailAddress('[email protected]'),
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
BookingAvailability::fromTo(
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
)
);

$this->assertEquals($expectedBookingInfo, $bookingInfo);
Expand Down
25 changes: 17 additions & 8 deletions tests/Offer/Events/AbstractBookingInfoEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use CultuurNet\UDB3\BookingInfo;
use CultuurNet\UDB3\DateTimeFactory;
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;
Expand Down Expand Up @@ -39,8 +40,10 @@ public function setUp(): void
),
new TelephoneNumber('0123456789'),
new EmailAddress('[email protected]'),
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
BookingAvailability::fromTo(
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
)
);
$this->abstractBookingInfoEvent = new MockAbstractBookingInfoEvent(
$this->itemId,
Expand All @@ -64,8 +67,10 @@ public function it_can_be_instantiated_with_properties(): void
),
new TelephoneNumber('0123456789'),
new EmailAddress('[email protected]'),
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
BookingAvailability::fromTo(
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
)
);
$expectedAbstractBookingInfoEvent = new MockAbstractBookingInfoEvent(
$expectedItemId,
Expand All @@ -91,8 +96,10 @@ public function it_can_return_its_properties(): void
),
new TelephoneNumber('0123456789'),
new EmailAddress('[email protected]'),
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
BookingAvailability::fromTo(
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
)
);

$itemId = $this->abstractBookingInfoEvent->getItemId();
Expand Down Expand Up @@ -157,8 +164,10 @@ public function serializationDataProvider(): array
),
new TelephoneNumber('0123456789'),
new EmailAddress('[email protected]'),
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
BookingAvailability::fromTo(
DateTimeFactory::fromAtom('2016-01-01T00:00:00+01:00'),
DateTimeFactory::fromAtom('2016-01-31T00:00:00+01:00')
)
)
),
],
Expand Down
Loading

0 comments on commit 155a535

Please sign in to comment.