diff --git a/tests/UiTPASEventSagaTest.php b/tests/UiTPASEventSagaTest.php index 54522b6..1cfac85 100644 --- a/tests/UiTPASEventSagaTest.php +++ b/tests/UiTPASEventSagaTest.php @@ -684,6 +684,38 @@ public function it_creates_a_new_uitpas_aggregate_and_registers_an_uitpas_event_ ); } + /** + * @test + */ + public function it_handles_exception_for_events_imported_from_udb2() + { + $this->mockGetEventToThrow(); + + $cdbXml = file_get_contents(__DIR__ . '/cdbxml-samples/event-with-uitpas-organizer-and-price.xml'); + + $cdbXmlNamespaceUri = 'http://www.cultuurdatabank.com/XMLSchema/CdbXSD/3.3/FINAL'; + + $expectedPriceInfo = new PriceInfo( + new BasePrice( + Price::fromFloat(5.5), + Currency::fromNative('EUR') + ) + ); + + $this->scenario + ->when(new EventImportedFromUDB2($this->eventId, $cdbXml, $cdbXmlNamespaceUri)) + ->then( + [ + new CreateUiTPASAggregate($this->eventId, []), + new RegisterUiTPASEvent( + $this->eventId, + $this->uitpasOrganizerId, + $expectedPriceInfo + ), + ] + ); + } + /** * @test */ @@ -1242,4 +1274,14 @@ private function mockGetEvent(array $distributionKeys = []) ->with($this->eventId) ->willReturn($uitpasEvent); } + + private function mockGetEventToThrow() + { + $this->cultureFeedUitpas->expects($this->once()) + ->method('getEvent') + ->will($this->throwException(new \CultureFeed_Exception( + 'Event not found', + 0 + ))); + } }