mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Fixes for user events
This commit is contained in:
parent
29038a16fa
commit
8b22fa5a47
@ -175,7 +175,7 @@ class PaymentController extends Controller
|
||||
|
||||
foreach($payable_invoices as $payable_invoice)
|
||||
{
|
||||
nlog($payable_invoice);
|
||||
// nlog($payable_invoice);
|
||||
|
||||
$payable_invoice['amount'] = Number::parseFloat($payable_invoice['amount']);
|
||||
|
||||
|
@ -174,7 +174,7 @@ class TaskStatusController extends BaseController
|
||||
*/
|
||||
public function store(StoreTaskStatusRequest $request)
|
||||
{
|
||||
nlog($request->all());
|
||||
// nlog($request->all());
|
||||
|
||||
$task_status = TaskStatusFactory::create(auth()->user()->company()->id, auth()->user()->id);
|
||||
$task_status->fill($request->all());
|
||||
|
@ -60,7 +60,7 @@ class EntitySentObject
|
||||
|
||||
private function setTemplate()
|
||||
{
|
||||
nlog($this->template);
|
||||
// nlog($this->template);
|
||||
|
||||
switch ($this->template) {
|
||||
case 'invoice':
|
||||
|
@ -184,8 +184,8 @@ class InvoiceTest extends TestCase
|
||||
->assertStatus(302);
|
||||
} catch (ValidationException $e) {
|
||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||
nlog('inside update invoice validator');
|
||||
nlog($message);
|
||||
// nlog('inside update invoice validator');
|
||||
// nlog($message);
|
||||
$this->assertNotNull($message);
|
||||
}
|
||||
|
||||
|
@ -46,14 +46,23 @@ use App\Events\Task\TaskWasCreated;
|
||||
use App\Events\Task\TaskWasDeleted;
|
||||
use App\Events\Task\TaskWasRestored;
|
||||
use App\Events\Task\TaskWasUpdated;
|
||||
use App\Events\User\UserWasArchived;
|
||||
use App\Events\User\UserWasCreated;
|
||||
use App\Events\User\UserWasDeleted;
|
||||
use App\Events\User\UserWasRestored;
|
||||
use App\Events\User\UserWasUpdated;
|
||||
use App\Events\Vendor\VendorWasArchived;
|
||||
use App\Events\Vendor\VendorWasCreated;
|
||||
use App\Events\Vendor\VendorWasDeleted;
|
||||
use App\Events\Vendor\VendorWasRestored;
|
||||
use App\Events\Vendor\VendorWasUpdated;
|
||||
use App\Http\Middleware\PasswordProtection;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\Quote;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||
use Tests\MockAccountData;
|
||||
use Tests\TestCase;
|
||||
|
||||
@ -64,6 +73,7 @@ class EventTest extends TestCase
|
||||
{
|
||||
use MockAccountData;
|
||||
use MakesHash;
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function setUp() :void
|
||||
{
|
||||
@ -72,6 +82,13 @@ class EventTest extends TestCase
|
||||
$this->faker = \Faker\Factory::create();
|
||||
|
||||
$this->makeTestData();
|
||||
|
||||
Model::reguard();
|
||||
|
||||
$this->withoutMiddleware(
|
||||
ThrottleRequests::class,
|
||||
PasswordProtection::class
|
||||
);
|
||||
}
|
||||
|
||||
public function testExpenseEvents()
|
||||
@ -134,6 +151,7 @@ class EventTest extends TestCase
|
||||
|
||||
public function testVendorEvents()
|
||||
{
|
||||
|
||||
$this->expectsEvents([
|
||||
VendorWasCreated::class,
|
||||
VendorWasUpdated::class,
|
||||
@ -456,7 +474,6 @@ class EventTest extends TestCase
|
||||
|
||||
public function testInvoiceEvents()
|
||||
{
|
||||
|
||||
/* Test fire new invoice */
|
||||
$data = [
|
||||
'client_id' => $this->client->hashed_id,
|
||||
@ -573,4 +590,85 @@ class EventTest extends TestCase
|
||||
])->post('/api/v1/clients/bulk?action=delete', $data)
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
|
||||
public function testUserEvents()
|
||||
{
|
||||
$this->withoutMiddleware(PasswordProtection::class);
|
||||
|
||||
|
||||
$this->expectsEvents([
|
||||
UserWasCreated::class,
|
||||
UserWasUpdated::class,
|
||||
UserWasArchived::class,
|
||||
UserWasRestored::class,
|
||||
UserWasDeleted::class,
|
||||
]);
|
||||
|
||||
$data = [
|
||||
'first_name' => 'hey',
|
||||
'last_name' => 'you',
|
||||
'email' => 'bob1@good.ole.boys.com',
|
||||
'company_user' => [
|
||||
'is_admin' => false,
|
||||
'is_owner' => false,
|
||||
'permissions' => 'create_client,create_invoice',
|
||||
],
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||
])->post('/api/v1/users?include=company_user', $data)
|
||||
->assertStatus(200);
|
||||
|
||||
$arr = $response->json();
|
||||
|
||||
$data = [
|
||||
'first_name' => 'hasdasdy',
|
||||
'last_name' => 'you',
|
||||
'email' => 'bob1@good.ole.boys.com',
|
||||
'company_user' => [
|
||||
'is_admin' => false,
|
||||
'is_owner' => false,
|
||||
'permissions' => 'create_client,create_invoice',
|
||||
],
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||
])->put('/api/v1/users/' . $arr['data']['id'], $data)
|
||||
->assertStatus(200);
|
||||
|
||||
|
||||
$data = [
|
||||
'ids' => [$arr['data']['id']],
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||
])->post('/api/v1/users/bulk?action=archive', $data)
|
||||
->assertStatus(200);
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||
])->post('/api/v1/users/bulk?action=restore', $data)
|
||||
->assertStatus(200);
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
'X-API-PASSWORD' => 'ALongAndBriliantPassword',
|
||||
])->post('/api/v1/users/bulk?action=delete', $data)
|
||||
->assertStatus(200);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -189,6 +189,7 @@ trait MockAccountData
|
||||
$this->user = User::factory()->create([
|
||||
'account_id' => $this->account->id,
|
||||
'confirmation_code' => $this->createDbHash(config('database.default')),
|
||||
'email' => 'user@example.com',
|
||||
]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user