ssaweb/appwrite-test-utils

有用的类,帮助您为Appwrite功能编写PHPUnit测试

v2.0.2 2024-01-08 04:40 UTC

This package is auto-updated.

Last update: 2024-09-08 06:12:16 UTC


README

用于帮助您为Appwrite功能编写PHPUnit测试的类

为什么使用$context包装器?

可能是对其他人有用的个人需求 XD

基本上,如果您尝试编写一个测试来检查发送到Appwrite函数API的jsonsend方法的请求数据,如下所示

$this->response = $this->createMock(stdClass::class);

$this->response
    ->expects($this->once())
    ->method('json')
    ->with($this->anything(), 201);

上面的代码将失败,并显示以下信息

Trying to configure method "json" which cannot be configured because it does not exist, has not been specified, is final, or is static

因此,我们需要向该对象添加一个类型,因为Appwrite的SDK没有为我们提供它,所以我创建了这个包来做到这一点。

$this->response = $this->createMock(Response::class);

$this->response
    ->expects($this->once())
    ->method('json')
    ->with($this->anything(), 201);

现在我们有一个可以评估的具有类型的$response对象 =)