]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/EntityTest.php
Finished refactor of entity repos
[bookstack] / tests / Entity / EntityTest.php
index 71d83dd47237efaedd2830af575f8c0f445fe78a..9fd4eb9ad299bcee4528cbf97e9e581744fd14fe 100644 (file)
@@ -136,7 +136,7 @@ class EntityTest extends TestCase
         $this->asAdmin()
             ->visit('/books')
             // Choose to create a book
-            ->click('Add new book')
+            ->click('Create New Book')
             ->seePageIs('/books/create')
             // Fill out form & save
             ->type($book->name, '#name')
@@ -168,7 +168,7 @@ class EntityTest extends TestCase
         $entities = $this->createEntityChainBelongingToUser($creator, $updater);
         $this->actingAs($creator);
         app('BookStack\Repos\UserRepo')->destroy($creator);
-        app('BookStack\Repos\PageRepo')->saveRevision($entities['page']);
+        app('BookStack\Repos\EntityRepo')->savePageRevision($entities['page']);
 
         $this->checkEntitiesViewable($entities);
     }
@@ -181,7 +181,7 @@ class EntityTest extends TestCase
         $entities = $this->createEntityChainBelongingToUser($creator, $updater);
         $this->actingAs($updater);
         app('BookStack\Repos\UserRepo')->destroy($updater);
-        app('BookStack\Repos\PageRepo')->saveRevision($entities['page']);
+        app('BookStack\Repos\EntityRepo')->savePageRevision($entities['page']);
 
         $this->checkEntitiesViewable($entities);
     }
@@ -218,15 +218,27 @@ class EntityTest extends TestCase
 
     public function test_old_page_slugs_redirect_to_new_pages()
     {
-        $page = \BookStack\Page::all()->first();
+        $page = \BookStack\Page::first();
         $pageUrl = $page->getUrl();
         $newPageUrl = '/books/' . $page->book->slug . '/page/super-test-page';
+        // Need to save twice since revisions are not generated in seeder.
         $this->asAdmin()->visit($pageUrl)
+            ->clickInElement('#content', 'Edit')
+            ->type('super test', '#name')
+            ->press('Save Page');
+
+        $page = \BookStack\Page::first();
+        $pageUrl = $page->getUrl();
+
+        // Second Save
+        $this->visit($pageUrl)
             ->clickInElement('#content', 'Edit')
             ->type('super test page', '#name')
             ->press('Save Page')
-            ->seePageIs($newPageUrl)
-            ->visit($pageUrl)
+            // Check redirect
+            ->seePageIs($newPageUrl);
+
+        $this->visit($pageUrl)
             ->seePageIs($newPageUrl);
     }