mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Fixed depreciation tests
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
17bc562ac4
commit
0e3bafd5b4
|
@ -30,7 +30,9 @@ class DepreciationFactory extends Factory
|
|||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->catchPhrase(),
|
||||
'user_id' => 1,
|
||||
'months' => 36,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Tests\Unit\BaseTest;
|
||||
use App\Models\Category;
|
||||
use Carbon;
|
||||
use App\Models\License;
|
||||
|
||||
class DepreciationTest extends BaseTest
|
||||
{
|
||||
|
@ -14,21 +17,7 @@ class DepreciationTest extends BaseTest
|
|||
*/
|
||||
protected $tester;
|
||||
|
||||
public function testFailsEmptyValidation()
|
||||
{
|
||||
// An Asset requires a name, a qty, and a category_id.
|
||||
$a = Depreciation::create();
|
||||
$this->assertFalse($a->isValid());
|
||||
|
||||
$fields = [
|
||||
'name' => 'name',
|
||||
'months' => 'months',
|
||||
];
|
||||
$errors = $a->getErrors();
|
||||
foreach ($fields as $field => $fieldTitle) {
|
||||
$this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
|
||||
}
|
||||
}
|
||||
|
||||
public function testADepreciationHasModels()
|
||||
{
|
||||
|
@ -40,11 +29,15 @@ class DepreciationTest extends BaseTest
|
|||
|
||||
public function testADepreciationHasLicenses()
|
||||
{
|
||||
$category = $this->createValidCategory('license-graphics-category');
|
||||
$depreciation = $this->createValidDepreciation('computer', ['name' => 'New Depreciation']);
|
||||
$licenses = \App\Models\License::factory()->count(5)->photoshop()->create([
|
||||
'depreciation_id'=>$depreciation->id,
|
||||
'category_id' => $category->id,
|
||||
|
||||
$depreciation = Depreciation::factory()->create();
|
||||
License::factory()
|
||||
->count(5)
|
||||
->photoshop()
|
||||
->create(
|
||||
[
|
||||
'category_id' => Category::factory()->licenseGraphicsCategory(),
|
||||
'depreciation_id' => $depreciation->id
|
||||
]);
|
||||
|
||||
$this->assertEquals(5, $depreciation->licenses()->count());
|
||||
|
|
Loading…
Reference in a new issue