mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-06 02:33:48 +00:00
added it_get_non_existed_user_subscription, it_get_user_invoices_from_admin test
This commit is contained in:
@@ -15,7 +15,7 @@ class InvoiceResource extends JsonResource
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$user = User::where('stripe_id', $this->customer)
|
||||
$user = User::whereStripeId($this->customer)
|
||||
->first();
|
||||
|
||||
return [
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Tests\Feature;
|
||||
use App\Models\File;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
use DB;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
@@ -122,6 +123,24 @@ class AdminTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_non_existed_user_subscription()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create();
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->getJson("/api/admin/users/$user->id/subscription")
|
||||
->assertStatus(404);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
||||
@@ -3,13 +3,8 @@
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\UserSettings;
|
||||
use App\Services\StripeService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Laravel\Cashier\Subscription;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
use Tests\TestCase;
|
||||
|
||||
@@ -276,4 +271,26 @@ class SubscriptionTest extends TestCase
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_get_user_invoices_from_admin()
|
||||
{
|
||||
$user = User::factory(User::class)
|
||||
->create($this->user);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$admin = User::factory(User::class)
|
||||
->create(['role' => 'admin']);
|
||||
|
||||
Sanctum::actingAs($admin);
|
||||
|
||||
$this->getJson("/api/admin/users/$user->id/invoices")
|
||||
->assertStatus(200)
|
||||
->assertJsonFragment([
|
||||
'customer' => $this->user['stripe_id']
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user