关于 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);
}
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 3
洛未必达

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

5年前 评论

file
这块也有些问题

5年前 评论

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

5年前 评论

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