]> BookStack Code Mirror - bookstack/commitdiff
Fixed entity-specific tag counts listing
authorDan Brown <redacted>
Mon, 16 May 2022 13:05:21 +0000 (14:05 +0100)
committerDan Brown <redacted>
Mon, 16 May 2022 13:05:21 +0000 (14:05 +0100)
Was reporting wrong due to use of old polymorphic namespace references.
Test was not picking up as assertElementContains had wider scope than
expected, looking within the HTML of the element instead of the text
which you might expect. Updated test helper to look at text instead.

app/Actions/TagRepo.php
tests/TestResponse.php

index 0acee7486b92a4dec062834799b99a406e6bba39..8cf1076019e6318785a3d5ed13fc8d4490b16517 100644 (file)
@@ -28,10 +28,10 @@ class TagRepo
                 'name',
                 ($searchTerm || $nameFilter) ? 'value' : DB::raw('COUNT(distinct value) as `values`'),
                 DB::raw('COUNT(id) as usages'),
-                DB::raw('SUM(IF(entity_type = \'BookStack\\\\Page\', 1, 0)) as page_count'),
-                DB::raw('SUM(IF(entity_type = \'BookStack\\\\Chapter\', 1, 0)) as chapter_count'),
-                DB::raw('SUM(IF(entity_type = \'BookStack\\\\Book\', 1, 0)) as book_count'),
-                DB::raw('SUM(IF(entity_type = \'BookStack\\\\BookShelf\', 1, 0)) as shelf_count'),
+                DB::raw('SUM(IF(entity_type = \'page\', 1, 0)) as page_count'),
+                DB::raw('SUM(IF(entity_type = \'chapter\', 1, 0)) as chapter_count'),
+                DB::raw('SUM(IF(entity_type = \'book\', 1, 0)) as book_count'),
+                DB::raw('SUM(IF(entity_type = \'bookshelf\', 1, 0)) as shelf_count'),
             ])
             ->orderBy($nameFilter ? 'value' : 'name');
 
index 4e53aa020ba3ca5054e8d75e14a2ed57dc277276..888bacdfc6c0152f9be22d498c9fd348f90a552c 100644 (file)
@@ -111,7 +111,7 @@ class TestResponse extends BaseTestResponse
 
         foreach ($elements as $element) {
             $element = new Crawler($element);
-            if (preg_match("/$pattern/i", $element->html())) {
+            if (preg_match("/$pattern/i", $element->text())) {
                 $matched = true;
                 break;
             }