Skip to content

NOW MANAGED ON CODEBERG

Tests: Categorised up meta tests

Dan Brown514db6061778
diff --git a/tests/HelpTest.php b/tests/Meta/HelpTest.php
similarity index 94%
rename from tests/HelpTest.php
rename to tests/Meta/HelpTest.php
index 9cf80717f..e1de96bc8 100644
--- a/tests/HelpTest.php
+++ b/tests/Meta/HelpTest.php
@@ -1,6 +1,8 @@
<?php
-namespace Tests;
+namespace Tests\Meta;
+
+use Tests\TestCase;
class HelpTest extends TestCase
{
diff --git a/tests/LicensesTest.php b/tests/Meta/LicensesTest.php
similarity index 94%
rename from tests/LicensesTest.php
rename to tests/Meta/LicensesTest.php
index a7fb803c0..4bee6f682 100644
--- a/tests/LicensesTest.php
+++ b/tests/Meta/LicensesTest.php
@@ -1,6 +1,8 @@
<?php
-namespace Tests;
+namespace Tests\Meta;
+
+use Tests\TestCase;
class LicensesTest extends TestCase
{
diff --git a/tests/OpenGraphTest.php b/tests/Meta/OpenGraphTest.php
similarity index 98%
rename from tests/OpenGraphTest.php
rename to tests/Meta/OpenGraphTest.php
index 545fa4c86..96e622da0 100644
--- a/tests/OpenGraphTest.php
+++ b/tests/Meta/OpenGraphTest.php
@@ -1,11 +1,12 @@
<?php
-namespace Tests;
+namespace Tests\Meta;
use BookStack\Entities\Repos\BaseRepo;
use BookStack\Entities\Repos\BookRepo;
use Illuminate\Support\Str;
use Illuminate\Testing\TestResponse;
+use Tests\TestCase;
class OpenGraphTest extends TestCase
{
diff --git a/tests/OpensearchTest.php b/tests/Meta/OpensearchTest.php
similarity index 84%
rename from tests/OpensearchTest.php
rename to tests/Meta/OpensearchTest.php
index a68076b43..38e158716 100644
--- a/tests/OpensearchTest.php
+++ b/tests/Meta/OpensearchTest.php
@@ -1,12 +1,15 @@
<?php
-namespace Tests;
+namespace Tests\Meta;
+
+use Tests\TestCase;
class OpensearchTest extends TestCase
{
public function test_opensearch_endpoint()
{
- $appName = setting('app-name');
+ $appName = 'MyAppNameThatsReallyLongLikeThis';
+ setting()->put('app-name', $appName);
$resultUrl = url('/search') . '?term={searchTerms}';
$selfUrl = url('/opensearch.xml');
@@ -17,14 +20,11 @@ class OpensearchTest extends TestCase
$html->assertElementExists('OpenSearchDescription > ShortName');
$html->assertElementContains('OpenSearchDescription > ShortName', mb_strimwidth($appName, 0, 16));
+ $html->assertElementNotContains('OpenSearchDescription > ShortName', $appName);
$html->assertElementExists('OpenSearchDescription > Description');
- $html->assertElementContains('OpenSearchDescription > Description', trans('common.opensearch_description', [
- 'appName' => $appName,
- ]));
-
+ $html->assertElementContains('OpenSearchDescription > Description', "Search {$appName}");
$html->assertElementExists('OpenSearchDescription > Image');
-
$html->assertElementExists('OpenSearchDescription > Url[rel="results"][template="' . htmlspecialchars($resultUrl) . '"]');
$html->assertElementExists('OpenSearchDescription > Url[rel="self"][template="' . htmlspecialchars($selfUrl) . '"]');
}
diff --git a/tests/PwaManifestTest.php b/tests/Meta/PwaManifestTest.php
similarity index 98%
rename from tests/PwaManifestTest.php
rename to tests/Meta/PwaManifestTest.php
index c66f8b360..fc6d19b54 100644
--- a/tests/PwaManifestTest.php
+++ b/tests/Meta/PwaManifestTest.php
@@ -1,6 +1,8 @@
<?php
-namespace Tests;
+namespace Tests\Meta;
+
+use Tests\TestCase;
class PwaManifestTest extends TestCase
{
diff --git a/tests/Meta/RobotsTest.php b/tests/Meta/RobotsTest.php
new file mode 100644
index 000000000..04496c375
--- /dev/null
+++ b/tests/Meta/RobotsTest.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Tests\Meta;
+
+use Tests\TestCase;
+
+class RobotsTest extends TestCase
+{
+ public function test_robots_effected_by_public_status()
+ {
+ $this->get('/robots.txt')->assertSee("User-agent: *\nDisallow: /");
+
+ $this->setSettings(['app-public' => 'true']);
+
+ $resp = $this->get('/robots.txt');
+ $resp->assertSee("User-agent: *\nDisallow:");
+ $resp->assertDontSee('Disallow: /');
+ }
+
+ public function test_robots_effected_by_setting()
+ {
+ $this->get('/robots.txt')->assertSee("User-agent: *\nDisallow: /");
+
+ config()->set('app.allow_robots', true);
+
+ $resp = $this->get('/robots.txt');
+ $resp->assertSee("User-agent: *\nDisallow:");
+ $resp->assertDontSee('Disallow: /');
+
+ // Check config overrides app-public setting
+ config()->set('app.allow_robots', false);
+ $this->setSettings(['app-public' => 'true']);
+ $this->get('/robots.txt')->assertSee("User-agent: *\nDisallow: /");
+ }
+}
diff --git a/tests/PublicActionTest.php b/tests/PublicActionTest.php
index 875b279a8..76745aaac 100644
--- a/tests/PublicActionTest.php
+++ b/tests/PublicActionTest.php
@@ -128,33 +128,6 @@ class PublicActionTest extends TestCase
$resp->assertDontSee($page->name);
}
- public function test_robots_effected_by_public_status()
- {
- $this->get('/robots.txt')->assertSee("User-agent: *\nDisallow: /");
-
- $this->setSettings(['app-public' => 'true']);
-
- $resp = $this->get('/robots.txt');
- $resp->assertSee("User-agent: *\nDisallow:");
- $resp->assertDontSee('Disallow: /');
- }
-
- public function test_robots_effected_by_setting()
- {
- $this->get('/robots.txt')->assertSee("User-agent: *\nDisallow: /");
-
- config()->set('app.allow_robots', true);
-
- $resp = $this->get('/robots.txt');
- $resp->assertSee("User-agent: *\nDisallow:");
- $resp->assertDontSee('Disallow: /');
-
- // Check config overrides app-public setting
- config()->set('app.allow_robots', false);
- $this->setSettings(['app-public' => 'true']);
- $this->get('/robots.txt')->assertSee("User-agent: *\nDisallow: /");
- }
-
public function test_default_favicon_file_created_upon_access()
{
$faviconPath = public_path('favicon.ico');