mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 08:12:15 +00:00
test groups refactoring
This commit is contained in:
194
tests/Domain/Settings/SettingsTest.php
Normal file
194
tests/Domain/Settings/SettingsTest.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Tests\Domain\Settings;
|
||||
|
||||
|
||||
use Domain\Settings\Models\Setting;
|
||||
use Domain\Settings\Models\User;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SettingsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_page_settings()
|
||||
{
|
||||
Setting::create([
|
||||
'name' => 'get_started_title',
|
||||
'value' => 'Hello World!',
|
||||
]);
|
||||
|
||||
Setting::create([
|
||||
'name' => 'pricing_description',
|
||||
'value' => 'Give me a money!',
|
||||
]);
|
||||
|
||||
$this->getJson('/api/content?column=get_started_title|pricing_description')
|
||||
->assertStatus(200)
|
||||
->assertExactJson([
|
||||
"get_started_title" => "Hello World!",
|
||||
"pricing_description" => "Give me a money!",
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_admin_settings()
|
||||
{
|
||||
$this->setup->seed_default_settings('Extended');
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson('/api/admin/settings?column=section_features|section_feature_boxes')
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'section_features' => '1',
|
||||
'section_feature_boxes' => '1',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_try_get_secured_settings_via_public_api()
|
||||
{
|
||||
Setting::create([
|
||||
'name' => 'purchase_code',
|
||||
'value' => '15a53561-d387-4e0a-8de1-5d1bff34c1ed',
|
||||
]);
|
||||
|
||||
$this->getJson('/api/content?column=purchase_code')
|
||||
->assertStatus(401);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_update_settings()
|
||||
{
|
||||
$this->setup->seed_default_settings('Extended');
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson('/api/admin/settings', [
|
||||
'name' => 'header_title',
|
||||
'value' => 'New Header Title'
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'value' => 'New Header Title'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_update_settings_image()
|
||||
{
|
||||
Setting::forceCreate([
|
||||
'name' => 'app_logo',
|
||||
'value' => null,
|
||||
]);
|
||||
|
||||
$logo = UploadedFile::fake()
|
||||
->image('fake-image.jpg');
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->patchJson('/api/admin/settings', [
|
||||
'name' => 'app_logo',
|
||||
'app_logo' => $logo
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseMissing('settings', [
|
||||
'app_logo' => null
|
||||
]);
|
||||
|
||||
Storage::assertExists(
|
||||
get_setting('app_logo')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_flush_cache()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->getJson('/api/admin/settings/flush-cache')
|
||||
->assertStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_set_stripe()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->postJson('/api/admin/settings/stripe', [
|
||||
'currency' => 'EUR',
|
||||
'key' => '123456789',
|
||||
'secret' => '123456789',
|
||||
'webhookSecret' => '123456789',
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'name' => 'stripe_currency',
|
||||
'value' => 'EUR',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'name' => 'payments_configured',
|
||||
'value' => 1,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('settings', [
|
||||
'name' => 'payments_active',
|
||||
'value' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_set_email()
|
||||
{
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
$this
|
||||
->actingAs($admin)
|
||||
->postJson('/api/admin/settings/email', [
|
||||
'driver' => 'smtp',
|
||||
'host' => 'smtp.email.com',
|
||||
'port' => 25,
|
||||
'username' => 'john@doe.com',
|
||||
'password' => 'secret',
|
||||
'encryption' => 'tls',
|
||||
])->assertStatus(204);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user