-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(MicrosoftTeams): Add test for sending message
- Created a new test file ClientTest.php in the MicrosoftTeams directory - Added a test to verify the ability to send a message using the Microsoft Teams client - Defined message content with various properties such as correlationId, originator, summary, themeColor, etc. - Added sections and potential actions to the message for richer content and interactivity - Mocked the response and asserted the ability to send the message successfully
- Loading branch information
Showing
1 changed file
with
117 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<?php | ||
|
||
/** @noinspection StaticClosureCanBeUsedInspection */ | ||
/** @noinspection PhpUnhandledExceptionInspection */ | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the guanguans/notify. | ||
* | ||
* (c) guanguans <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled. | ||
*/ | ||
|
||
namespace Guanguans\NotifyTests\MicrosoftTeams; | ||
|
||
use Guanguans\Notify\MicrosoftTeams\Authenticator; | ||
use Guanguans\Notify\MicrosoftTeams\Client; | ||
use Guanguans\Notify\MicrosoftTeams\Messages\Message; | ||
|
||
use function Pest\Faker\faker; | ||
|
||
it('can send message', function (): void { | ||
$authenticator = new Authenticator('Your webhook url.'); | ||
$client = new Client($authenticator); | ||
$message = Message::make([ | ||
'correlationId' => 'This is correlationId.', | ||
'expectedActors' => [ | ||
'[email protected]', | ||
], | ||
'originator' => 'This is originator.', | ||
'summary' => 'This is summary.', | ||
'themeColor' => '0076D7', | ||
'hideOriginalBody' => false, | ||
'title' => 'This is title.', | ||
'text' => 'This is text.', | ||
'sections' => [], | ||
'potentialAction' => [], | ||
]) | ||
->addSection([ | ||
'title' => 'This is title.', | ||
'startGroup' => true, | ||
'activityImage' => 'This is activityImage.', | ||
'activityTitle' => 'This is activityTitle.', | ||
'activitySubtitle' => 'This is activitySubtitle.', | ||
'activityText' => 'This is activityText.', | ||
'heroImage' => 'This is heroImage.', | ||
'text' => 'This is text.', | ||
'facts' => [ | ||
[ | ||
'name' => 'This is name.', | ||
'value' => 'This is value.', | ||
], | ||
], | ||
'images' => [ | ||
'This is images.', | ||
], | ||
'potentialAction' => [], | ||
]) | ||
->addPotentialAction([ | ||
'@type' => 'OpenUri', | ||
'name' => 'This is name.', | ||
'targets' => [ | ||
[ | ||
'os' => 'default', | ||
'uri' => 'https://learn.microsoft.com/outlook/actionable-messages', | ||
], | ||
], | ||
]) | ||
->addPotentialAction([ | ||
'@type' => 'HttpPOST', | ||
'name' => 'This is name.', | ||
'target' => 'https://learn.microsoft.com/outlook/actionable-messages', | ||
'headers' => [ | ||
[ | ||
'name' => 'X-Version', | ||
'value' => 'v1.0.0', | ||
], | ||
], | ||
'body' => [ | ||
'field' => 'value', | ||
], | ||
'bodyContentType' => 'application/x-www-form-urlencoded', | ||
]) | ||
->addPotentialAction([ | ||
'@type' => 'ActionCard', | ||
'name' => 'This is name.', | ||
'inputs' => [ | ||
[ | ||
'@type' => 'TextInput', | ||
'id' => 'comment', | ||
'isRequired' => true, | ||
'title' => 'This is title.', | ||
'value' => 'This is value.', | ||
'isMultiline' => true, | ||
], | ||
], | ||
'actions' => [], | ||
]) | ||
->addPotentialAction([ | ||
'@type' => 'InvokeAddInCommand', | ||
'name' => 'This is name.', | ||
'addInId' => '527104a1-f1a5-475a-9199-7a968161c870', | ||
'desktopCommandId' => 'show', | ||
'initializationContext' => [ | ||
'property1' => 'This is property1.', | ||
'property2' => 'This is property2.', | ||
], | ||
]); | ||
|
||
expect($client) | ||
->mock([ | ||
create_response(faker()->text()), | ||
]) | ||
->assertCanSendMessage($message); | ||
})->group(__DIR__, __FILE__); |