2
0

LibraryTipitakaReadTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. use Illuminate\Foundation\Testing\RefreshDatabase;
  3. use Illuminate\Support\Str;
  4. uses(RefreshDatabase::class);
  5. /**
  6. * 阅读页的目标不存在时返回 404,而不是 500。
  7. * 旧地址 /library/tipitaka/{book}-{para}/read 先校验 channel 再 301;新地址见最后两条。
  8. */
  9. it('returns 404 when the channel does not exist', function () {
  10. $this->get('/library/tipitaka/165-123/read?channel='.Str::uuid())
  11. ->assertNotFound();
  12. });
  13. it('returns 404 when the channel is not a uuid', function () {
  14. $this->get('/library/tipitaka/165-123/read?channel=not-a-uuid')
  15. ->assertNotFound();
  16. });
  17. it('returns 404 when the id is malformed', function () {
  18. $this->get('/library/tipitaka/abc/read?channel='.makeChannel(makeStudio('me'), 'c'))
  19. ->assertNotFound();
  20. });
  21. it('returns 404 when the paragraph is not a chapter', function () {
  22. $channel = makeChannel(makeStudio('me'), 'c');
  23. $this->get("/library/tipitaka/channels/{$channel}/chapter/99999-1")
  24. ->assertNotFound();
  25. });
  26. it('returns 404 on the new reader url when the channel does not exist', function () {
  27. $this->get('/library/tipitaka/channels/'.Str::uuid().'/chapter/165-123')
  28. ->assertNotFound();
  29. });