mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 06:54:36 -04:00
Tests for shop route
This commit is contained in:
parent
0c7a2cd776
commit
089ededb7f
@ -7,6 +7,7 @@ use App\Models\CompanyToken;
|
|||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
use Tests\MockAccountData;
|
use Tests\MockAccountData;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
@ -37,21 +38,34 @@ class ShopInvoiceTest extends TestCase
|
|||||||
$this->withoutExceptionHandling();
|
$this->withoutExceptionHandling();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTokenFailure()
|
public function testTokenSuccess()
|
||||||
{
|
{
|
||||||
|
$this->company->enable_shop_api = true;
|
||||||
|
$this->company->save();
|
||||||
|
|
||||||
|
$response = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
'X-API-COMPANY-KEY' => $this->company->company_key
|
'X-API-COMPANY-KEY' => $this->company->company_key
|
||||||
])->get('/api/v1/shop/products');
|
])->get('api/v1/shop/products');
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (ValidationException $e) {
|
||||||
|
$this->assertNotNull($message);
|
||||||
|
}
|
||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTokenSuccess()
|
public function testTokenFailure()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$this->company->enable_shop_api = true;
|
||||||
|
$this->company->save();
|
||||||
|
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
'X-API-COMPANY-KEY' => $this->company->company_key
|
'X-API-COMPANY-KEY' => $this->company->company_key
|
||||||
@ -63,8 +77,29 @@ class ShopInvoiceTest extends TestCase
|
|||||||
$arr = $response->json();
|
$arr = $response->json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCompanyEnableShopApiBooleanWorks()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-COMPANY-KEY' => $this->company->company_key
|
||||||
|
])->get('api/v1/shop/products');
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (ValidationException $e) {
|
||||||
|
$this->assertNotNull($message);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response->assertStatus(403);
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetByProductKey()
|
public function testGetByProductKey()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$this->company->enable_shop_api = true;
|
||||||
|
$this->company->save();
|
||||||
|
|
||||||
$product = factory(\App\Models\Product::class)->create([
|
$product = factory(\App\Models\Product::class)->create([
|
||||||
'user_id' => $this->user->id,
|
'user_id' => $this->user->id,
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
@ -86,6 +121,9 @@ class ShopInvoiceTest extends TestCase
|
|||||||
public function testGetByClientByContactKey()
|
public function testGetByClientByContactKey()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$this->company->enable_shop_api = true;
|
||||||
|
$this->company->save();
|
||||||
|
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
'X-API-COMPANY-KEY' => $this->company->company_key
|
'X-API-COMPANY-KEY' => $this->company->company_key
|
||||||
|
Loading…
x
Reference in New Issue
Block a user