Skip to content

Commit

Permalink
Making sure a page can be unset as homepage.
Browse files Browse the repository at this point in the history
Making sure if second homepage is added, first one is unset.
  • Loading branch information
nWidart committed May 17, 2016
1 parent e75896e commit 3b0b959
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions Tests/PagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,55 @@ public function it_makes_page_as_homepage()
'body' => 'My Page Body',
],
]);

$homepage = $this->page->findHomepage();

$this->assertTrue($page->is_home);
$this->assertEquals($page->id, $homepage->id);
}

/** @test */
public function it_can_unset_homepage()
{
$page = $this->page->create([
'is_home' => 1,
'template' => 'default',
'en' => [
'title' => 'My Page',
'slug' => 'my-page',
'body' => 'My Page Body',
],
]);
$page = $this->page->update($page, [
'is_home' => 0,
]);
$this->assertFalse($page->is_home);
}

/** @test */
public function it_unsets_first_homepage_if_another_is_set_as_homepage()
{
$this->page->create([
'is_home' => '1',
'template' => 'default',
'en' => [
'title' => 'My Page',
'slug' => 'my-page',
'body' => 'My Page Body',
],
]);
$pageOther = $this->page->create([
'is_home' => '1',
'template' => 'default',
'en' => [
'title' => 'My Other Page',
'slug' => 'my-other-page',
'body' => 'My Page Body',
],
]);

$page = $this->page->find(1);
$this->assertFalse($page->is_home);
$this->assertTrue($pageOther->is_home);
}
}

0 comments on commit 3b0b959

Please sign in to comment.