]> BookStack Code Mirror - bookstack/blob - tests/HomepageTest.php
Updated the Swedish language files
[bookstack] / tests / HomepageTest.php
1 <?php namespace Tests;
2
3 class HomepageTest extends TestCase
4 {
5
6     public function test_default_homepage_visible()
7     {
8         $this->asEditor();
9         $homeVisit = $this->get('/');
10         $homeVisit->assertSee('My Recently Viewed');
11         $homeVisit->assertSee('Recently Updated Pages');
12         $homeVisit->assertSee('Recent Activity');
13         $homeVisit->assertSee('home-default');
14     }
15
16     public function test_custom_homepage()
17     {
18         $this->asEditor();
19         $name = 'My custom homepage';
20         $content = str_repeat('This is the body content of my custom homepage.', 20);
21         $customPage = $this->newPage(['name' => $name, 'html' => $content]);
22         $this->setSettings(['app-homepage' => $customPage->id]);
23         $this->setSettings(['app-homepage-type' => 'page']);
24
25         $homeVisit = $this->get('/');
26         $homeVisit->assertSee($name);
27         $homeVisit->assertSee($content);
28         $homeVisit->assertSee('My Recently Viewed');
29         $homeVisit->assertSee('Recently Updated Pages');
30         $homeVisit->assertSee('Recent Activity');
31     }
32
33     public function test_delete_custom_homepage()
34     {
35         $this->asEditor();
36         $name = 'My custom homepage';
37         $content = str_repeat('This is the body content of my custom homepage.', 20);
38         $customPage = $this->newPage(['name' => $name, 'html' => $content]);
39         $this->setSettings(['app-homepage' => $customPage->id]);
40
41         $homeVisit = $this->get('/');
42         $homeVisit->assertSee($name);
43
44         $pageDeleteReq = $this->delete($customPage->getUrl());
45         $pageDeleteReq->assertStatus(302);
46         $pageDeleteReq->assertRedirect($customPage->getUrl());
47         $pageDeleteReq->assertSessionHas('error');
48         $pageDeleteReq->assertSessionMissing('success');
49
50         $homeVisit = $this->get('/');
51         $homeVisit->assertSee($name);
52         $homeVisit->assertStatus(200);
53     }
54
55     public function test_set_book_homepage()
56     {
57         $editor = $this->getEditor();
58         setting()->putUser($editor, 'books_view_type', 'grid');
59
60         $this->setSettings(['app-homepage-type' => 'books']);
61
62         $this->asEditor();
63         $homeVisit = $this->get('/');
64         $homeVisit->assertSee('Books');
65         $homeVisit->assertSee('grid-card');
66         $homeVisit->assertSee('grid-card-content');
67         $homeVisit->assertSee('grid-card-footer');
68         $homeVisit->assertSee('featured-image-container');
69
70         $this->setSettings(['app-homepage-type' => false]);
71         $this->test_default_homepage_visible();
72     }
73
74     public function test_set_bookshelves_homepage()
75     {
76         $editor = $this->getEditor();
77         setting()->putUser($editor, 'bookshelves_view_type', 'grid');
78
79         $this->setSettings(['app-homepage-type' => 'bookshelves']);
80
81         $this->asEditor();
82         $homeVisit = $this->get('/');
83         $homeVisit->assertSee('Shelves');
84         $homeVisit->assertSee('bookshelf-grid-item grid-card');
85         $homeVisit->assertSee('grid-card-content');
86         $homeVisit->assertSee('grid-card-footer');
87         $homeVisit->assertSee('featured-image-container');
88
89         $this->setSettings(['app-homepage-type' => false]);
90         $this->test_default_homepage_visible();
91     }
92 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.