This module will let you test messages that are sent during your Codeception acceptance tests.
Begin by installing this package through Composer. Edit your project's composer.json
file to require nathanmac/im-codeception-module
.
{
"require-dev": {
"codeception/codeception": "*",
"nathanmac/im-codeception-module": "~1.0"
}
}
Next, update Composer from the Terminal:
composer update
Then enable it in your suite configuration with the following settings
The configuration settings depending on which queueing service is being used, all the options are listed here. Refer to the configuration examples below to identify the configuration options required for your chosen service.
- service - the messaging service.
- token - API token and/or Access Token.
- room - The room/channel id for the messaging service.
N.B. The API key for HipChat must be an users API token in order to provide sufficient access the last messages in a given room, however if you are just looking to send a messages to the service a room API token will be sufficient to send the message. Consult the HipChat API documentation for clarification on this topic.
modules:
enabled: [IM]
config:
IM:
service: 'hipchat'
token: API_TOKEN
room: ROOM_ID
<?php
$I = new IMGuy($scenario);
$I->wantTo('grab the recent messages on the IM server and run some tests');
$message = $I->grabLastInstantMessage();
$I->seeInLastInstantMessageFrom('Tester');
$I->dontSeeInLastInstantMessageFrom('Codeception');
$I->seeInLastInstantMessageContent('Testing has been completed with no issues.');
$I->dontSeeInLastInstantMessageContent('Random Message not there');
$I->seeInLastInstantMessageColor('yello');
$I->dontSeeInLastInstantMessageColor('red');
$date = $I->grabLastInstantMessageDate();
$I->seeInLastInstantMessageDate('2014-10-21T16:41:48.657455+00:00');
$I->dontSeeInLastInstantMessageDate('2015-10-21T16:41:48.657455+00:00');
$I->sendInstantMessage("Testing has been completed with no issues.", array('color' => 'yellow', 'notify' => true));
Simple method for sending a messages to an messaging service.
<?php
$I->sendInstantMessage('Testing message to be send to IM service.', array('color' => 'red', 'notify' => true);
?>
- Param string $message Message to be sent.
- Param array $options Depends on service, for HipChat these include the color and the notify option.
Grabber method to return the last messages on the service.
<?php
$messages = $I->grabLastInstantMessage();
?>
Grabber method to return the from field of the last message.
<?php
$from = $I>grabLastInstantMessageFrom();
?>
Checks whether the last messages from address matches.
<?php
$I->seeInLastInstantMessageFrom('Codeception');
?>
Checks whether the last messages from address does not match.
<?php
$I->dontSeeInLastInstantMessageFrom('Codeception');
?>
Grabber method to return the content/text of the last message.
<?php
$content = $I->grabLastInstantMessageContent();
?>
Checks whether the last messages content/text matches.
<?php
$I->seeInLastInstantMessageContent('Hello this is the messages I am expecting to see.');
?>
Checks whether the last messages content/text does not match.
<?php
$I->dontSeeInLastInstantMessageContent('Hello this is the messages I am not expecting to see.');
?>
Grabber method to return the color of the last message.
<?php
$color = $I->grabLastInstantMessageColor();
?>
Checks whether the last messages color matches.
<?php
$I->seeInLastInstantMessageColor('red');
?>
Checks whether the last messages color does not match.
<?php
$I->dontSeeInLastInstantMessageColor('red');
?>
Grabber method to return the date/time of the last message.
<?php
$date = $I->grabLastInstantMessageDate();
?>
Checks whether the last messages date matches.
<?php
$I->seeInLastInstantMessageDate('2014-10-13T16:30:48.657455+00:00');
?>
Checks whether the last messages date does not match.
<?php
$I->dontSeeInLastInstantMessageDate('2015-11-13T16:30:48.657455+00:00');
?>
Released under the same license as Codeception: MIT