-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from itk-dev/feature/booking-247-add-tests
Add acceptConflict tests.
- Loading branch information
Showing
5 changed files
with
103 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,7 +231,7 @@ public function testCreateBookingHandler(): void | |
$booking->setResourceEmail('[email protected]'); | ||
$booking->setStartTime(new \DateTime()); | ||
$booking->setEndTime(new \DateTime()); | ||
$booking->setUserName('auther1'); | ||
$booking->setUserName('author1'); | ||
$booking->setUserMail('[email protected]'); | ||
$booking->setMetaData([ | ||
'meta_data_4' => '1, 2, 3', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -553,4 +553,59 @@ public function testCreateBookingInviteResource(): void | |
$this->assertEquals(400, $e->getCode()); | ||
} | ||
} | ||
|
||
/** | ||
* @throws MicrosoftGraphCommunicationException | ||
* @throws BookingCreateConflictException | ||
*/ | ||
public function testAcceptConflict(): void | ||
{ | ||
$microsoftGraphServiceHelperMock = $this->getMockBuilder(MicrosoftGraphHelperService::class) | ||
->disableOriginalConstructor() | ||
->onlyMethods(['isBookingConflict', 'request', 'authenticateAsServiceAccount']) | ||
->getMock(); | ||
$microsoftGraphServiceHelperMock->expects($this->exactly(1))->method('isBookingConflict')->willReturn(true); | ||
$microsoftGraphServiceHelperMock->method('authenticateAsServiceAccount')->willReturn('1234'); | ||
|
||
$microsoftGraphServiceHelperMock->expects($this->exactly(1))->method('request')->willReturn( | ||
new GraphResponse( | ||
new GraphRequest('GET', '/', '123', 'http://localhost', 'v1'), | ||
json_encode([ | ||
'iCalUId' => '123', | ||
]), | ||
201, | ||
), | ||
); | ||
|
||
$microsoftGraphService = new MicrosoftGraphBookingService('test', 'test', $microsoftGraphServiceHelperMock); | ||
|
||
// Accept conflict. | ||
$microsoftGraphService->createBookingForResource( | ||
'[email protected]', | ||
'test resource', | ||
'test', | ||
'', | ||
new \DateTime('2040-08-18T10:00:00.000Z'), | ||
new \DateTime('2040-08-18T12:00:00.000Z'), | ||
true, | ||
); | ||
|
||
$exceptionCode = null; | ||
|
||
// Do not accept conflict. | ||
try { | ||
$microsoftGraphService->createBookingForResource( | ||
'[email protected]', | ||
'test resource', | ||
'test', | ||
'', | ||
new \DateTime('2040-08-18T10:00:00.000Z'), | ||
new \DateTime('2040-08-18T12:00:00.000Z'), | ||
); | ||
} catch (BookingCreateConflictException $e) { | ||
$exceptionCode = $e->getCode(); | ||
} | ||
|
||
$this->assertEquals(409, $exceptionCode); | ||
} | ||
} |