]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/EntityTest.php
Finished refactor of entity repos
[bookstack] / tests / Entity / EntityTest.php
index 8c0c286a6c271939567eb73445df77e9c94ff775..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')
@@ -151,8 +151,10 @@ class EntityTest extends TestCase
             ->visit('/books/create')
             ->type($book->name, '#name')
             ->type($book->description, '#description')
-            ->press('Save Book')
-            ->seePageIs('/books/my-first-book-2');
+            ->press('Save Book');
+        
+        $expectedPattern = '/\/books\/my-first-book-[0-9a-zA-Z]{3}/';
+        $this->assertRegExp($expectedPattern, $this->currentUri, "Did not land on expected page [$expectedPattern].\n");
 
         $book = \BookStack\Book::where('slug', '=', 'my-first-book')->first();
         return $book;
@@ -166,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);
     }
@@ -179,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);
     }
@@ -234,8 +236,9 @@ class EntityTest extends TestCase
             ->type('super test page', '#name')
             ->press('Save Page')
             // Check redirect
-            ->seePageIs($newPageUrl)
-            ->visit($pageUrl)
+            ->seePageIs($newPageUrl);
+
+        $this->visit($pageUrl)
             ->seePageIs($newPageUrl);
     }