mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Add test for dashboard counts
This commit is contained in:
parent
549dec9f9e
commit
22a2cc0256
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Accessory;
|
||||||
|
use App\Models\Asset;
|
||||||
|
use App\Models\Component;
|
||||||
|
use App\Models\Consumable;
|
||||||
|
use App\Models\License;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
@ -13,4 +18,39 @@ class DashboardTest extends TestCase
|
||||||
->get(route('home'))
|
->get(route('home'))
|
||||||
->assertRedirect(route('view-assets'));
|
->assertRedirect(route('view-assets'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCountsAreLoadedCorrectlyForAdmins()
|
||||||
|
{
|
||||||
|
Asset::factory()->count(2)->create();
|
||||||
|
Accessory::factory()->count(2)->create();
|
||||||
|
License::factory()->count(2)->create();
|
||||||
|
Consumable::factory()->count(2)->create();
|
||||||
|
Component::factory()->count(2)->create();
|
||||||
|
|
||||||
|
$this->actingAs(User::factory()->admin()->create())
|
||||||
|
->get(route('home'))
|
||||||
|
->assertViewIs('dashboard')
|
||||||
|
->assertViewHas('counts', function ($value) {
|
||||||
|
$accessoryCount = Accessory::count();
|
||||||
|
$assetCount = Asset::count();
|
||||||
|
$componentCount = Component::count();
|
||||||
|
$consumableCount = Consumable::count();
|
||||||
|
$licenseCount = License::assetcount();
|
||||||
|
$userCount = User::count();
|
||||||
|
|
||||||
|
$this->assertEquals($value['accessory'], $accessoryCount, 'Accessory count incorrect.');
|
||||||
|
$this->assertEquals($value['asset'], $assetCount, 'Asset count incorrect.');
|
||||||
|
$this->assertEquals($value['license'], $licenseCount, 'License count incorrect.');
|
||||||
|
$this->assertEquals($value['consumable'], $consumableCount, 'Consumable count incorrect.');
|
||||||
|
$this->assertEquals($value['component'], $componentCount, 'Component count incorrect.');
|
||||||
|
$this->assertEquals($value['user'], $userCount, 'User count incorrect.');
|
||||||
|
$this->assertEquals(
|
||||||
|
$value['grand_total'],
|
||||||
|
$accessoryCount + $assetCount + $consumableCount + $licenseCount,
|
||||||
|
'Grand total count incorrect.'
|
||||||
|
);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue