mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-22 10:52:30 +01:00
Tests: Categorised up meta tests
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.
This commit is contained in:
parent
2f74cfb42c
commit
514db60617
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
namespace Tests\Meta;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class HelpTest extends TestCase
|
||||
{
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
namespace Tests\Meta;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class LicensesTest extends TestCase
|
||||
{
|
@ -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
|
||||
{
|
@ -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) . '"]');
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
namespace Tests\Meta;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class PwaManifestTest extends TestCase
|
||||
{
|
35
tests/Meta/RobotsTest.php
Normal file
35
tests/Meta/RobotsTest.php
Normal file
@ -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: /");
|
||||
}
|
||||
}
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user