diff --git a/tests/Feature/ProjectApiTest.php b/tests/Feature/ProjectApiTest.php
index 3f2b6a5ad7..11e38a57cc 100644
--- a/tests/Feature/ProjectApiTest.php
+++ b/tests/Feature/ProjectApiTest.php
@@ -11,13 +11,16 @@
namespace Tests\Feature;
+use App\Models\Expense;
+use Tests\TestCase;
+use App\Models\Invoice;
+use App\Models\Quote;
+use Tests\MockAccountData;
use App\Utils\Traits\MakesHash;
use Illuminate\Database\Eloquent\Model;
-use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Session;
use Illuminate\Validation\ValidationException;
-use Tests\MockAccountData;
-use Tests\TestCase;
+use Illuminate\Foundation\Testing\DatabaseTransactions;
/**
* @test
@@ -44,6 +47,65 @@ class ProjectApiTest extends TestCase
Model::reguard();
}
+ public function testProjectIncludesZeroCount()
+ {
+
+ $response = $this->withHeaders([
+ 'X-API-SECRET' => config('ninja.api_secret'),
+ 'X-API-TOKEN' => $this->token,
+ ])->putJson("/api/v1/projects/{$this->project->hashed_id}?include=expenses,invoices,quotes");
+
+ $response->assertStatus(200);
+
+ $arr = $response->json();
+
+ $this->assertEquals(0, count($arr['data']['invoices']));
+ $this->assertEquals(0, count($arr['data']['expenses']));
+ $this->assertEquals(0, count($arr['data']['quotes']));
+
+ }
+
+ public function testProjectIncludes()
+ {
+ $i = Invoice::factory()->create([
+ 'user_id' => $this->user->id,
+ 'company_id' => $this->company->id,
+ 'client_id' => $this->project->client_id,
+ 'project_id' => $this->project->id,
+ ]);
+
+
+ $e = Expense::factory()->create([
+ 'user_id' => $this->user->id,
+ 'company_id' => $this->company->id,
+ 'client_id' => $this->project->client_id,
+ 'project_id' => $this->project->id,
+ ]);
+
+
+ $q = Quote::factory()->create([
+ 'user_id' => $this->user->id,
+ 'company_id' => $this->company->id,
+ 'client_id' => $this->project->client_id,
+ 'project_id' => $this->project->id,
+ ]);
+
+
+ $response = $this->withHeaders([
+ 'X-API-SECRET' => config('ninja.api_secret'),
+ 'X-API-TOKEN' => $this->token,
+ ])->putJson("/api/v1/projects/{$this->project->hashed_id}?include=expenses,invoices,quotes");
+
+ $response->assertStatus(200);
+
+ $arr = $response->json();
+
+ $this->assertEquals(1, count($arr['data']['invoices']));
+ $this->assertEquals(1, count($arr['data']['expenses']));
+ $this->assertEquals(1, count($arr['data']['quotes']));
+
+ }
+
public function testProjectValidationForBudgetedHoursPut()
{
diff --git a/tests/Feature/PurchaseOrderTest.php b/tests/Feature/PurchaseOrderTest.php
index b855933fda..7b48a45c64 100644
--- a/tests/Feature/PurchaseOrderTest.php
+++ b/tests/Feature/PurchaseOrderTest.php
@@ -46,6 +46,24 @@ class PurchaseOrderTest extends TestCase
$this->makeTestData();
}
+ public function testExpensePurchaseOrderConversion()
+ {
+
+ $p = PurchaseOrder::factory()->create([
+ 'user_id' => $this->user->id,
+ 'company_id' => $this->company->id,
+ 'vendor_id' => $this->vendor->id,
+ 'project_id' => $this->project->id,
+ ]);
+
+ $expense = $p->service()->expense();
+
+ $this->assertEquals($expense->project_id, $this->project->id);
+ $this->assertEquals($expense->client_id, $p->project->client_id);
+
+ }
+
+
public function testPurchaseOrderHistory()
{
event(new PurchaseOrderWasUpdated($this->purchase_order, $this->company, Ninja::eventVars($this->company, $this->user)));