Test for new shop routes"

This commit is contained in:
David Bomba 2020-08-05 12:21:26 +10:00
parent e183238b8e
commit 13cf06b0cd
3 changed files with 54 additions and 1 deletions

View File

@ -29,7 +29,7 @@ class ProfileController extends BaseController
protected $entity_transformer = CompanyShopProfileTransformer::class;
public function show(Request $request, string $product_key)
public function show(Request $request)
{
$company = Company::where('company_key', $request->header('X-API-COMPANY-KEY'))->first();

View File

@ -36,6 +36,7 @@ use App\Transformers\CompanyLedgerTransformer;
use App\Transformers\CompanyTokenHashedTransformer;
use App\Transformers\CompanyTokenTransformer;
use App\Transformers\CreditTransformer;
use App\Transformers\EntityTransformer;
use App\Transformers\PaymentTermTransformer;
use App\Transformers\TaskTransformer;
use App\Transformers\WebhookTransformer;

View File

@ -0,0 +1,52 @@
<?php
namespace Tests\Unit\Shop;
use App\Factory\InvoiceFactory;
use App\Factory\InvoiceItemFactory;
use App\Helpers\Invoice\InvoiceSum;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\MockAccountData;
use Tests\TestCase;
/**
* @test
* @covers \App\Http\Controllers\Shop\ProfileController
*/
class ShopProfileTest extends TestCase
{
use MockAccountData;
use DatabaseTransactions;
public function setUp() :void
{
parent::setUp();
$this->makeTestData();
}
public function testProfileDisplays()
{
$this->company->enable_shop_api = true;
$this->company->save();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-COMPANY-KEY' => $this->company->company_key
])->get('/api/v1/shop/profile');
$response->assertStatus(200);
$arr = $response->json();
$this->assertArrayHasKey('custom_value1', $arr['data']['settings']);
$this->assertEquals($this->company->company_key, $arr['data']['company_key']);
}
}