-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #409 from rautamik/bugfix/212-max-shields
Restrict small and large shields max amount
- Loading branch information
Showing
6 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Tests\Unit; | ||
|
||
use OGame\Services\ObjectService; | ||
use Tests\UnitTestCase; | ||
|
||
class ObjectServiceTest extends UnitTestCase | ||
{ | ||
public function testGetObjectMaxBuildAmount(): void | ||
{ | ||
$objectService = new ObjectService(); | ||
$this->createAndSetPlanetModel([]); | ||
|
||
// Test with requirement not met | ||
$maxBuildAmount = $objectService->getObjectMaxBuildAmount('plasma_turret', $this->planetService, false); | ||
$this->assertEquals(0, $maxBuildAmount); | ||
|
||
// Test with object limited to one instance | ||
$maxBuildAmount = $objectService->getObjectMaxBuildAmount('small_shield_dome', $this->planetService, true); | ||
$this->assertEquals(1, $maxBuildAmount); | ||
|
||
$this->createAndSetPlanetModel([ | ||
'small_shield_dome' => 1, | ||
]); | ||
|
||
// Test with object limited to one instance which already exists | ||
$maxBuildAmount = $objectService->getObjectMaxBuildAmount('small_shield_dome', $this->planetService, true); | ||
$this->assertEquals(0, $maxBuildAmount); | ||
|
||
$this->createAndSetPlanetModel([ | ||
'metal' => 24000, | ||
'crystal' => 6000 | ||
]); | ||
|
||
// Test it calculates max amount correctly | ||
$maxBuildAmount = $objectService->getObjectMaxBuildAmount('anti_ballistic_missile', $this->planetService, true); | ||
$this->assertEquals(3, $maxBuildAmount); | ||
} | ||
} |