dazzle/behattr-date-manipulation

允许您使用不同的系统日期执行自定义步骤的命令。

安装: 834

依赖项: 0

建议者: 0

安全: 0

星级: 0

关注者: 1

分支: 1

开放问题: 0

类型:behattr-extension

dev-master 2024-03-07 15:23 UTC

This package is auto-updated.

Last update: 2024-09-07 16:32:35 UTC


README

此包允许您执行对时间敏感的命令。

我什么时候需要这个?

如果您有需要执行的时间敏感步骤,例如 cronjob 选取 X 天前的项目。

安装

通过 composer 安装

composer require dazzle/behat-date-manipulation:dev-master

此包依赖于 libfaketime

大多数情况下,安装非常简单

git clone https://github.com/wolfcw/libfaketime.git
cd libfaketime && make install

使用方法

在您的 Behat 配置 YAML 文件中,在 'Contexts' 部分添加以下内容

- Dazzle\BehatDateManipulation\FeatureContext:
            parameters:
              install_path: "/usr/local/lib/faketime/libfaketime.so.1"

默认的 libfaketime 路径通常应该没问题。

示例步骤

Given I manipulate the date with "+30d" and execute command "php my_cron.php"

Given I manipulate the date with "-15d" and execute command "date"
And I save it into "DATE"
And I expect "<<DATE>>" to equal "xxxx"

第二个示例使用了 rdx/behat-variables,它不包含在此包中,但如果您想使用此包提供的输出,可能很有用。

鸣谢

www.dazzle.be www.aperta.be