mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-13 08:45:01 +00:00
added it_get_settings, it_flush_cache, it_set_stripe, it_set_email test
This commit is contained in:
@@ -76,11 +76,13 @@ class SettingController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function set_email(Request $request)
|
public function set_email(Request $request)
|
||||||
{
|
{
|
||||||
// Check if is demo
|
// TODO: pridat validator do requestu
|
||||||
if (env('APP_DEMO')) {
|
if (env('APP_DEMO')) {
|
||||||
return Demo::response_204();
|
return Demo::response_204();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!app()->runningUnitTests()) {
|
||||||
|
|
||||||
setEnvironmentValue([
|
setEnvironmentValue([
|
||||||
'MAIL_DRIVER' => $request->input('driver'),
|
'MAIL_DRIVER' => $request->input('driver'),
|
||||||
'MAIL_HOST' => $request->input('host'),
|
'MAIL_HOST' => $request->input('host'),
|
||||||
@@ -93,6 +95,7 @@ class SettingController extends Controller
|
|||||||
// Clear config cache
|
// Clear config cache
|
||||||
Artisan::call('config:clear');
|
Artisan::call('config:clear');
|
||||||
Artisan::call('config:cache');
|
Artisan::call('config:cache');
|
||||||
|
}
|
||||||
|
|
||||||
return response('Done', 204);
|
return response('Done', 204);
|
||||||
}
|
}
|
||||||
@@ -104,24 +107,27 @@ class SettingController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function set_stripe(Request $request)
|
public function set_stripe(Request $request)
|
||||||
{
|
{
|
||||||
// Get stripe status
|
// TODO: pridat validator do requestu
|
||||||
$is_stripe = get_setting('payments_configured');
|
// Check payment setup status
|
||||||
|
if (get_setting('payments_configured')) {
|
||||||
// Check setup status
|
abort(401, 'Gone');
|
||||||
if ($is_stripe) abort(401, 'Gone');
|
}
|
||||||
|
|
||||||
// Create stripe instance
|
|
||||||
$stripe = Stripe::make($request->secret, '2020-03-02');
|
|
||||||
|
|
||||||
// Try to get stripe account details
|
// Try to get stripe account details
|
||||||
try {
|
try {
|
||||||
$stripe->account()->details();
|
if (!app()->runningUnitTests()) {
|
||||||
|
|
||||||
|
Stripe::make($request->secret, '2020-03-02')
|
||||||
|
->account()
|
||||||
|
->details();
|
||||||
|
}
|
||||||
} catch (UnauthorizedException $e) {
|
} catch (UnauthorizedException $e) {
|
||||||
|
|
||||||
throw new HttpException(401, $e->getMessage());
|
throw new HttpException(401, $e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get options
|
// Get options
|
||||||
$settings = collect([
|
collect([
|
||||||
[
|
[
|
||||||
'name' => 'stripe_currency',
|
'name' => 'stripe_currency',
|
||||||
'value' => $request->currency,
|
'value' => $request->currency,
|
||||||
@@ -134,13 +140,15 @@ class SettingController extends Controller
|
|||||||
'name' => 'payments_active',
|
'name' => 'payments_active',
|
||||||
'value' => 1,
|
'value' => 1,
|
||||||
],
|
],
|
||||||
|
])->each(function ($col) {
|
||||||
|
Setting::forceCreate([
|
||||||
|
'name' => $col['name'],
|
||||||
|
'value' => $col['value'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Store options
|
|
||||||
$settings->each(function ($col) {
|
|
||||||
Setting::updateOrCreate(['name' => $col['name']], $col);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!app()->runningUnitTests()) {
|
||||||
|
|
||||||
// Set stripe credentials to .env
|
// Set stripe credentials to .env
|
||||||
setEnvironmentValue([
|
setEnvironmentValue([
|
||||||
'CASHIER_CURRENCY' => $request->currency,
|
'CASHIER_CURRENCY' => $request->currency,
|
||||||
@@ -154,4 +162,7 @@ class SettingController extends Controller
|
|||||||
Artisan::call('config:clear');
|
Artisan::call('config:clear');
|
||||||
Artisan::call('config:cache');
|
Artisan::call('config:cache');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return response('Done', 204);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -95,19 +95,19 @@ return [
|
|||||||
'extended' => [
|
'extended' => [
|
||||||
[
|
[
|
||||||
'name' => 'section_features',
|
'name' => 'section_features',
|
||||||
'value' => '1',
|
'value' => 1,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'section_feature_boxes',
|
'name' => 'section_feature_boxes',
|
||||||
'value' => '1',
|
'value' => 1,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'section_pricing_content',
|
'name' => 'section_pricing_content',
|
||||||
'value' => '1',
|
'value' => 1,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'section_get_started',
|
'name' => 'section_get_started',
|
||||||
'value' => '1',
|
'value' => 1,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'header_title',
|
'name' => 'header_title',
|
||||||
|
|||||||
@@ -4,14 +4,12 @@ namespace Tests\Feature;
|
|||||||
|
|
||||||
use App\Models\File;
|
use App\Models\File;
|
||||||
use App\Models\Folder;
|
use App\Models\Folder;
|
||||||
use App\Models\Page;
|
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Models\Share;
|
use App\Models\Share;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Zip;
|
use App\Models\Zip;
|
||||||
use App\Notifications\ResetPassword;
|
use App\Notifications\ResetPassword;
|
||||||
use App\Services\SetupService;
|
use App\Services\SetupService;
|
||||||
use Carbon\Carbon;
|
|
||||||
use DB;
|
use DB;
|
||||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
@@ -485,6 +483,21 @@ class AdminTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_get_settings()
|
||||||
|
{
|
||||||
|
$this->setup->seed_default_settings('Extended');
|
||||||
|
|
||||||
|
$this->getJson('/api/admin/settings?column=section_features|section_feature_boxes')
|
||||||
|
->assertStatus(200)
|
||||||
|
->assertJsonFragment([
|
||||||
|
'section_features' => '1',
|
||||||
|
'section_feature_boxes' => '1',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
@@ -541,4 +554,47 @@ class AdminTest extends TestCase
|
|||||||
$this->getJson('/api/admin/settings/flush-cache')
|
$this->getJson('/api/admin/settings/flush-cache')
|
||||||
->assertStatus(204);
|
->assertStatus(204);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_set_stripe()
|
||||||
|
{
|
||||||
|
$this->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()
|
||||||
|
{
|
||||||
|
$this->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