Updates tests so they use space_id key for sessions instead of space
MODIFY
tests/Feature/CreateEarningTest.php
tests/Feature/CreateEarningTest.php
@@ -26,7 +26,7 @@ class CreateEarningTest extends TestCase
$response = $this
->followingRedirects()
->actingAs($this->user)
- ->withSession(['space' => $this->space])
+ ->withSession(['space_id' => $this->space->id])
->postJson('/earnings', [
'date' => date('Y-m-d'),
'description' => 'Something for the test',
@@ -42,7 +42,7 @@ class CreateEarningTest extends TestCase
$response = $this
->followingRedirects()
->actingAs($this->user)
- ->withSession(['space' => $this->space])
+ ->withSession(['space_id' => $this->space->id])
->postJson('/earnings', [
'date' => date('Y-m-d'),
'description' => 'Something for the test',

MODIFY
tests/Feature/CreateSpendingTest.php
tests/Feature/CreateSpendingTest.php
@@ -26,7 +26,7 @@ class CreateSpendingTest extends TestCase
$response = $this
->followingRedirects()
->actingAs($this->user)
- ->withSession(['space' => $this->space])
+ ->withSession(['space_id' => $this->space->id])
->postJson('/spendings', [
'date' => date('Y-m-d'),
'description' => 'Something for the test',
@@ -42,7 +42,7 @@ class CreateSpendingTest extends TestCase
$response = $this
->followingRedirects()
->actingAs($this->user)
- ->withSession(['space' => $this->space])
+ ->withSession(['space_id' => $this->space->id])
->postJson('/spendings', [
'date' => date('Y-m-d'),
'description' => 'Something for the test',

MODIFY
tests/Feature/DashboardTest.php
tests/Feature/DashboardTest.php
@@ -19,7 +19,7 @@ class DashboardTest extends TestCase
$response = $this
->actingAs($user)
- ->withSession(['space' => $space])
+ ->withSession(['space_id' => $space->id])
->get('/dashboard');
$response
@@ -54,7 +54,7 @@ class DashboardTest extends TestCase
$response = $this
->actingAs($user)
- ->withSession(['space' => $space])
+ ->withSession(['space_id' => $space->id])
->get('/dashboard');
$response

MODIFY
tests/Feature/RecurringTest.php
tests/Feature/RecurringTest.php
@@ -45,7 +45,7 @@ class RecurringTest extends TestCase
];
$response = $this->actingAs($user)
- ->withSession(['space' => $space])
+ ->withSession(['space_id' => $space->id])
->postJson('/recurrings', $requestData);
$response->assertStatus(302);

MODIFY
tests/Unit/Repositories/BudgetRepositoryTest.php
tests/Unit/Repositories/BudgetRepositoryTest.php
@@ -83,7 +83,7 @@ class BudgetRepositoryTest extends TestCase
{
$space = factory(Space::class)->create(['id' => 200]);
- $this->withSession(['space' => (object) ['id' => $space->id]]);
+ $this->withSession(['space_id' => $space->id]);
$this->assertEmpty($this->budgetRepository->getActive());
}
@@ -98,7 +98,7 @@ class BudgetRepositoryTest extends TestCase
'ends_on' => date('Y-m-d', strtotime('last day of last month'))
]);
- $this->withSession(['space' => (object) ['id' => 200]]);
+ $this->withSession(['space_id' => 200]);
$this->assertEmpty($this->budgetRepository->getActive());
}
@@ -112,7 +112,7 @@ class BudgetRepositoryTest extends TestCase
'starts_on' => date('Y-m-d', strtotime('first day of this month'))
]);
- $this->withSession(['space' => (object) ['id' => 200]]);
+ $this->withSession(['space_id' => 200]);
$this->assertCount(1, $this->budgetRepository->getActive());
}
@@ -164,7 +164,7 @@ class BudgetRepositoryTest extends TestCase
public function testGetSpentByIdUsingFreshBudget(): void
{
- $this->withSession(['space' => (object) ['id' => 1]]);
+ $this->withSession(['space_id' => 1]);
$budget = factory(Budget::class)->create([
'space_id' => 1,
@@ -177,7 +177,7 @@ class BudgetRepositoryTest extends TestCase
public function testGetSpentByIdUsingYearlyBudget(): void
{
- $this->withSession(['space' => (object) ['id' => $this->spaceId]]);
+ $this->withSession(['space_id' => $this->spaceId]);
$tag = factory(Tag::class)->create(['space_id' => $this->spaceId]);
@@ -213,7 +213,7 @@ class BudgetRepositoryTest extends TestCase
public function testGetSpentByIdUsingMonthlyBudget(): void
{
- $this->withSession(['space' => (object) ['id' => $this->spaceId]]);
+ $this->withSession(['space_id' => $this->spaceId]);
$tag = factory(Tag::class)->create(['space_id' => $this->spaceId]);
@@ -249,7 +249,7 @@ class BudgetRepositoryTest extends TestCase
public function testGetSpentByIdUsingWeeklyBudget(): void
{
- $this->withSession(['space' => (object) ['id' => $this->spaceId]]);
+ $this->withSession(['space_id' => $this->spaceId]);
$tag = factory(Tag::class)->create(['space_id' => $this->spaceId]);
@@ -285,7 +285,7 @@ class BudgetRepositoryTest extends TestCase
public function testGetSpentByIdUsingDailyBudget(): void
{
- $this->withSession(['space' => (object) ['id' => $this->spaceId]]);
+ $this->withSession(['space_id' => $this->spaceId]);
$tag = factory(Tag::class)->create(['space_id' => $this->spaceId]);

MODIFY
tests/Unit/Repositories/CurrencyRepositoryTest.php
tests/Unit/Repositories/CurrencyRepositoryTest.php
@@ -4,6 +4,7 @@ namespace Tests\Unit\Repositories;
use App\Models\ConversionRate;
use App\Models\Currency;
+use App\Models\Space;
use App\Repositories\CurrencyRepository;
use Tests\TestCase;
@@ -24,10 +25,11 @@ class CurrencyRepositoryTest extends TestCase
$firstCurrency = factory(Currency::class)->create();
$secondCurrency = factory(Currency::class)->create();
+ $firstSpace = factory(Space::class)->create(['currency_id' => $firstCurrency->id]);
+ $secondSpace = factory(Space::class)->create(['currency_id' => $secondCurrency->id]);
+
// Select first currency, assuming there are no conversion rates yet, the method should return 1 currency
- $this->session(['space' => (object) [
- 'currency_id' => $firstCurrency->id
- ]]);
+ $this->session(['space_id' => $firstSpace->id]);
$this->assertCount(1, $this->currencyRepository->getIfConversionRatePresent());
@@ -40,14 +42,8 @@ class CurrencyRepositoryTest extends TestCase
$this->assertCount(2, $this->currencyRepository->getIfConversionRatePresent());
// Switch to the other currency, the method should return 1 currency
- $this->session(['space' => (object) [
- 'currency_id' => $secondCurrency->id
- ]]);
+ $this->session(['space_id' => $secondSpace->id]);
$this->assertCount(1, $this->currencyRepository->getIfConversionRatePresent());
-
- // Clean up
- $firstCurrency->delete();
- $secondCurrency->delete();
}
}

Updates tests so they use space_id key for sessions instead of space