关于 43 节的遗漏?

SubscribeToThreadsTest中的两个测试文中交代的有些模糊,跟到最后测试无法全部通过,参照源码修改如下后与教程效果同步

/** @test */
public function a_user_can_subscribe_to_threads()
{
    $this->signIn();
    // Given we have a thread...
    $thread = create('App\Thread');
    // And the user subscribes to the thread...
    $this->post($thread->path() . '/subscriptions');

    $this->assertCount(1, $thread->fresh()->subscriptions);
}

/** @test */
public function a_user_can_unsubscribe_from_threads()
{
    $this->signIn();
    $thread = create('App\Thread');
    // 这里原文笔记中忘记了一行,虽然测试不会报错,但是却不符合业务逻辑,源码中是有下面这一行,逻辑更加合理
    $thread->subscribe();
    $this->delete($thread->path() . '/subscriptions');
    $this->assertCount(0, $thread->subscriptions);
}
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 3
洛未必达

说的对,已经改正 :+1:

5年前 评论

file
这块也有些问题

5年前 评论

@洛未必达 是不是遗漏一段代码?

5年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!