Skip to content

Commit

Permalink
Set amount of planets for research queue tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rautamik committed Nov 24, 2024
1 parent cd65744 commit 8fe67d4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/AccountTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests;

use Carbon\Carbon;
use Exception;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Support\Str;
Expand All @@ -17,18 +18,19 @@
use OGame\Services\PlanetService;
use OGame\Services\PlayerService;
use OGame\Services\SettingsService;
use Carbon\Carbon;

/**
* Base class for tests that require account context. Common setup includes signup of new account and login.
*/
abstract class AccountTestCase extends TestCase
{
protected int $currentUserId = 0;
protected string $currentUsername = '';
protected int $currentPlanetId = 0;
protected PlanetService $secondPlanetService;
protected int $userPlanetAmount = 2;
protected string $currentUsername = '';
protected Carbon $defaultTestTime;
protected PlanetService $planetService;
protected PlanetService $secondPlanetService;

/**
* Set up common test components.
Expand All @@ -41,10 +43,10 @@ protected function setUp(): void
// Set default test time to 2024-01-01 00:00:00 to ensure all tests have the same starting point.
$this->travelTo(Carbon::create(2024, 1, 1, 0, 0, 0));

// Set amount of planets to be created for the user to 4 because planet switching
// Set amount of planets to be created for the user because planet switching
// is a part of the test suite.
$settingsService = resolve(SettingsService::class);
$settingsService->set('registration_planet_amount', 4);
$settingsService->set('registration_planet_amount', $this->userPlanetAmount);

// Create a new user and login so we can access ingame features.
$this->createAndLoginUser();
Expand All @@ -53,8 +55,6 @@ protected function setUp(): void
$this->retrieveMetaFields();
}

protected PlanetService $planetService;

/**
* By default, Laravel does not refresh the application state between requests in a single test.
* By invoking this method we ensure that the application state is refreshed to avoid any side effects from
Expand Down
11 changes: 11 additions & 0 deletions tests/Feature/ResearchQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
*/
class ResearchQueueTest extends AccountTestCase
{
/**
* Set up common test components.
* @throws BindingResolutionException
*/
protected function setUp(): void
{
$this->userPlanetAmount = 4;

parent::setUp();
}

/**
* Verify that researching energy technology works as expected.
* @throws Exception
Expand Down

0 comments on commit 8fe67d4

Please sign in to comment.