mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 21:54:14 -08:00
f432f98e12
* Fix Bug in User::generateFormattedNameFromFullName In a name "John Doe", this method would split it into "John" and " Doe", Leaving a space in the last name when importing to the database. Strip this space. * Cleanup/fix some item mapping. Also make some changes to the importer schema to allow for unit testing. Generate a default item mapping, and then merge that with any custom mappings. * Beginning work on importer unit tests. * Strip out testrun branches from importer. It added a lot of complexity and was not terribly useful with web importer as it stood, might reconsider down the road however. * Normalize the mapped keys when using custom field mappings. * Add test for custom asset import mapping. * Make all unit tests inherit from a new custom base. This baseclass currently calls Artisan::migrate() and seeds a Settings instance. This fixes unit tests after the autoincrement bits. * Store requestable as a boolean. Fixes some import oddities * Work on tests for accessory importer. * Test for custom mapping of accessory import, also adjust the internal field for purchase date. * Update default locale fallback for currency detection * Fix Reassignable in consumable as well. * More importer tests and fixes.
98 lines
2.3 KiB
PHP
98 lines
2.3 KiB
PHP
<?php
|
|
|
|
|
|
use App\Models\SnipeModel;
|
|
|
|
class SnipeModelTest extends BaseTest
|
|
{
|
|
/**
|
|
* @var \UnitTester
|
|
*/
|
|
protected $tester;
|
|
|
|
// tests
|
|
/**
|
|
* @test
|
|
*/
|
|
public function it_sets_purchase_dates_appropriately()
|
|
{
|
|
$c = new SnipeModel;
|
|
$c->purchase_date = '';
|
|
$this->assertTrue($c->purchase_date === null);
|
|
$c->purchase_date = '2016-03-25 12:35:50';
|
|
$this->assertTrue($c->purchase_date==='2016-03-25 12:35:50');
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function it_sets_purchase_costs_appropriately()
|
|
{
|
|
$c = new SnipeModel;
|
|
$c->purchase_cost = '0.00';
|
|
$this->assertTrue($c->purchase_cost === null);
|
|
$c->purchase_cost = '9.54';
|
|
$this->assertTrue($c->purchase_cost===9.54);
|
|
$c->purchase_cost = '9.50';
|
|
$this->assertTrue($c->purchase_cost===9.5);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function it_nulls_blank_location_ids_but_not_others()
|
|
{
|
|
$c = new SnipeModel;
|
|
$c->location_id = '';
|
|
$this->assertTrue($c->location_id === null);
|
|
$c->location_id = '5';
|
|
$this->assertTrue($c->location_id==5);
|
|
}
|
|
/**
|
|
* @test
|
|
*/
|
|
public function it_nulls_blank_categories_but_not_others()
|
|
{
|
|
$c = new SnipeModel;
|
|
$c->category_id = '';
|
|
$this->assertTrue($c->category_id === null);
|
|
$c->category_id = '1';
|
|
$this->assertTrue($c->category_id==1);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function it_nulls_blank_suppliers_but_not_others()
|
|
{
|
|
$c = new SnipeModel;
|
|
$c->supplier_id = '';
|
|
$this->assertTrue($c->supplier_id === null);
|
|
$c->supplier_id = '4';
|
|
$this->assertTrue($c->supplier_id==4);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function it_nulls_blank_depreciations_but_not_others()
|
|
{
|
|
$c = new SnipeModel;
|
|
$c->depreciation_id = '';
|
|
$this->assertTrue($c->depreciation_id === null);
|
|
$c->depreciation_id = '4';
|
|
$this->assertTrue($c->depreciation_id==4);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function it_nulls_blank_manufacturers_but_not_others()
|
|
{
|
|
$c = new SnipeModel;
|
|
$c->manufacturer_id = '';
|
|
$this->assertTrue($c->manufacturer_id === null);
|
|
$c->manufacturer_id = '4';
|
|
$this->assertTrue($c->manufacturer_id==4);
|
|
}
|
|
} |