1 | <?php |
||
5 | class PagesTest extends BasePageTest |
||
6 | { |
||
7 | /** @test */ |
||
8 | public function it_makes_page_as_homepage() |
||
9 | { |
||
10 | $page = $this->page->create([ |
||
11 | 'is_home' => 1, |
||
12 | 'template' => 'default', |
||
13 | 'en' => [ |
||
14 | 'title' => 'My Page', |
||
15 | 'slug' => 'my-page', |
||
16 | 'body' => 'My Page Body', |
||
17 | ], |
||
18 | ]); |
||
19 | |||
20 | $homepage = $this->page->findHomepage(); |
||
21 | |||
22 | $this->assertTrue($page->is_home); |
||
23 | $this->assertEquals($page->id, $homepage->id); |
||
24 | } |
||
25 | |||
26 | /** @test */ |
||
27 | public function it_can_unset_homepage() |
||
28 | { |
||
29 | $page = $this->page->create([ |
||
30 | 'is_home' => 1, |
||
31 | 'template' => 'default', |
||
32 | 'en' => [ |
||
33 | 'title' => 'My Page', |
||
34 | 'slug' => 'my-page', |
||
35 | 'body' => 'My Page Body', |
||
36 | ], |
||
37 | ]); |
||
38 | $page = $this->page->update($page, [ |
||
39 | 'is_home' => 0, |
||
40 | ]); |
||
41 | $this->assertFalse($page->is_home); |
||
42 | } |
||
43 | |||
44 | /** @test */ |
||
45 | public function it_unsets_first_homepage_if_another_is_set_as_homepage() |
||
46 | { |
||
47 | $this->page->create([ |
||
48 | 'is_home' => '1', |
||
49 | 'template' => 'default', |
||
50 | 'en' => [ |
||
51 | 'title' => 'My Page', |
||
52 | 'slug' => 'my-page', |
||
53 | 'body' => 'My Page Body', |
||
54 | ], |
||
55 | ]); |
||
56 | $pageOther = $this->page->create([ |
||
57 | 'is_home' => '1', |
||
58 | 'template' => 'default', |
||
59 | 'en' => [ |
||
60 | 'title' => 'My Other Page', |
||
61 | 'slug' => 'my-other-page', |
||
62 | 'body' => 'My Page Body', |
||
63 | ], |
||
64 | ]); |
||
65 | |||
66 | $page = $this->page->find(1); |
||
67 | $this->assertFalse($page->is_home); |
||
68 | $this->assertTrue($pageOther->is_home); |
||
69 | } |
||
70 | } |
||
71 |