Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/SkusTest.php
<?php | <?php | ||||
namespace Tests\Feature\Controller; | namespace Tests\Feature\Controller; | ||||
use App\Entitlement; | use App\Entitlement; | ||||
use App\Http\Controllers\API\V4\SkusController; | use App\Http\Controllers\API\V4\SkusController; | ||||
use App\Sku; | use App\Sku; | ||||
use App\Tenant; | |||||
use Tests\TestCase; | use Tests\TestCase; | ||||
class SkusTest extends TestCase | class SkusTest extends TestCase | ||||
{ | { | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function setUp(): void | public function setUp(): void | ||||
Show All 34 Lines | public function testIndex(): void | ||||
$nsku = Sku::create([ | $nsku = Sku::create([ | ||||
'title' => 'test', | 'title' => 'test', | ||||
'name' => 'Test', | 'name' => 'Test', | ||||
'description' => '', | 'description' => '', | ||||
'active' => true, | 'active' => true, | ||||
'cost' => 100, | 'cost' => 100, | ||||
'handler_class' => 'App\Handlers\Mailbox', | 'handler_class' => 'App\Handlers\Mailbox', | ||||
]); | ]); | ||||
$nsku->tenant_id = 2; | $tenant = Tenant::whereNotIn('id', [\config('app.tenant_id')])->first(); | ||||
$nsku->tenant_id = $tenant->id; | |||||
machniak: The intention of this tests (and most of other you modified) was to use non default tenant. I.e. | |||||
$nsku->save(); | $nsku->save(); | ||||
$response = $this->actingAs($user)->get("api/v4/skus"); | $response = $this->actingAs($user)->get("api/v4/skus"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(9, $json); | $this->assertCount(9, $json); | ||||
Show All 26 Lines | public function testUserSkus(): void | ||||
$nsku = Sku::create([ | $nsku = Sku::create([ | ||||
'title' => 'test', | 'title' => 'test', | ||||
'name' => 'Test', | 'name' => 'Test', | ||||
'description' => '', | 'description' => '', | ||||
'active' => true, | 'active' => true, | ||||
'cost' => 100, | 'cost' => 100, | ||||
'handler_class' => 'App\Handlers\Mailbox', | 'handler_class' => 'App\Handlers\Mailbox', | ||||
]); | ]); | ||||
$nsku->tenant_id = 2; | $tenant = Tenant::whereNotIn('id', [\config('app.tenant_id')])->first(); | ||||
$nsku->tenant_id = $tenant->id; | |||||
$nsku->save(); | $nsku->save(); | ||||
$response = $this->actingAs($user)->get("api/v4/users/{$user->id}/skus"); | $response = $this->actingAs($user)->get("api/v4/users/{$user->id}/skus"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(8, $json); | $this->assertCount(8, $json); | ||||
▲ Show 20 Lines • Show All 137 Lines • Show Last 20 Lines |
The intention of this tests (and most of other you modified) was to use non default tenant. I.e. something like Tenant::whereNotIn('id', [\config('app.tenant_id')])->first() might be more appropriate.