mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 16:22:14 +00:00
- redirect after sign in/up to payment page
- extended /api/oasis/subscribe function - setup:dev extended data
This commit is contained in:
@@ -5,9 +5,11 @@ namespace Tests\Feature\Oasis;
|
||||
use App\Models\User;
|
||||
use App\Notifications\Oasis\PaymentRequiredNotification;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Notification;
|
||||
use Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
class OasisAdminTest extends TestCase
|
||||
@@ -64,7 +66,7 @@ class OasisAdminTest extends TestCase
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_register_new_client_from_admin_panel()
|
||||
public function it_create_client_order()
|
||||
{
|
||||
Notification::fake();
|
||||
|
||||
@@ -73,7 +75,7 @@ class OasisAdminTest extends TestCase
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->postJson('/api/oasis/admin/users/create', [
|
||||
$this->postJson('/api/oasis/admin/users/create-order', [
|
||||
'ico' => '08995281',
|
||||
'name' => 'GDPR Cloud Solution, s.r.o.',
|
||||
'email' => 'john@doe.com',
|
||||
@@ -107,4 +109,44 @@ class OasisAdminTest extends TestCase
|
||||
|
||||
Notification::assertSentTo($newbie, PaymentRequiredNotification::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_create_new_user_with_avatar()
|
||||
{
|
||||
Storage::fake('local');
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$avatar = UploadedFile::fake()
|
||||
->image('fake-image.jpg');
|
||||
|
||||
$this->postJson("/api/oasis/admin/users/create-user", [
|
||||
'name' => 'John Doe',
|
||||
'role' => 'user',
|
||||
'email' => 'john@doe.com',
|
||||
'password' => 'VerySecretPassword',
|
||||
'storage_capacity' => 15,
|
||||
'password_confirmation' => 'VerySecretPassword',
|
||||
'avatar' => $avatar,
|
||||
])->assertStatus(201);
|
||||
|
||||
$this->assertDatabaseHas('users', [
|
||||
'email' => 'john@doe.com'
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('user_settings', [
|
||||
'name' => 'John Doe',
|
||||
'payment_activation' => 1,
|
||||
]);
|
||||
|
||||
Storage::disk('local')
|
||||
->assertExists(
|
||||
User::whereEmail('john@doe.com')->first()->settings->getRawOriginal('avatar')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Services\Oasis\OasisService;
|
||||
use Carbon\Carbon;
|
||||
use Cartalyst\Stripe\Stripe;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Notification;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -87,7 +88,7 @@ class OasisSubscriptionTest extends TestCase
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_subscribe_user_and_pay_for_it()
|
||||
public function it_subscribe_user_from_subscription_request()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create(['role' => 'user']);
|
||||
@@ -145,6 +146,67 @@ class OasisSubscriptionTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_subscribe_user_after_signup()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create(['role' => 'user']);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
// Register payment method
|
||||
$stripe = Stripe::make(config('cashier.secret'), '2020-03-02');
|
||||
|
||||
// Create test payment method
|
||||
$paymentMethod = $stripe->paymentMethods()->create([
|
||||
'type' => 'card',
|
||||
'card' => [
|
||||
'number' => '4242424242424242',
|
||||
'exp_month' => 11,
|
||||
'exp_year' => 2022,
|
||||
'cvc' => '123'
|
||||
],
|
||||
]);
|
||||
|
||||
// Create stripe customer
|
||||
$user->createOrGetStripeCustomer();
|
||||
|
||||
$this->postJson("/api/oasis/subscribe", [
|
||||
'plan' => $this->plan,
|
||||
'billing' => [
|
||||
'billing_address' => '2794 Alfreda Mount Suite 467 East Crystalberg',
|
||||
'billing_city' => 'Christianfort',
|
||||
'billing_country' => 'SK',
|
||||
'billing_name' => 'Heidi Romaguera PhD',
|
||||
'billing_phone_number' => '+421',
|
||||
'billing_postal_code' => '59445',
|
||||
'billing_state' => 'SK',
|
||||
],
|
||||
'payment' => [
|
||||
'type' => 'stripe',
|
||||
'meta' => [
|
||||
'pm' => $paymentMethod['id']
|
||||
],
|
||||
],
|
||||
])->assertStatus(204);
|
||||
|
||||
$this->assertDatabaseHas('subscriptions', [
|
||||
'stripe_status' => 'active'
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('user_settings', [
|
||||
'storage_capacity' => 50,
|
||||
'payment_activation' => 1,
|
||||
]);
|
||||
|
||||
$this->assertDatabaseMissing('users', [
|
||||
'stripe_id' => null,
|
||||
'card_brand' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user