mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 05:37:17 -04:00
Fixes for tests
This commit is contained in:
parent
fc06feceb9
commit
42e7369c08
@ -12,9 +12,13 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Http\Requests\Company\CreateCompanyRequest;
|
use App\Http\Requests\Company\CreateCompanyRequest;
|
||||||
|
use App\Http\Requests\Company\ShowCompanyRequest;
|
||||||
use App\Http\Requests\SignupRequest;
|
use App\Http\Requests\SignupRequest;
|
||||||
use App\Jobs\Company\CreateCompany;
|
use App\Jobs\Company\CreateCompany;
|
||||||
use App\Jobs\RegisterNewAccount;
|
use App\Jobs\RegisterNewAccount;
|
||||||
|
use App\Models\Company;
|
||||||
|
use App\Transformers\CompanyTransformer;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
@ -27,6 +31,11 @@ use Illuminate\Support\Facades\Hash;
|
|||||||
class CompanyController extends BaseController
|
class CompanyController extends BaseController
|
||||||
{
|
{
|
||||||
use DispatchesJobs;
|
use DispatchesJobs;
|
||||||
|
use MakesHash;
|
||||||
|
|
||||||
|
protected $entity_type = Company::class;
|
||||||
|
|
||||||
|
protected $entity_transformer = CompanyTransformer::class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CompanyController constructor.
|
* CompanyController constructor.
|
||||||
@ -68,10 +77,9 @@ class CompanyController extends BaseController
|
|||||||
public function store(CreateCompanyRequest $request)
|
public function store(CreateCompanyRequest $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
CreateCompany::dispatchNow($request);
|
$company = CreateCompany::dispatchNow($request, auth()->user()->company()->account);
|
||||||
|
|
||||||
//todo redirect to localization setup workflow
|
return $this->itemResponse($company);
|
||||||
return redirect()->route('dashboard.index');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +89,7 @@ class CompanyController extends BaseController
|
|||||||
* @param int $id
|
* @param int $id
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function show($id)
|
public function show(ShowCompanyRequest $request, Company $company)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
41
app/Http/Requests/Company/CreateCompanyRequest.php
Normal file
41
app/Http/Requests/Company/CreateCompanyRequest.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Company;
|
||||||
|
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
use App\Models\Company;
|
||||||
|
|
||||||
|
class CreateCompanyRequest extends Request
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function authorize() : bool
|
||||||
|
{
|
||||||
|
|
||||||
|
return auth()->user()->can('create', Company::class);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
|
||||||
|
return [
|
||||||
|
'name' => 'required'
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
30
app/Http/Requests/Company/DestroyCompanyRequest
Normal file
30
app/Http/Requests/Company/DestroyCompanyRequest
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Company;
|
||||||
|
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
use App\Models\Company;
|
||||||
|
|
||||||
|
class DestroyCompanyRequest extends Request
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function authorize() : bool
|
||||||
|
{
|
||||||
|
return auth()->user()->can('edit', $this->company);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
49
app/Http/Requests/Company/EditCompanyRequest.php
Normal file
49
app/Http/Requests/Company/EditCompanyRequest.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Company;
|
||||||
|
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
use App\Models\Company;
|
||||||
|
|
||||||
|
class EditCompanyRequest extends Request
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return auth()->user()->can('edit', $this->company);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
$rules = [];
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function sanitize()
|
||||||
|
{
|
||||||
|
$input = $this->all();
|
||||||
|
|
||||||
|
//$input['id'] = $this->encodePrimaryKey($input['id']);
|
||||||
|
|
||||||
|
//$this->replace($input);
|
||||||
|
|
||||||
|
return $this->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
30
app/Http/Requests/Company/ShowCompanyRequest.php
Normal file
30
app/Http/Requests/Company/ShowCompanyRequest.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Company;
|
||||||
|
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
use App\Models\Company;
|
||||||
|
|
||||||
|
class ShowCompanyRequest extends Request
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function authorize() : bool
|
||||||
|
{
|
||||||
|
return auth()->user()->can('view', $this->company);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
43
app/Http/Requests/Company/StoreCompanyRequest.php
Normal file
43
app/Http/Requests/Company/StoreCompanyRequest.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Company;
|
||||||
|
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
use App\Models\ClientContact;
|
||||||
|
use App\Models\Company;
|
||||||
|
|
||||||
|
class StoreCompanyRequest extends Request
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function authorize() : bool
|
||||||
|
{
|
||||||
|
return auth()->user()->can('create', Company::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
//$this->sanitize();
|
||||||
|
|
||||||
|
return [
|
||||||
|
// 'client_id' => 'required',
|
||||||
|
// 'documents' => 'mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
41
app/Http/Requests/Company/UpdateCompanyRequest.php
Normal file
41
app/Http/Requests/Company/UpdateCompanyRequest.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://opensource.org/licenses/AAL
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Company;
|
||||||
|
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class UpdateCompanyRequest extends Request
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function authorize() : bool
|
||||||
|
{
|
||||||
|
|
||||||
|
return auth()->user()->can('edit', $this->company);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// 'documents' => 'mimes:png,ai,svg,jpeg,tiff,pdf,gif,psd,txt,doc,xls,ppt,xlsx,docx,pptx',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -33,10 +33,13 @@ class CreateCompany
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function __construct(array $request, $account = false)
|
public function __construct(array $request, $account)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
|
|
||||||
$this->account = $account;
|
$this->account = $account;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,7 +51,7 @@ class CreateCompany
|
|||||||
{
|
{
|
||||||
|
|
||||||
$company = new Company();
|
$company = new Company();
|
||||||
$company->name = $this->request['first_name'] . ' ' . $this->request['last_name'];
|
$company->name = $this->request['name'] ?: $this->request['first_name'] . ' ' . $this->request['last_name'];
|
||||||
$company->account_id = $this->account->id;
|
$company->account_id = $this->account->id;
|
||||||
$company->company_key = $this->createHash();
|
$company->company_key = $this->createHash();
|
||||||
$company->ip = request()->ip();
|
$company->ip = request()->ip();
|
||||||
|
@ -41,6 +41,7 @@ class AccountTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
|
'name' => $this->faker->company,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
@ -60,7 +61,8 @@ class AccountTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'name' => $this->faker->company,
|
||||||
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'privacy_policy' => 1,
|
'privacy_policy' => 1,
|
||||||
'terms_of_service' => 1
|
'terms_of_service' => 1
|
||||||
|
@ -46,7 +46,8 @@ class ClientTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'name' => $this->faker->company,
|
||||||
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
'privacy_policy' => 1,
|
'privacy_policy' => 1,
|
||||||
@ -86,7 +87,8 @@ class ClientTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'name' => $this->faker->company,
|
||||||
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
'privacy_policy' => 1,
|
'privacy_policy' => 1,
|
||||||
|
@ -46,7 +46,8 @@ class InvoiceTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'name' => $this->faker->company,
|
||||||
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
'privacy_policy' => 1,
|
'privacy_policy' => 1,
|
||||||
@ -109,6 +110,7 @@ class InvoiceTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
|
'name' => $this->faker->company,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
|
@ -46,7 +46,8 @@ class PaymentTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'name' => $this->faker->company,
|
||||||
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
'privacy_policy' => 1,
|
'privacy_policy' => 1,
|
||||||
@ -109,7 +110,8 @@ class PaymentTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'name' => $this->faker->company,
|
||||||
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
'privacy_policy' => 1,
|
'privacy_policy' => 1,
|
||||||
|
@ -44,7 +44,8 @@ class ProductTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'name' => $this->faker->company,
|
||||||
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
'privacy_policy' => 1,
|
'privacy_policy' => 1,
|
||||||
|
@ -46,7 +46,8 @@ class QuoteTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'name' => $this->faker->company,
|
||||||
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
'privacy_policy' => 1,
|
'privacy_policy' => 1,
|
||||||
@ -109,7 +110,8 @@ class QuoteTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'name' => $this->faker->company,
|
||||||
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
'privacy_policy' => 1,
|
'privacy_policy' => 1,
|
||||||
|
@ -46,7 +46,8 @@ class RecurringInvoiceTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'name' => $this->faker->company,
|
||||||
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
'privacy_policy' => 1,
|
'privacy_policy' => 1,
|
||||||
@ -109,7 +110,8 @@ class RecurringInvoiceTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'name' => $this->faker->company,
|
||||||
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
'privacy_policy' => 1,
|
'privacy_policy' => 1,
|
||||||
|
@ -46,7 +46,8 @@ class RecurringQuoteTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'name' => $this->faker->company,
|
||||||
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
'privacy_policy' => 1,
|
'privacy_policy' => 1,
|
||||||
@ -109,7 +110,8 @@ class RecurringQuoteTest extends TestCase
|
|||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->faker->firstName,
|
'first_name' => $this->faker->firstName,
|
||||||
'last_name' => $this->faker->lastName,
|
'last_name' => $this->faker->lastName,
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'name' => $this->faker->company,
|
||||||
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
'password' => 'ALongAndBrilliantPassword123',
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
'_token' => csrf_token(),
|
'_token' => csrf_token(),
|
||||||
'privacy_policy' => 1,
|
'privacy_policy' => 1,
|
||||||
|
81
tests/Feature/UserTest.php
Normal file
81
tests/Feature/UserTest.php
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
|
||||||
|
use App\Models\Account;
|
||||||
|
use App\Models\Activity;
|
||||||
|
use App\Models\Company;
|
||||||
|
use App\Models\CompanyLedger;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Foundation\Testing\Concerns\InteractsWithDatabase;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
use Tests\MockAccountData;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @covers App\Http\Controllers\UserController
|
||||||
|
*/
|
||||||
|
class UserTest extends TestCase
|
||||||
|
{
|
||||||
|
use MockAccountData;
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
public function setUp() :void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
Session::start();
|
||||||
|
|
||||||
|
$this->faker = \Faker\Factory::create();
|
||||||
|
|
||||||
|
Model::reguard();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUserList()
|
||||||
|
{
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'first_name' => $this->faker->firstName,
|
||||||
|
'last_name' => $this->faker->lastName,
|
||||||
|
'name' => $this->faker->company,
|
||||||
|
'email' => $this->faker->unique()->safeEmail,
|
||||||
|
'password' => 'ALongAndBrilliantPassword123',
|
||||||
|
'_token' => csrf_token(),
|
||||||
|
'privacy_policy' => 1,
|
||||||
|
'terms_of_service' => 1
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
])->post('/api/v1/signup', $data);
|
||||||
|
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
|
||||||
|
$acc = $response->json();
|
||||||
|
|
||||||
|
|
||||||
|
$account = Account::find($this->decodePrimaryKey($acc['data']['id']));
|
||||||
|
|
||||||
|
$token = $account->default_company->tokens->first()->token;
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $token,
|
||||||
|
])->get('/api/v1/users');
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user