gpt4 book ai didi

laravel - 使用 Laravel5 模块 : withoutWrapping() applied on single JsonResource affects other tests 进行 Codeception api 测试

转载 作者:行者123 更新时间:2023-11-28 21:36:36 25 4
gpt4 key购买 nike

我在几个 Cest 文件中使用 Laravel5 模块进行代码接收 api 测试。如果我运行所有 api 测试 codecept run api。在包含 MyResource::withoutWrapping(); 的 api 资源影响其他 Cest 文件上的其他 api 响应后进行测试(它从 api 响应中删除“数据”包装)。是否有可能避免这种行为?我不想将 withoutWrapping() 应用于其他 api 资源,紧随其后...

# api.suite.yml
class_name: ApiTester
modules:
enabled:
- REST:
url: /api
depends: Laravel5
- \Helper\Api
- Asserts
- Laravel5:
environment_file: .env.testing

// Controller Api endpoint
public function show(Event $event)
{
EventResource::withoutWrapping();
return new EventResource($event->load([
'eventRoomPrices', 'hotel.availableRoomCategories']));
}

最佳答案

您必须在该测试方法的末尾或该 Cest 类的 _after 方法中调用与 MyResource::withoutWrapping() 相反的方法。

是否有 MyResource::withWrapping() 方法?

关于laravel - 使用 Laravel5 模块 : withoutWrapping() applied on single JsonResource affects other tests 进行 Codeception api 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58181841/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com