Completed
Pull Request — master (#25)
by
unknown
02:43
created

PagesTest::it_makes_page_as_homepage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

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