mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24: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()
|
public function definition()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'name' => $this->faker->catchPhrase(),
|
||||||
'user_id' => 1,
|
'user_id' => 1,
|
||||||
|
'months' => 36,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||||
use Tests\Unit\BaseTest;
|
use Tests\Unit\BaseTest;
|
||||||
|
use App\Models\Category;
|
||||||
|
use Carbon;
|
||||||
|
use App\Models\License;
|
||||||
|
|
||||||
class DepreciationTest extends BaseTest
|
class DepreciationTest extends BaseTest
|
||||||
{
|
{
|
||||||
|
@ -14,21 +17,7 @@ class DepreciationTest extends BaseTest
|
||||||
*/
|
*/
|
||||||
protected $tester;
|
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()
|
public function testADepreciationHasModels()
|
||||||
{
|
{
|
||||||
|
@ -40,11 +29,15 @@ class DepreciationTest extends BaseTest
|
||||||
|
|
||||||
public function testADepreciationHasLicenses()
|
public function testADepreciationHasLicenses()
|
||||||
{
|
{
|
||||||
$category = $this->createValidCategory('license-graphics-category');
|
|
||||||
$depreciation = $this->createValidDepreciation('computer', ['name' => 'New Depreciation']);
|
$depreciation = Depreciation::factory()->create();
|
||||||
$licenses = \App\Models\License::factory()->count(5)->photoshop()->create([
|
License::factory()
|
||||||
'depreciation_id'=>$depreciation->id,
|
->count(5)
|
||||||
'category_id' => $category->id,
|
->photoshop()
|
||||||
|
->create(
|
||||||
|
[
|
||||||
|
'category_id' => Category::factory()->licenseGraphicsCategory(),
|
||||||
|
'depreciation_id' => $depreciation->id
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertEquals(5, $depreciation->licenses()->count());
|
$this->assertEquals(5, $depreciation->licenses()->count());
|
||||||
|
|
Loading…
Reference in a new issue