nathanmac/im-codeception-module

在Codeception验收测试中测试消息服务

v1.1 2014-10-24 15:13 UTC

This package is not auto-updated.

Last update: 2024-09-24 03:19:34 UTC


README

Latest Stable Version License

此模块将允许您在Codeception验收测试中测试发送的消息。

安装

首先,通过Composer安装此软件包。编辑您的项目composer.json文件以要求nathanmac/im-codeception-module

{
    "require-dev": {
        "codeception/codeception": "*",
        "nathanmac/im-codeception-module": "~1.0"
    }
}

接下来,在终端中更新Composer

composer update

然后,在套件配置中使用以下设置启用它

配置

根据使用的队列服务,以下是所有配置选项。请参考以下配置示例,以确定所需的服务配置选项。

  • service - 消息服务。
  • token - API令牌和/或访问令牌。
  • room - 消息服务的房间/频道ID。

注意。HipChat的API密钥必须是用户的API令牌,以便提供足够的访问权限获取给定房间中的最后一条消息。但是,如果您只想向服务发送消息,房间API令牌就足够发送消息了。有关此问题的详细说明,请参阅HipChat API文档。

示例

示例配置(hipchat)

 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));

操作

sendInstantMessage

向消息服务发送消息的简单方法。

<?php
$I->sendInstantMessage('Testing message to be send to IM service.', array('color' => 'red', 'notify' => true);
?>
  • 参数 string $message 要发送的消息。
  • 参数 array $options 根据服务而异,对于HipChat,这些包括颜色和通知选项。

grabLastInstantMessage

抓取方法,返回服务上的最后一条消息。

<?php
$messages = $I->grabLastInstantMessage();
?>

grabLastInstantMessageFrom

抓取方法,返回最后一条消息的“from”字段。

<?php
$from = $I>grabLastInstantMessageFrom();
?>

seeInLastInstantMessageFrom

检查最后一条消息的发送地址是否匹配。

<?php
$I->seeInLastInstantMessageFrom('Codeception');
?>

dontSeeInLastInstantMessageFrom

检查最后一条消息的发送地址是否不匹配。

<?php
$I->dontSeeInLastInstantMessageFrom('Codeception');
?>

grabLastInstantMessageContent

抓取方法,返回最后一条消息的内容/文本。

<?php
$content = $I->grabLastInstantMessageContent();
?>

seeInLastInstantMessageContent

检查最后一条消息的内容/文本是否匹配。

<?php
$I->seeInLastInstantMessageContent('Hello this is the messages I am expecting to see.');
?>

dontSeeInLastInstantMessageContent

检查最后一条消息的内容/文本是否不匹配。

<?php
$I->dontSeeInLastInstantMessageContent('Hello this is the messages I am not expecting to see.');
?>

grabLastInstantMessageColor

抓取方法,返回最后一条消息的颜色。

<?php
$color = $I->grabLastInstantMessageColor();
?>

seeInLastInstantMessageColor

检查最后一条消息的颜色是否匹配。

<?php
$I->seeInLastInstantMessageColor('red');
?>

dontSeeInLastInstantMessageColor

检查最后一条消息的颜色是否不匹配。

<?php
$I->dontSeeInLastInstantMessageColor('red');
?>

grabLastInstantMessageDate

抓取方法,返回最后一条消息的日期/时间。

<?php
$date = $I->grabLastInstantMessageDate();
?>

seeInLastInstantMessageDate

检查最后一条消息的日期是否匹配。

<?php
$I->seeInLastInstantMessageDate('2014-10-13T16:30:48.657455+00:00');
?>

dontSeeInLastInstantMessageDate

检查最后一条消息的日期是否不匹配。

<?php
$I->dontSeeInLastInstantMessageDate('2015-11-13T16:30:48.657455+00:00');
?>

许可证

与Codeception相同的许可证:MIT