]> BookStack Code Mirror - bookstack/blobdiff - tests/Api/PagesApiTest.php
Tiny header
[bookstack] / tests / Api / PagesApiTest.php
index 4eb109d9dec3acf35653740aa51f5af714d122c4..b91d96d892c74402e9ac79990bbcdcad663d56f0 100644 (file)
@@ -5,13 +5,15 @@ namespace Tests\Api;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Page;
+use Carbon\Carbon;
+use Illuminate\Support\Facades\DB;
 use Tests\TestCase;
 
 class PagesApiTest extends TestCase
 {
     use TestsApi;
 
-    protected $baseEndpoint = '/api/pages';
+    protected string $baseEndpoint = '/api/pages';
 
     public function test_index_endpoint_returns_expected_page()
     {
@@ -240,6 +242,21 @@ class PagesApiTest extends TestCase
         $this->assertEquals($originalContent, $page->html);
     }
 
+    public function test_update_increments_updated_date_if_only_tags_are_sent()
+    {
+        $this->actingAsApiEditor();
+        $page = Page::visible()->first();
+        DB::table('pages')->where('id', '=', $page->id)->update(['updated_at' => Carbon::now()->subWeek()]);
+
+        $details = [
+            'tags' => [['name' => 'Category', 'value' => 'Testing']]
+        ];
+
+        $this->putJson($this->baseEndpoint . "/{$page->id}", $details);
+        $page->refresh();
+        $this->assertGreaterThan(Carbon::now()->subDay()->unix(), $page->updated_at->unix());
+    }
+
     public function test_delete_endpoint()
     {
         $this->actingAsApiEditor();