mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 22:14:36 -04:00
Company TestS
This commit is contained in:
parent
54cf2fec6f
commit
2ddb9ddde3
@ -91,7 +91,7 @@ class CompanyController extends BaseController
|
|||||||
public function store(StoreCompanyRequest $request)
|
public function store(StoreCompanyRequest $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$company = CreateCompany::dispatchNow($request, auth()->user()->company()->account);
|
$company = CreateCompany::dispatchNow($request->all(), auth()->user()->company()->account);
|
||||||
|
|
||||||
return $this->itemResponse($company);
|
return $this->itemResponse($company);
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
|
use App\Models\Company;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Payment;
|
use App\Models\Payment;
|
||||||
use App\Models\Product;
|
use App\Models\Product;
|
||||||
@ -20,6 +21,7 @@ use App\Models\RecurringInvoice;
|
|||||||
use App\Models\RecurringQuote;
|
use App\Models\RecurringQuote;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Policies\ClientPolicy;
|
use App\Policies\ClientPolicy;
|
||||||
|
use App\Policies\CompanyPolicy;
|
||||||
use App\Policies\InvoicePolicy;
|
use App\Policies\InvoicePolicy;
|
||||||
use App\Policies\PaymentPolicy;
|
use App\Policies\PaymentPolicy;
|
||||||
use App\Policies\ProductPolicy;
|
use App\Policies\ProductPolicy;
|
||||||
@ -40,6 +42,7 @@ class AuthServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
protected $policies = [
|
protected $policies = [
|
||||||
Client::class => ClientPolicy::class,
|
Client::class => ClientPolicy::class,
|
||||||
|
Company::class => CompanyPolicy::class,
|
||||||
Product::class => ProductPolicy::class,
|
Product::class => ProductPolicy::class,
|
||||||
Invoice::class => InvoicePolicy::class,
|
Invoice::class => InvoicePolicy::class,
|
||||||
Payment::class => PaymentPolicy::class,
|
Payment::class => PaymentPolicy::class,
|
||||||
|
@ -81,6 +81,10 @@ class RouteServiceProvider extends ServiceProvider
|
|||||||
return \App\Models\Company::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
return \App\Models\Company::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::bind('companies', function ($value) {
|
||||||
|
return \App\Models\Company::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
||||||
|
});
|
||||||
|
|
||||||
Route::bind('account', function ($value) {
|
Route::bind('account', function ($value) {
|
||||||
return \App\Models\Account::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
return \App\Models\Account::withTrashed()->where('id', $this->decodePrimaryKey($value))->firstOrFail();
|
||||||
});
|
});
|
||||||
|
@ -70,7 +70,7 @@ class CompanyTest extends TestCase
|
|||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
'X-API-TOKEN' => $token,
|
'X-API-TOKEN' => $token,
|
||||||
])->get('/api/v1/copmanies');
|
])->get('/api/v1/companies');
|
||||||
|
|
||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
|
|
||||||
@ -83,25 +83,28 @@ class CompanyTest extends TestCase
|
|||||||
'name' => 'A New Company'
|
'name' => 'A New Company'
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
->assertStatus(200);
|
->assertStatus(200)->decodeResponseJson();
|
||||||
|
|
||||||
$product = Product::all()->first();
|
$company = Company::find($this->decodePrimaryKey($response['data']['id']));
|
||||||
|
|
||||||
|
Log::error('coco');
|
||||||
|
Log::error($company);
|
||||||
|
|
||||||
$product_update = [
|
$company_update = [
|
||||||
'notes' => 'CHANGE'
|
'name' => 'CHANGE NAME'
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
'X-API-TOKEN' => $token,
|
'X-API-TOKEN' => $token,
|
||||||
])->put('/api/v1/products/'.$this->encodePrimaryKey($product->id), $product_update)
|
])->put('/api/v1/companies/'.$this->encodePrimaryKey($company->id), $company_update)
|
||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
|
|
||||||
|
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
'X-API-SECRET' => config('ninja.api_secret'),
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
'X-API-TOKEN' => $token,
|
'X-API-TOKEN' => $token,
|
||||||
])->delete('/api/v1/products/'.$this->encodePrimaryKey($product->id))
|
])->delete('/api/v1/companies/'.$this->encodePrimaryKey($company->id))
|
||||||
->assertStatus(200);
|
->assertStatus(200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user