1 <?php namespace Entity;
7 class PageRevisionTest extends TestCase
10 public function test_page_revision_count_increments_on_update()
12 $page = Page::first();
13 $startCount = $page->revision_count;
14 $resp = $this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
15 $resp->assertStatus(302);
17 $this->assertTrue(Page::find($page->id)->revision_count === $startCount+1);
20 public function test_revision_count_shown_in_page_meta()
22 $page = Page::first();
23 $this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
24 $this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
25 $page = Page::find($page->id);
27 $pageView = $this->get($page->getUrl());
28 $pageView->assertSee('Revision #' . $page->revision_count);
31 public function test_revision_deletion() {
32 $page = Page::first();
33 $this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
34 $this->asEditor()->put($page->getUrl(), ['name' => 'Updated page', 'html' => 'new page html', 'summary' => 'Update a']);
35 $page = Page::find($page->id);
36 $beforeRevisionCount = $page->revisions->count();
38 // Delete the first revision
39 $revision = $page->revisions->get(0);
40 $resp = $this->asEditor()->delete($revision->getUrl('/delete/'));
41 $resp->assertStatus(200);
43 $page = Page::find($page->id);
44 $afterRevisionCount = $page->revisions->count();
46 $this->assertTrue($beforeRevisionCount === ($afterRevisionCount + 1));
48 // Try to delete the latest revision
49 $revision = $page->revisions->get($page->revisions->count() - 1);
50 $resp = $this->asEditor()->delete($revision->getUrl('/delete/'));
51 $resp->assertSee('Cannot delete the latest revision');