Extracted robots.txt tests into its own file to fit into new folder.
Also tweaked open search tests a tad to specifically check long app
names.
<?php
-namespace Tests;
+namespace Tests\Meta;
+
+use Tests\TestCase;
class HelpTest extends TestCase
{
<?php
-namespace Tests;
+namespace Tests\Meta;
+
+use Tests\TestCase;
class LicensesTest extends TestCase
{
<?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
{
<?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');
$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) . '"]');
}
<?php
-namespace Tests;
+namespace Tests\Meta;
+
+use Tests\TestCase;
class PwaManifestTest extends TestCase
{
--- /dev/null
+<?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: /");
+ }
+}
$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');