2016-12-26 15:17:46 -08:00
|
|
|
<?php
|
2021-11-30 20:09:29 -08:00
|
|
|
namespace Tests\Unit;
|
2016-12-26 15:17:46 -08:00
|
|
|
|
|
|
|
use App\Models\SnipeModel;
|
2023-03-07 16:57:55 -08:00
|
|
|
use Tests\TestCase;
|
2016-12-26 15:17:46 -08:00
|
|
|
|
2023-03-07 16:57:55 -08:00
|
|
|
class SnipeModelTest extends TestCase
|
2016-12-26 15:17:46 -08:00
|
|
|
{
|
2023-02-07 16:28:40 -08:00
|
|
|
public function testSetsPurchaseDatesAppropriately()
|
2016-12-26 15:17:46 -08:00
|
|
|
{
|
|
|
|
$c = new SnipeModel;
|
|
|
|
$c->purchase_date = '';
|
|
|
|
$this->assertTrue($c->purchase_date === null);
|
|
|
|
$c->purchase_date = '2016-03-25 12:35:50';
|
2021-06-10 13:15:52 -07:00
|
|
|
$this->assertTrue($c->purchase_date === '2016-03-25 12:35:50');
|
2016-12-26 15:17:46 -08:00
|
|
|
}
|
|
|
|
|
2023-02-07 16:28:40 -08:00
|
|
|
public function testSetsPurchaseCostsAppropriately()
|
2016-12-26 15:17:46 -08:00
|
|
|
{
|
|
|
|
$c = new SnipeModel;
|
|
|
|
$c->purchase_cost = '0.00';
|
|
|
|
$this->assertTrue($c->purchase_cost === null);
|
|
|
|
$c->purchase_cost = '9.54';
|
2021-06-10 13:15:52 -07:00
|
|
|
$this->assertTrue($c->purchase_cost === 9.54);
|
2016-12-26 15:17:46 -08:00
|
|
|
$c->purchase_cost = '9.50';
|
2021-06-10 13:15:52 -07:00
|
|
|
$this->assertTrue($c->purchase_cost === 9.5);
|
2016-12-26 15:17:46 -08:00
|
|
|
}
|
|
|
|
|
2023-02-07 16:28:40 -08:00
|
|
|
public function testNullsBlankLocationIdsButNotOthers()
|
2016-12-26 15:17:46 -08:00
|
|
|
{
|
|
|
|
$c = new SnipeModel;
|
|
|
|
$c->location_id = '';
|
|
|
|
$this->assertTrue($c->location_id === null);
|
|
|
|
$c->location_id = '5';
|
2021-06-10 13:15:52 -07:00
|
|
|
$this->assertTrue($c->location_id == 5);
|
2016-12-26 15:17:46 -08:00
|
|
|
}
|
2021-06-10 13:15:52 -07:00
|
|
|
|
2023-02-07 16:28:40 -08:00
|
|
|
public function testNullsBlankCategoriesButNotOthers()
|
2016-12-26 15:17:46 -08:00
|
|
|
{
|
|
|
|
$c = new SnipeModel;
|
|
|
|
$c->category_id = '';
|
|
|
|
$this->assertTrue($c->category_id === null);
|
|
|
|
$c->category_id = '1';
|
2021-06-10 13:15:52 -07:00
|
|
|
$this->assertTrue($c->category_id == 1);
|
2016-12-26 15:17:46 -08:00
|
|
|
}
|
|
|
|
|
2023-02-07 16:28:40 -08:00
|
|
|
public function testNullsBlankSuppliersButNotOthers()
|
2016-12-26 15:17:46 -08:00
|
|
|
{
|
|
|
|
$c = new SnipeModel;
|
|
|
|
$c->supplier_id = '';
|
|
|
|
$this->assertTrue($c->supplier_id === null);
|
|
|
|
$c->supplier_id = '4';
|
2021-06-10 13:15:52 -07:00
|
|
|
$this->assertTrue($c->supplier_id == 4);
|
2016-12-26 15:17:46 -08:00
|
|
|
}
|
|
|
|
|
2023-02-07 16:28:40 -08:00
|
|
|
public function testNullsBlankDepreciationsButNotOthers()
|
2016-12-26 15:17:46 -08:00
|
|
|
{
|
|
|
|
$c = new SnipeModel;
|
|
|
|
$c->depreciation_id = '';
|
|
|
|
$this->assertTrue($c->depreciation_id === null);
|
|
|
|
$c->depreciation_id = '4';
|
2021-06-10 13:15:52 -07:00
|
|
|
$this->assertTrue($c->depreciation_id == 4);
|
2016-12-26 15:17:46 -08:00
|
|
|
}
|
|
|
|
|
2023-02-07 16:28:40 -08:00
|
|
|
public function testNullsBlankManufacturersButNotOthers()
|
2016-12-26 15:17:46 -08:00
|
|
|
{
|
|
|
|
$c = new SnipeModel;
|
|
|
|
$c->manufacturer_id = '';
|
|
|
|
$this->assertTrue($c->manufacturer_id === null);
|
|
|
|
$c->manufacturer_id = '4';
|
2021-06-10 13:15:52 -07:00
|
|
|
$this->assertTrue($c->manufacturer_id == 4);
|
2016-12-26 15:17:46 -08:00
|
|
|
}
|
2021-06-10 13:15:52 -07:00
|
|
|
}
|