mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-04-22 03:51:06 +00:00
Covered app icon setting with testing
This commit is contained in:
parent
3c658e39ab
commit
a50b0ea1e5
1 changed files with 46 additions and 0 deletions
|
@ -2,10 +2,14 @@
|
||||||
|
|
||||||
namespace Tests\Settings;
|
namespace Tests\Settings;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
use Tests\Uploads\UsesImages;
|
||||||
|
|
||||||
class SettingsTest extends TestCase
|
class SettingsTest extends TestCase
|
||||||
{
|
{
|
||||||
|
use UsesImages;
|
||||||
|
|
||||||
public function test_settings_endpoint_redirects_to_settings_view()
|
public function test_settings_endpoint_redirects_to_settings_view()
|
||||||
{
|
{
|
||||||
$resp = $this->asAdmin()->get('/settings');
|
$resp = $this->asAdmin()->get('/settings');
|
||||||
|
@ -40,4 +44,46 @@ class SettingsTest extends TestCase
|
||||||
$resp->assertStatus(404);
|
$resp->assertStatus(404);
|
||||||
$resp->assertSee('Page Not Found');
|
$resp->assertSee('Page Not Found');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_updating_and_removing_app_icon()
|
||||||
|
{
|
||||||
|
$this->asAdmin();
|
||||||
|
$galleryFile = $this->getTestImage('my-app-icon.png');
|
||||||
|
$expectedPath = public_path('uploads/images/system/' . date('Y-m') . '/my-app-icon.png');
|
||||||
|
|
||||||
|
$this->assertFalse(setting()->get('app-icon'));
|
||||||
|
$this->assertFalse(setting()->get('app-icon-180'));
|
||||||
|
$this->assertFalse(setting()->get('app-icon-128'));
|
||||||
|
$this->assertFalse(setting()->get('app-icon-64'));
|
||||||
|
$this->assertFalse(setting()->get('app-icon-32'));
|
||||||
|
|
||||||
|
$prevFileCount = count(glob(dirname($expectedPath) . DIRECTORY_SEPARATOR . '*.png'));
|
||||||
|
|
||||||
|
$upload = $this->call('POST', '/settings/customization', [], [], ['app_icon' => $galleryFile], []);
|
||||||
|
$upload->assertRedirect('/settings/customization');
|
||||||
|
|
||||||
|
$this->assertTrue(file_exists($expectedPath), 'Uploaded image not found at path: ' . $expectedPath);
|
||||||
|
$this->assertStringContainsString('my-app-icon', setting()->get('app-icon'));
|
||||||
|
$this->assertStringContainsString('my-app-icon', setting()->get('app-icon-180'));
|
||||||
|
$this->assertStringContainsString('my-app-icon', setting()->get('app-icon-128'));
|
||||||
|
$this->assertStringContainsString('my-app-icon', setting()->get('app-icon-64'));
|
||||||
|
$this->assertStringContainsString('my-app-icon', setting()->get('app-icon-32'));
|
||||||
|
|
||||||
|
$newFileCount = count(glob(dirname($expectedPath) . DIRECTORY_SEPARATOR . '*.png'));
|
||||||
|
$this->assertEquals(5, $newFileCount - $prevFileCount);
|
||||||
|
|
||||||
|
$resp = $this->get('/');
|
||||||
|
$this->withHtml($resp)->assertElementCount('link[sizes][href*="my-app-icon"]', 6);
|
||||||
|
|
||||||
|
$reset = $this->post('/settings/customization', ['app_icon_reset' => 'true']);
|
||||||
|
$reset->assertRedirect('/settings/customization');
|
||||||
|
|
||||||
|
$resetFileCount = count(glob(dirname($expectedPath) . DIRECTORY_SEPARATOR . '*.png'));
|
||||||
|
$this->assertEquals($prevFileCount, $resetFileCount);
|
||||||
|
$this->assertFalse(setting()->get('app-icon'));
|
||||||
|
$this->assertFalse(setting()->get('app-icon-180'));
|
||||||
|
$this->assertFalse(setting()->get('app-icon-128'));
|
||||||
|
$this->assertFalse(setting()->get('app-icon-64'));
|
||||||
|
$this->assertFalse(setting()->get('app-icon-32'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue