A free open source IT asset/license management system
Tests on asset tags that are maximum integers and *almost* maximum...
Brady Wetheringtone827bc9a07e8
diff --git a/tests/Unit/AssetTest.php b/tests/Unit/AssetTest.phpindex 9c3a76af69..ef0da1a1b8 100644--- a/tests/Unit/AssetTest.php+++ b/tests/Unit/AssetTest.php@@ -6,6 +6,7 @@ use App\Models\AssetModel;use App\Models\Category;use Carbon\Carbon;use Tests\TestCase;+use App\Models\Setting;class AssetTest extends TestCase{@@ -135,6 +136,40 @@ class AssetTest extends TestCase$this->assertEquals($final->asset_tag, $final_result);}+ public function testAutoIncrementBIG()+ {+ $this->settings->enableAutoIncrement();++ // we have to do this by hand to 'simulate' two web pages being open at the same time+ $a = Asset::factory()->make(['asset_tag' => Asset::autoincrement_asset()]);+ $b = Asset::factory()->make(['asset_tag' => 'ABCD' . (PHP_INT_MAX - 1)]);++ $this->assertTrue($a->save());+ $this->assertTrue($b->save());+ \Log::error("A asset tag is: " . $a->asset_tag);+ $matches = [];+ preg_match('/\d+/', $a->asset_tag, $matches);+ \Log::error("digits are: " . $matches[0]);+ $this->assertEquals(Setting::getSettings()->next_auto_tag_base, $matches[0] + 1, "Next auto increment number should be the last normally-saved one plus one, but isn't");+ }++ public function testAutoIncrementAlmostBIG()+ {+ // TODO: this looks pretty close to the one above, could we maybe squish them together?+ $this->settings->enableAutoIncrement();++ // we have to do this by hand to 'simulate' two web pages being open at the same time+ $a = Asset::factory()->make(['asset_tag' => Asset::autoincrement_asset()]);+ $b = Asset::factory()->make(['asset_tag' => 'ABCD' . (PHP_INT_MAX - 2)]);++ $this->assertTrue($a->save());+ $this->assertTrue($b->save());+ $matches = [];+ preg_match('/\d+/', $b->asset_tag, $matches); //this is *b*, not *a* - slight difference from above test+ $this->assertEquals(Setting::getSettings()->next_auto_tag_base, $matches[0] + 1, "Next auto increment number should be the last normally-saved one plus one, but isn't");+ }++public function testWarrantyExpiresAttribute(){