Compare commits

..

50 Commits

Author SHA1 Message Date
snipe
d8a8e1cc09 Bumped version 2018-08-28 11:43:56 -07:00
snipe
522dc1db2a Fixed #6124 2018-08-23 21:05:10 -07:00
snipe
db907815ff Removed check for active in password reset form 2018-08-21 18:40:27 -07:00
snipe
ae6abdddad Check the user is active before displaying password reset
This would only come into play if an inactive user already received a password reset email and then the system was upgraded to prevent those emails from being sent to inactive users
2018-08-14 19:04:47 -07:00
snipe
63c9fbe10c Temporarily disbable notifying users on import 2018-08-14 18:27:46 -07:00
snipe
101dfd01f2 Bumped hash 2018-08-14 18:22:53 -07:00
snipe
5db5134ae0 Set activated to default on when new user is created 2018-08-14 18:14:41 -07:00
snipe
5294489b0e Fixed HTML typo 2018-08-14 18:14:29 -07:00
snipe
05b2b8fb59 Tweaked code/language for password reset 2018-08-14 18:09:33 -07:00
snipe
0100c56046 Only allow password reset if user is active 2018-08-14 17:46:29 -07:00
Jordi Boggiano
e81b221fd1 Fix license identifier (#6043) 2018-08-08 20:36:45 -07:00
snipe
f374ac1bf7 Removed duplicate BACKUP_ENV in example env 2018-08-01 15:31:43 -07:00
snipe
524c6c502e Features/restore deleted cmd (#5982)
* Delete content from login attempts table

* Script to restore deleted users and put their asset assignments back

* Uncomment backup
2018-07-27 02:42:55 -07:00
snipe
614e858e44 Restrict users asset listing to just assets checked out to users 2018-07-25 21:38:14 -07:00
snipe
708b1a962c Split out custom_css from custom_header
This makes it so that the custom_css will still be respected even if there is no custom header
2018-07-25 19:01:47 -07:00
snipe
4e55a18a60 Bumped version 2018-07-24 19:46:23 -07:00
snipe
3de1de9dc6 Merge branch 'develop' 2018-07-24 14:04:16 -07:00
snipe
e320d2ba05 Fixed #5944 - added logo option for print-assets page (#5950) 2018-07-24 13:37:02 -07:00
snipe
ed78a4b8a0 Fixed activated issue for strict mode 2018-07-24 13:28:59 -07:00
snipe
376eb52f00 Fixed #5938 - added “self location edit” as permission 2018-07-24 12:42:16 -07:00
snipe
8ecceeacda Fixed weird display for self options 2018-07-24 12:41:58 -07:00
snipe
f4cfb31bf4 Use request object 2018-07-24 12:10:02 -07:00
snipe
227dc7e81d Save model display setting - fix for issue in #5301 2018-07-24 12:10:02 -07:00
snipe
152d985ebc Add @Azerothian as a contributor 2018-07-24 12:10:02 -07:00
Earl Ramirez
ef1e8df001 Disable file browsing (#5922)
* Added cron to list of packages

* Disable file browsing from the public directory
2018-07-23 20:40:04 -07:00
snipe
5c2b1a3b70 Add @Azerothian as a contributor 2018-07-23 20:29:15 -07:00
Azerothian
66c3f5432d implemented specific seat checkout (#5887) 2018-07-23 20:28:45 -07:00
Daniel Meltzer
de413408f5 Port/reenable most unit tests. (#5921)
* Port/reenable most unit tests.

Should probably flesh out notifications tests in the next few days.

* Disable json checkin in ApiAssetsTest@index for now.  It's broken, but hiding other real broken things.

* Re Disable Groups allowDelete
2018-07-23 06:48:21 -07:00
Daniel Meltzer
059126f642 Checkout update locationid (#5919)
* Fix missing punctuation.  Bad merge.

* If we're checking out to an location, use it's id instead of location_id
2018-07-23 06:47:21 -07:00
Daniel Meltzer
3bc43210ab Add ID to the allowed sort fields in api/Users. (#5929) 2018-07-23 06:46:50 -07:00
Daniel Meltzer
82194cef8a bugfix: updating a user when an admin (not a superuser) would remove any groups from the user. (#5914) 2018-07-21 23:02:06 -07:00
snipe
1956a16d1e Merge branch 'develop' 2018-07-20 13:25:03 -07:00
Till Deeke
e1c095adca Removes the typehint for search term string (#5904)
The „string“ typehint only works in PHP >= 7.0.0.
Since we are still supporting versions below that, remove the type hint.
2018-07-20 13:23:44 -07:00
Till Deeke
45a2932f4b Fixes the generation of where conditions (#5902) 2018-07-20 13:23:29 -07:00
Till Deeke
b6e3715cd8 Fix: No Notifications for checking out Consumables (#5898)
* Adds a method to consumables to check if a notification should be sent

Adds the checkin_email method to Consumables, this gets checked in notifications when checking out the consumable.

Without the method, no notifications get sent for checking out consumables.

* Fixes the checkin_email method on the License model

This should allow the License to also send checkout/checkin notifications again.
2018-07-20 13:22:49 -07:00
snipe
aa9c0078a1 Merge branch 'develop'
# Conflicts:
#	config/version.php
2018-07-19 14:47:27 -07:00
snipe
9677115055 Bumped version 2018-07-19 14:46:08 -07:00
snipe
d45e90e358 One more fix for #5893 2018-07-19 14:45:28 -07:00
snipe
f692fb5bff Merge branch 'develop'
# Conflicts:
#	config/version.php
2018-07-19 10:50:18 -07:00
snipe
83692696ba Bumped version 2018-07-19 10:49:40 -07:00
snipe
bbb15d610f Merge branch 'develop' 2018-07-19 10:40:38 -07:00
snipe
7ebb7876c4 Partial fix for #5896
Still need to fix the front end on edit, which seems to be defaulting to boolean
2018-07-19 10:40:07 -07:00
snipe
bd581d01a3 Use full row width for image field 2018-07-19 10:40:07 -07:00
snipe
de2ebba577 Category add/edit UI tweaks 2018-07-19 10:40:07 -07:00
Daniel Meltzer
351274c633 Hotfix: the checkin_email does not exist on consumable. (#5891) 2018-07-19 10:38:50 -07:00
snipe
53fab3e9ba Merge branch 'develop' 2018-07-19 10:23:18 -07:00
snipe
a0c0b7b1eb Fixed #5893 - activated typo 2018-07-19 10:22:08 -07:00
snipe
5a34d43a86 Fixed #5895 - wrong date validation in maintenances 2018-07-19 10:19:55 -07:00
snipe
86a0f77e6f Merge branch 'develop' 2018-07-19 10:15:38 -07:00
snipe
9d00ae6e50 Fixed #5894 - lookup by asset tag in top search broken 2018-07-19 10:14:02 -07:00
59 changed files with 1118 additions and 794 deletions

View File

@@ -1641,6 +1641,15 @@
"contributions": [
"code"
]
},
{
"login": "Azerothian",
"name": "Azerothian",
"avatar_url": "https://avatars1.githubusercontent.com/u/264022?v=4",
"profile": "https://www.illisian.com.au",
"contributions": [
"code"
]
}
]
}

View File

@@ -7,7 +7,6 @@ APP_KEY=ChangeMe
APP_URL=null
APP_TIMEZONE='UTC'
APP_LOCALE=en
BACKUP_ENV=false
# --------------------------------------------
# REQUIRED: DATABASE SETTINGS

View File

@@ -20,6 +20,7 @@ vim \
git \
cron \
mysql-client \
cron \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

View File

@@ -1,5 +1,5 @@
[![Build Status](https://travis-ci.org/snipe/snipe-it.svg?branch=master)](https://travis-ci.org/snipe/snipe-it) [![Crowdin](https://d322cqt584bo4o.cloudfront.net/snipe-it/localized.svg)](https://crowdin.com/project/snipe-it) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/snipe/snipe-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Docker Pulls](https://img.shields.io/docker/pulls/snipe/snipe-it.svg)](https://hub.docker.com/r/snipe/snipe-it/) [![Twitter Follow](https://img.shields.io/twitter/follow/snipeitapp.svg?style=social)](https://twitter.com/snipeitapp) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/553ce52037fc43ea99149785afcfe641)](https://www.codacy.com/app/snipe/snipe-it?utm_source=github.com&utm_medium=referral&utm_content=snipe/snipe-it&utm_campaign=Badge_Grade)
[![All Contributors](https://img.shields.io/badge/all_contributors-179-orange.svg?style=flat-square)](#contributors) [![Open Source Helpers](https://www.codetriage.com/snipe/snipe-it/badges/users.svg)](https://www.codetriage.com/snipe/snipe-it)
[![All Contributors](https://img.shields.io/badge/all_contributors-180-orange.svg?style=flat-square)](#contributors) [![Open Source Helpers](https://www.codetriage.com/snipe/snipe-it/badges/users.svg)](https://www.codetriage.com/snipe/snipe-it)
## Snipe-IT - Open Source Asset Management System
@@ -95,7 +95,7 @@ Thanks goes to all of these wonderful people ([emoji key](https://github.com/ken
| [<img src="https://avatars2.githubusercontent.com/u/982885?v=4" width="110px;"/><br /><sub>Martin Stub</sub>](http://martinstub.dk)<br />[🌍](#translation-stubben "Translation") | [<img src="https://avatars2.githubusercontent.com/u/28959963?v=4" width="110px;"/><br /><sub>Meyer Flavio</sub>](https://github.com/meyerf99)<br />[🌍](#translation-meyerf99 "Translation") | [<img src="https://avatars3.githubusercontent.com/u/796443?v=4" width="110px;"/><br /><sub>Micael Rodrigues</sub>](https://github.com/MicaelRodrigues)<br />[🌍](#translation-MicaelRodrigues "Translation") | [<img src="https://avatars0.githubusercontent.com/u/10481331?v=4" width="110px;"/><br /><sub>Mikael Rasmussen</sub>](http://rubixy.com/)<br />[🌍](#translation-mikaelssen "Translation") | [<img src="https://avatars1.githubusercontent.com/u/1544552?v=4" width="110px;"/><br /><sub>IxFail</sub>](https://github.com/IxFail)<br />[🌍](#translation-IxFail "Translation") | [<img src="https://avatars3.githubusercontent.com/u/18483118?v=4" width="110px;"/><br /><sub>Mohammed Fota</sub>](http://www.mohammedfota.com)<br />[🌍](#translation-MohammedFota "Translation") | [<img src="https://avatars0.githubusercontent.com/u/227080?v=4" width="110px;"/><br /><sub>Moayad Alserihi</sub>](https://github.com/omego)<br />[🌍](#translation-omego "Translation") |
| [<img src="https://avatars0.githubusercontent.com/u/1680266?v=4" width="110px;"/><br /><sub>saymd</sub>](https://github.com/saymd)<br />[🌍](#translation-saymd "Translation") | [<img src="https://avatars0.githubusercontent.com/u/1826808?v=4" width="110px;"/><br /><sub>Patrik Larsson</sub>](https://nordsken.se)<br />[🌍](#translation-pooot "Translation") | [<img src="https://avatars1.githubusercontent.com/u/20584746?v=4" width="110px;"/><br /><sub>drcryo</sub>](https://github.com/drcryo)<br />[🌍](#translation-drcryo "Translation") | [<img src="https://avatars1.githubusercontent.com/u/19408004?v=4" width="110px;"/><br /><sub>pawel1615</sub>](https://github.com/pawel1615)<br />[🌍](#translation-pawel1615 "Translation") | [<img src="https://avatars2.githubusercontent.com/u/23340468?v=4" width="110px;"/><br /><sub>bodrovics</sub>](https://github.com/bodrovics)<br />[🌍](#translation-bodrovics "Translation") | [<img src="https://avatars0.githubusercontent.com/u/3257654?v=4" width="110px;"/><br /><sub>priatna</sub>](https://github.com/priatna)<br />[🌍](#translation-priatna "Translation") | [<img src="https://avatars1.githubusercontent.com/u/5358374?v=4" width="110px;"/><br /><sub>Fan Jiang</sub>](https://amayume.net)<br />[🌍](#translation-ProfFan "Translation") |
| [<img src="https://avatars1.githubusercontent.com/u/22555451?v=4" width="110px;"/><br /><sub>ragnarcx</sub>](https://github.com/ragnarcx)<br />[🌍](#translation-ragnarcx "Translation") | [<img src="https://avatars2.githubusercontent.com/u/18654582?v=4" width="110px;"/><br /><sub>Rein van Haaren</sub>](http://www.reinvanhaaren.nl/)<br />[🌍](#translation-reinvanhaaren "Translation") | [<img src="https://avatars1.githubusercontent.com/u/386672?v=4" width="110px;"/><br /><sub>Teguh Dwicaksana</sub>](http://dheche.songolimo.net)<br />[🌍](#translation-dheche "Translation") | [<img src="https://avatars2.githubusercontent.com/u/2572552?v=4" width="110px;"/><br /><sub>fraccie</sub>](https://github.com/FRaccie)<br />[🌍](#translation-FRaccie "Translation") | [<img src="https://avatars0.githubusercontent.com/u/35182720?v=4" width="110px;"/><br /><sub>vinzruzell</sub>](https://github.com/vinzruzell)<br />[🌍](#translation-vinzruzell "Translation") | [<img src="https://avatars1.githubusercontent.com/u/7883603?v=4" width="110px;"/><br /><sub>Kevin Austin</sub>](http://kevinaustin.com)<br />[🌍](#translation-vipsystem "Translation") | [<img src="https://avatars3.githubusercontent.com/u/3861828?v=4" width="110px;"/><br /><sub>Wira Sandy</sub>](http://azuraweb.xyz)<br />[🌍](#translation-wira-sandy "Translation") |
| [<img src="https://avatars2.githubusercontent.com/u/8663789?v=4" width="110px;"/><br /><sub>Илья</sub>](https://github.com/GrayHoax)<br />[🌍](#translation-GrayHoax "Translation") | [<img src="https://avatars3.githubusercontent.com/u/30119111?v=4" width="110px;"/><br /><sub>GodUseVPN</sub>](https://github.com/godusevpn)<br />[🌍](#translation-godusevpn "Translation") | [<img src="https://avatars1.githubusercontent.com/u/745576?v=4" width="110px;"/><br /><sub>周周</sub>](https://github.com/EngrZhou)<br />[🌍](#translation-EngrZhou "Translation") | [<img src="https://avatars3.githubusercontent.com/u/1631095?v=4" width="110px;"/><br /><sub>Sam</sub>](https://github.com/takuy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=takuy "Code") |
| [<img src="https://avatars2.githubusercontent.com/u/8663789?v=4" width="110px;"/><br /><sub>Илья</sub>](https://github.com/GrayHoax)<br />[🌍](#translation-GrayHoax "Translation") | [<img src="https://avatars3.githubusercontent.com/u/30119111?v=4" width="110px;"/><br /><sub>GodUseVPN</sub>](https://github.com/godusevpn)<br />[🌍](#translation-godusevpn "Translation") | [<img src="https://avatars1.githubusercontent.com/u/745576?v=4" width="110px;"/><br /><sub>周周</sub>](https://github.com/EngrZhou)<br />[🌍](#translation-EngrZhou "Translation") | [<img src="https://avatars3.githubusercontent.com/u/1631095?v=4" width="110px;"/><br /><sub>Sam</sub>](https://github.com/takuy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=takuy "Code") | [<img src="https://avatars1.githubusercontent.com/u/264022?v=4" width="110px;"/><br /><sub>Azerothian</sub>](https://www.illisian.com.au)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Azerothian "Code") |
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!

View File

@@ -79,6 +79,7 @@ class PaveIt extends Command
DB::statement('delete from accessories_users');
DB::statement('delete from asset_logs');
DB::statement('delete from asset_maintenances');
DB::statement('delete from login_attempts');
DB::statement('delete from asset_uploads');
DB::statement('delete from action_logs');
DB::statement('delete from checkout_requests');

View File

@@ -0,0 +1,120 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\User;
use App\Models\Actionlog;
use App\Models\Asset;
use App\Models\Consumable;
use App\Models\Accessory;
use App\Models\LicenseSeat;
use App\Models\License;
use DB;
use Artisan;
class RestoreDeletedUsers extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'snipeit:restore-users {--start_date=} {--end_date=}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Restore users, and any associated assets and license checkouts.';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$start_date = $this->option('start_date');
$end_date = $this->option('end_date');
$asset_totals = 0;
$license_totals = 0;
$user_count = 0;
if (($start_date=='') || ($end_date=='')) {
$this->info('ERROR: All fields are required.');
return false;
}
$users = User::whereBetween('deleted_at', [$start_date, $end_date])->withTrashed()->get();
$this->info('There are '.$users->count().' users deleted between '.$start_date.' and '.$end_date);
$this->warn('Making a backup!');
Artisan::call('backup:run');
foreach ($users as $user) {
$user_count++;
$user_logs = Actionlog::where('target_id', $user->id)->where('target_type',User::class)
->where('action_type','checkout')->with('item')->get();
$this->info($user_count.'. '.$user->username.' ('.$user->id.') was deleted at '.$user->deleted_at. ' and has '.$user_logs->count().' checkouts associated.');
foreach ($user_logs as $user_log) {
$this->info(' * '.$user_log->item_type.': '.$user_log->item->name.' - item_id: '.$user_log->item_id);
if ($user_log->item_type==Asset::class) {
$asset_totals++;
DB::table('assets')
->where('id', $user_log->item_id)
->update(['assigned_to' => $user->id, 'assigned_type'=> User::class]);
$this->info(' ** Asset '.$user_log->item->id.' ('.$user_log->item->asset_tag.') restored to user '.$user->id.'');
} elseif ($user_log->item_type==License::class) {
$license_totals++;
$avail_seat = DB::table('license_seats')->where('license_id','=',$user_log->item->id)
->whereNull('assigned_to')->whereNull('asset_id')->whereBetween('updated_at', [$start_date, $end_date])->first();
if ($avail_seat) {
$this->info(' ** Allocating seat '.$avail_seat->id.' for this License');
DB::table('license_seats')
->where('id', $avail_seat->id)
->update(['assigned_to' => $user->id]);
} else {
$this->warn('ERROR: No available seats for '.$user_log->item->name);
}
}
}
$this->warn('Restoring user '.$user->username.'!');
$user->restore();
}
$this->info($asset_totals.' assets affected');
$this->info($license_totals.' licenses affected');
}
}

View File

@@ -30,6 +30,7 @@ class Kernel extends ConsoleKernel
Commands\SyncAssetLocations::class,
Commands\RegenerateAssetTags::class,
Commands\SyncAssetCounters::class,
Commands\RestoreDeletedUsers::class,
];
/**

View File

@@ -105,7 +105,7 @@ class UsersController extends Controller
'assets','accessories', 'consumables','licenses','groups','activated','created_at',
'two_factor_enrolled','two_factor_optin','last_login', 'assets_count', 'licenses_count',
'consumables_count', 'accessories_count', 'phone', 'address', 'city', 'state',
'country', 'zip'
'country', 'zip', 'id'
];
$sort = in_array($request->get('sort'), $allowed_columns) ? $request->get('sort') : 'first_name';
@@ -292,7 +292,7 @@ class UsersController extends Controller
{
$this->authorize('view', User::class);
$this->authorize('view', Asset::class);
$assets = Asset::where('assigned_to', '=', $id)->with('model')->get();
$assets = Asset::where('assigned_to', '=', $id)->where('assigned_type', '=', User::class)->with('model')->get();
return (new AssetsTransformer)->transformAssets($assets, $assets->count());
}

View File

@@ -439,7 +439,7 @@ class AssetsController extends Controller
* @since [v3.0]
* @return Redirect
*/
public function getAssetByTag()
public function getAssetByTag(Request $request)
{
$topsearch = ($request->get('topsearch')=="true");

View File

@@ -55,7 +55,10 @@ class ForgotPasswordController extends Controller
// to send the link, we will examine the response then see the message we
// need to show to the user. Finally, we'll send out a proper response.
$response = $this->broker()->sendResetLink(
$request->only('email')
array_merge(
$request->only('email'),
['activated' => '1']
)
);
if ($response === \Password::RESET_LINK_SENT) {

View File

@@ -76,7 +76,7 @@ class LoginController extends Controller
};
try {
$user = User::where('username', '=', $remote_user)->whereNull('deleted_at')->where('active', '=', '1')->first();
$user = User::where('username', '=', $remote_user)->whereNull('deleted_at')->where('activated', '=', '1')->first();
LOG::debug("Remote user auth lookup complete");
if(!is_null($user)) Auth::login($user, true);
} catch(Exception $e) {
@@ -97,7 +97,7 @@ class LoginController extends Controller
}
// Check if the user already exists in the database and was imported via LDAP
$user = User::where('username', '=', Input::get('username'))->whereNull('deleted_at')->where('ldap_import', '=', 1)->where('active', '=', '1')->first();
$user = User::where('username', '=', Input::get('username'))->whereNull('deleted_at')->where('ldap_import', '=', 1)->where('activated', '=', '1')->first();
LOG::debug("Local auth lookup complete");
// The user does not exist in the database. Try to get them from LDAP.

View File

@@ -4,6 +4,8 @@ namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
use App\Models\User;
use Illuminate\Http\Request;
class ResetPasswordController extends Controller
{
@@ -36,4 +38,8 @@ class ResetPasswordController extends Controller
{
$this->middleware('guest');
}
}

View File

@@ -87,7 +87,7 @@ class CustomFieldsController extends Controller
]);
if (!in_array(Input::get('format'), array_keys(CustomField::$PredefinedFormats))) {
if ($request->has("custom_format")) {
$field->format = e($request->get("custom_format"));
} else {
$field->format = e($request->get("format"));
@@ -96,7 +96,6 @@ class CustomFieldsController extends Controller
if ($field->save()) {
return redirect()->route("fields.index")->with("success", trans('admin/custom_fields/message.field.create.success'));
} else {
// dd($field);
return redirect()->back()->withInput()->with('error', trans('admin/custom_fields/message.field.create.error'));
}

View File

@@ -265,31 +265,40 @@ class LicensesController extends Controller
* @author [A. Gianotto] [<snipe@snipe.net>]
* @since [v1.0]
* @param Request $request
* @param int $licenseId
* @param int $seatId
* @return \Illuminate\Http\RedirectResponse
*/
public function postCheckout(Request $request, $licenseId)
public function postCheckout(Request $request, $licenseId, $seatId = null)
{
// Check that the license is valid
if ($license = License::where('id',$licenseId)->first()) {
if ($license = License::where('id', $licenseId)->first()) {
// If the license is valid, check that there is an available seat
if ($license->getAvailSeatsCountAttribute() < 1) {
return redirect()->route('licenses.index')->with('error', 'There are no available seats for this license');
}
// Get the next available seat for this license
$next = $license->freeSeat();
if (!$next) {
return redirect()->route('licenses.index')->with('error', 'There are no available seats for this license');
if (!$seatId) {
// Get the next available seat for this license
$next = $license->freeSeat();
if (!$next) {
return redirect()->route('licenses.index')->with('error', 'There are no available seats for this license');
}
if (!$licenseSeat = LicenseSeat::where('id', '=', $next->id)->first()) {
return redirect()->route('licenses.index')->with('error', 'There are no available seats for this license');
}
} else {
$licenseSeat = LicenseSeat::where('id', '=', $seatId)->first();
if (!$licenseSeat) {
return redirect()->route('licenses.index')->with('error', 'License seat is not available for checkout');
}
}
if (!$licenseSeat = LicenseSeat::where('id', '=', $next->id)->first()) {
return redirect()->route('licenses.index')->with('error', 'There are no available seats for this license');
}
$this->authorize('checkout', $license);

View File

@@ -45,15 +45,21 @@ class ProfileController extends Controller
{
$user = Auth::user();
$user->first_name = Input::get('first_name');
$user->last_name = Input::get('last_name');
$user->website = Input::get('website');
$user->location_id = Input::get('location_id');
$user->gravatar = Input::get('gravatar');
$user->locale = Input::get('locale');
$user->first_name = $request->input('first_name');
$user->last_name = $request->input('last_name');
$user->website = $request->input('website');
$user->gravatar = $request->input('gravatar');
if (!config('app.lock_passwords')) {
$user->locale = $request->input('locale', 'en');
}
if ((Gate::allows('self.two_factor')) && ((Setting::getSettings()->two_factor_enabled=='1') && (!config('app.lock_passwords')))) {
$user->two_factor_optin = Input::get('two_factor_optin', '0');
$user->two_factor_optin = $request->input('two_factor_optin', '0');
}
if (Gate::allows('self.edit_location') && (!config('app.lock_passwords'))) {
$user->location_id = $request->input('location_id');
}
if (Input::file('avatar')) {

View File

@@ -401,6 +401,8 @@ class SettingsController extends Controller
$setting->footer_text = $request->input('footer_text');
$setting->skin = $request->input('skin');
$setting->show_url_in_emails = $request->input('show_url_in_emails', '0');
$setting->logo_print_assets = $request->input('logo_print_assets', '0');
// Only allow the site name and CSS to be changed if lock_passwords is false
@@ -537,7 +539,9 @@ class SettingsController extends Controller
return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error'));
}
$setting->locale = $request->input('locale', 'en');
if (!config('app.lock_passwords')) {
$setting->locale = $request->input('locale', 'en');
}
$setting->default_currency = $request->input('default_currency', '$');
$setting->date_display_format = $request->input('date_display_format');
$setting->time_display_format = $request->input('time_display_format');
@@ -791,30 +795,36 @@ class SettingsController extends Controller
if (Input::has('labels_display_name')) {
if ($request->has('labels_display_name')) {
$setting->labels_display_name = 1;
} else {
$setting->labels_display_name = 0;
}
if (Input::has('labels_display_serial')) {
if ($request->has('labels_display_serial')) {
$setting->labels_display_serial = 1;
} else {
$setting->labels_display_serial = 0;
}
if (Input::has('labels_display_tag')) {
if ($request->has('labels_display_tag')) {
$setting->labels_display_tag = 1;
} else {
$setting->labels_display_tag = 0;
}
}
if (Input::has('labels_display_tag')) {
if ($request->has('labels_display_tag')) {
$setting->labels_display_tag = 1;
} else {
$setting->labels_display_tag = 0;
}
if ($request->has('labels_display_model')) {
$setting->labels_display_model = 1;
} else {
$setting->labels_display_model = 0;
}
if ($setting->save()) {
return redirect()->route('settings.index')
->with('success', trans('admin/settings/message.update.success'));

View File

@@ -86,8 +86,11 @@ class UsersController extends Controller
$userPermissions = Helper::selectedPermissionsArray($permissions, Input::old('permissions', array()));
$permissions = $this->filterDisplayable($permissions);
$user = new User;
$user->activated = 1;
return view('users/edit', compact('groups', 'userGroups', 'permissions', 'userPermissions'))
->with('user', new User);
->with('user', $user);
}
/**
@@ -112,7 +115,7 @@ class UsersController extends Controller
$user->last_name = $request->input('last_name');
$user->locale = $request->input('locale');
$user->employee_num = $request->input('employee_num');
$user->activated = $request->input('activated', $user->activated);
$user->activated = $request->input('activated', 0);
$user->jobtitle = $request->input('jobtitle');
$user->phone = $request->input('phone');
$user->location_id = $request->input('location_id', null);
@@ -247,9 +250,10 @@ class UsersController extends Controller
}
}
} catch (UserNotFoundException $e) {
$error = trans('admin/users/message.user_not_found', compact('id'));
return redirect()->route('users.index')->with('error', $error);
} catch (ModelNotFoundException $e) {
return redirect()->route('users.index')
->with('error', trans('admin/users/message.user_not_found', compact('id')));
}
@@ -257,8 +261,6 @@ class UsersController extends Controller
if (Auth::user()->isSuperUser()) {
if ($request->has('groups')) {
$user->groups()->sync($request->input('groups'));
} else {
$user->groups()->sync(array());
}
}

View File

@@ -68,7 +68,9 @@ class UserImporter extends ItemImporter
'last_name' => $user->last_name,
'password' => $this->tempPassword,
];
$user->notify(new WelcomeNotification($data));
// UNCOMMENT this to re-enable sending email notifications on user import
// $user->notify(new WelcomeNotification($data));
}
$user = null;
$this->item = null;

View File

@@ -228,6 +228,9 @@ class Asset extends Depreciable
if($target->location) {
$this->location_id = $target->location->id;
}
if($target instanceof Location) {
$this->location_id = $target->id;
}
}
/**

View File

@@ -29,8 +29,8 @@ class AssetMaintenance extends Model implements ICompanyableChild
'asset_maintenance_type' => 'required',
'title' => 'required|max:100',
'is_warranty' => 'boolean',
'start_date' => 'required|date_format:"Y-m-d"',
'completion_date' => 'nullable|date_format:"Y-m-d"',
'start_date' => 'required|date',
'completion_date' => 'nullable|date',
'notes' => 'string|nullable',
'cost' => 'numeric|nullable'
];

View File

@@ -156,6 +156,10 @@ class Consumable extends SnipeModel
return $this->belongsToMany('\App\Models\User', 'consumables_users', 'consumable_id', 'assigned_to')->count();
}
public function checkin_email()
{
return $this->category->checkin_email;
}
public function requireAcceptance()
{

View File

@@ -228,7 +228,7 @@ class License extends Depreciable
public function checkin_email()
{
return $this->model->category->checkin_email;
return $this->category->checkin_email;
}
public function requireAcceptance()

View File

@@ -53,7 +53,7 @@ trait Searchable {
* @param string $search The search term
* @return array An array of search terms
*/
private function prepeareSearchTerms(string $search) {
private function prepeareSearchTerms($search) {
return explode(' OR ', $search);
}
@@ -68,6 +68,8 @@ trait Searchable {
$table = $this->getTable();
$firstConditionAdded = false;
foreach($this->getSearchableAttributes() as $column) {
foreach($terms as $term) {
@@ -80,6 +82,19 @@ trait Searchable {
continue;
}
/**
* We need to form the query properly, starting with a "where",
* otherwise the generated select is wrong.
*
* @todo This does the job, but is inelegant and fragile
*/
if (!$firstConditionAdded) {
$query = $query->where($table . '.' . $column, 'LIKE', '%'.$term.'%');
$firstConditionAdded = true;
continue;
}
$query = $query->orWhere($table . '.' . $column, 'LIKE', '%'.$term.'%');
}
}

View File

@@ -80,7 +80,7 @@ class CheckoutConsumableNotification extends Notification
/**
* Send an email if an email should be sent at checkin/checkout
*/
if ($this->item->checkin_email()) {
if ((method_exists($this->item, 'checkin_email')) && ($this->item->checkin_email())) {
$notifyBy[1] = 'mail';
}

View File

@@ -135,6 +135,10 @@ class AuthServiceProvider extends ServiceProvider
return $user->hasAccess('self.api');
});
Gate::define('self.edit_location', function($user) {
return $user->hasAccess('self.edit_location');
});
Gate::define('backend.interact', function ($user) {
return $user->can('view', Statuslabel::class)
|| $user->can('view', AssetModel::class)

View File

@@ -2,7 +2,7 @@
"name": "snipe/snipe-it",
"description": "Open source asset management system built on Laravel.",
"keywords": ["assets", "asset-management", "laravel"],
"license": "AGPL-3",
"license": "AGPL-3.0-or-later",
"type": "project",
"require": {
"php": ">=5.6.4",

View File

@@ -571,6 +571,13 @@ return array(
'display' => true,
),
array(
'permission' => 'self.edit_location',
'label' => 'Profile Edit Location',
'note' => 'The user may update their own location in their profile. Note that this is not affected by any additional Users permissions you grant to this user or group.',
'display' => true,
),
),

View File

@@ -1,10 +1,10 @@
<?php
return array (
'app_version' => 'v4.6.0',
'full_app_version' => 'v4.6.0 - build 3710-g961741b80',
'build_version' => '3710',
'app_version' => 'v4.6.4',
'full_app_version' => 'v4.6.4 - build 3881-g522dc1db2',
'build_version' => '3881',
'prerelease_version' => '',
'hash_version' => 'g961741b80',
'full_hash' => 'v4.6.0-3-g961741b80',
'hash_version' => 'g522dc1db2',
'full_hash' => 'v4.6.4-3881-g522dc1db2',
'branch' => 'master',
);

View File

@@ -26,7 +26,11 @@ $factory->define(Asset::class, function (Faker\Generator $faker) {
'purchase_cost' => $faker->randomFloat(2, '299.99', '2999.99'),
'order_number' => $faker->numberBetween(1000000, 50000000),
'supplier_id' => 1,
'requestable' => $faker->boolean()
'requestable' => $faker->boolean(),
'assigned_to' => null,
'assigned_type' => null,
'next_audit_date' => null,
'last_checkout' => null,
];
});

View File

@@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddLogoToPrintAssets extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('settings', function (Blueprint $table) {
$table->boolean('logo_print_assets')->default('0');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('settings', function (Blueprint $table) {
$table->dropColumn('logo_print_assets');
});
}
}

View File

@@ -32,3 +32,4 @@
# Header set X-Permitted-Cross-Domain-Policies "master-only"
</IfModule>
Options -Indexes

View File

@@ -88,6 +88,8 @@ return array(
'login_remote_user_custom_logout_url_text' => 'Custom logout URL',
'login_remote_user_custom_logout_url_help' => 'If a url is provided here, users will get redirected to this URL after the user logs out of Snipe-IT. This is useful to close the user sessions of your Authentication provider correctly.',
'logo' => 'Logo',
'logo_print_assets' => 'Use in Print',
'logo_print_assets_help' => 'Use branding on printable asset lists ',
'full_multiple_companies_support_help_text' => 'Restricting users (including admins) assigned to companies to their company\'s assets.',
'full_multiple_companies_support_text' => 'Full Multiple Companies Support',
'show_in_model_list' => 'Show in Model Dropdowns',

View File

@@ -2,6 +2,6 @@
return [
'sent' => 'Your password link has been sent!',
'user' => 'That user does not exist or does not have an email address associated',
'user' => 'No matching active user found with that email.',
];

View File

@@ -37,19 +37,29 @@
</div>
@can('self.edit_location')
<!-- Location -->
@include ('partials.forms.edit.location-profile-select', ['translated_name' => trans('general.location')])
@endcan
<!-- Language -->
<div class="form-group {{ $errors->has('locale') ? 'has-error' : '' }}">
<label class="col-md-3 control-label" for="locale">{{ trans('general.language') }}</label>
<div class="col-md-9">
{!! Form::locales('locale', Input::old('locale', $user->locale), 'select2') !!}
{!! $errors->first('locale', '<span class="alert-msg">:message</span>') !!}
@if (!config('app.lock_passwords'))
{!! Form::locales('locale', Input::old('locale', $user->locale), 'select2') !!}
{!! $errors->first('locale', '<span class="alert-msg">:message</span>') !!}
@else
<p class="help-block">{{ trans('general.feature_disabled') }}</p>
@endif
</div>
</div>
<!-- Website URL -->
<div class="form-group {{ $errors->has('website') ? ' has-error' : '' }}">
<label for="website" class="col-md-3 control-label">{{ trans('general.website') }}</label>

View File

@@ -32,41 +32,52 @@
</div>
<!-- Use default checkbox -->
<div class="checkbox col-md-offset-3">
<label>
<div class="form-group">
<div class="col-md-3">
</div>
<div class="col-md-9">
@if ($snipeSettings->default_eula_text!='')
{{ Form::checkbox('use_default_eula', '1', Input::old('use_default_eula', $item->use_default_eula)) }}
{!! trans('admin/categories/general.use_default_eula') !!}
{{ Form::checkbox('use_default_eula', '1', old('use_default_eula', $item->use_default_eula), ['class'=>'minimal']) }}
{!! trans('admin/categories/general.use_default_eula') !!}
@else
{{ Form::checkbox('use_default_eula', '0', Input::old('use_default_eula'), array('disabled' => 'disabled')) }}
{!! trans('admin/categories/general.use_default_eula_disabled') !!}
@endif
<div class="icheckbox disabled">
{{ Form::checkbox('use_default_eula', '0', old('use_default_eula'), ['class'=>'disabled minimal','disabled' => 'disabled']) }}
</label>
{!! trans('admin/categories/general.use_default_eula_disabled') !!}
</div>
@endif
</div>
</div>
<!-- Require Acceptance -->
<div class="checkbox col-md-offset-3">
<label>
{{ Form::checkbox('require_acceptance', '1', Input::old('require_acceptance', $item->require_acceptance)) }}
<div class="form-group">
<div class="col-md-3">
</div>
<div class="col-md-9">
{{ Form::checkbox('require_acceptance', '1', old('require_acceptance', $item->require_acceptance), ['class'=>'minimal']) }}
{{ trans('admin/categories/general.require_acceptance') }}
</label>
</div>
</div>
<!-- Email on Checkin -->
<div class="checkbox col-md-offset-3">
<label>
{{ Form::checkbox('checkin_email', '1', Input::old('checkin_email', $item->checkin_email)) }}
<div class="form-group">
<div class="col-md-3">
</div>
<div class="col-md-9">
{{ Form::checkbox('checkin_email', '1', old('checkin_email', $item->checkin_email), ['class'=>'minimal']) }}
{{ trans('admin/categories/general.checkin_email') }}
</label>
</div>
</div>
<!-- Image -->
@if ($item->image)
<div class="form-group {{ $errors->has('image_delete') ? 'has-error' : '' }}">
<label class="col-md-3 control-label" for="image_delete">{{ trans('general.image_delete') }}</label>
<div class="col-md-5">
<div class="col-md-9">
{{ Form::checkbox('image_delete') }}
<img src="{{ url('/') }}/uploads/categories/{{ $item->image }}" />
{!! $errors->first('image_delete', '<span class="alert-msg">:message</span>') !!}

View File

@@ -98,12 +98,12 @@
@else
<tr class="header-row permissions-row">
<td class="col-md-5 tooltip-base permissions-item header-name"
<td class="col-md-5 tooltip-base permissions-item header-name"
data-toggle="tooltip"
data-placement="right"
title="{{ $localPermission['note'] }}">
<h4>{{ $area . ': ' . $localPermission['label'] }}</h4>
<p>{{ $localPermission['note'] }}</p>
</td>
<td class="col-md-1 permissions-item" style="vertical-align: bottom">
@@ -135,9 +135,7 @@
@endif
@endforeach
<tr>
<td colspan="3"></td>
</tr>
@endif
@endforeach

View File

@@ -33,13 +33,16 @@
border-color: {{ $snipeSettings->header_color }};
}
@if ($snipeSettings->custom_css)
{{ $snipeSettings->show_custom_css() }}
@endif
</style>
@endif
@if (($snipeSettings) && ($snipeSettings->custom_css))
<style>
{!! $snipeSettings->show_custom_css() !!}
</style>
@endif
</head>
<body class="hold-transition login-page">
@@ -55,7 +58,7 @@
<div class="text-center" style="padding-top: 100px;">
@if ($snipeSettings->privacy_policy_link!='')
@if (($snipeSettings) && ($snipeSettings->privacy_policy_link!=''))
<a target="_blank" rel="noopener" href="{{ $snipeSettings->privacy_policy_link }}" target="_new">{{ trans('admin/settings/general.privacy_policy') }}</a>
@endif
</div>

View File

@@ -54,9 +54,7 @@
}
@endif
@if (($snipeSettings) && ($snipeSettings->custom_css!=''))
{!! $snipeSettings->show_custom_css() !!}
@endif
@media (max-width: 400px) {
.navbar-left {
@@ -69,6 +67,12 @@
}
</style>
@if (($snipeSettings) && ($snipeSettings->custom_css))
<style>
{!! $snipeSettings->show_custom_css() !!}
</style>
@endif
<script nonce="{{ csrf_token() }}">
window.snipeit = {
settings: {

View File

@@ -277,7 +277,7 @@
function licenseSeatInOutFormatter(value, row) {
// The user is allowed to check the license seat out and it's available
if ((row.available_actions.checkout == true) && (row.user_can_checkout == true) && ((!row.asset_id) && (!row.assigned_to))) {
return '<a href="{{ url('/') }}/licenses/' + row.license_id + '/checkout" class="btn btn-sm bg-maroon" data-tooltip="true" title="Check this item out">{{ trans('general.checkout') }}</a>';
return '<a href="{{ url('/') }}/licenses/' + row.license_id + '/checkout/'+row.id+'" class="btn btn-sm bg-maroon" data-tooltip="true" title="Check this item out">{{ trans('general.checkout') }}</a>';
} else {
return '<a href="{{ url('/') }}/licenses/' + row.id + '/checkin" class="btn btn-sm bg-purple" data-tooltip="true" title="Check in this license seat.">{{ trans('general.checkin') }}</a>';
}

View File

@@ -1,6 +1,6 @@
<div class="form-group {{ $errors->has('image') ? 'has-error' : '' }}">
<label class="col-md-3 control-label" for="image">{{ trans('general.image_upload') }}</label>
<div class="col-md-5">
<div class="col-md-9">
<label class="btn btn-default">
{{ trans('button.select_file') }}
<input type="file" name="image" id="uploadFile" data-maxsize="{{ \App\Helpers\Helper::file_upload_max_size() }}" accept="image/gif,image/jpeg,image/png,image/svg" style="display:none">

View File

@@ -93,7 +93,20 @@
{!! $errors->first('brand', '<span class="alert-msg">:message</span>') !!}
</div>
</div>
<!-- remote load -->
<!-- Include logo in print assets -->
<div class="form-group">
<div class="col-md-3">
{{ Form::label('logo_print_assets', trans('admin/settings/general.logo_print_assets')) }}
</div>
<div class="col-md-9">
{{ Form::checkbox('logo_print_assets', '1', Input::old('logo_print_assets', $setting->logo_print_assets),array('class' => 'minimal')) }}
{{ trans('admin/settings/general.logo_print_assets_help') }}
</div>
</div>
<!-- show urls in emails-->
<div class="form-group">
<div class="col-md-3">
{{ Form::label('show_url_in_emails', trans('admin/settings/general.show_url_in_emails')) }}

View File

@@ -118,7 +118,7 @@
</div>
<div class="col-md-9">
{{ Form::checkbox('load_remote', '1', Input::old('load_remote', $setting->load_remote),array('class' => 'minimal')) }}
{{ trans('admin/settings/general.load_remote_help_text') }}
<p class="help-block">{{ trans('admin/settings/general.load_remote_help_text') }}</p>
</div>
</div>

View File

@@ -335,7 +335,7 @@
<p class="help-block">{{ trans('general.feature_disabled') }}</p>
</div>
@elseif ($user->id === Auth::user()->id)
<div class="icheckbox disabled"" style="padding-left: 10px;">
<div class="icheckbox disabled" style="padding-left: 10px;">
{{ Form::checkbox('activated', '1', old('activated', $user->activated),['class' => 'minimal', 'disabled'=>'disabled']) }}
{{ trans('admin/users/general.activated_help_text') }}
<p class="help-block">{{ trans('admin/users/general.activated_disabled_help_text') }}</p>

View File

@@ -22,10 +22,34 @@
padding: 3px;
font-size: 12px;
}
.print-logo {
max-height: 40px;
}
</style>
</head>
<body>
<h3>Assigned to {{ $show_user->present()->fullName() }}</h3>
@if ($snipeSettings->logo_print_assets=='1')
@if ($snipeSettings->brand == '3')
<h3>
@if ($snipeSettings->logo!='')
<img class="print-logo" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">
@endif
{{ $snipeSettings->site_name }}
</h3>
@elseif ($snipeSettings->brand == '2')
@if ($snipeSettings->logo!='')
<img class="print-logo" src="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">
@endif
@else
<h3>{{ $snipeSettings->site_name }}</h3>
@endif
@endif
<h4>Assigned to {{ $show_user->present()->fullName() }}</h4>
@if ($assets->count() > 0)
@php

View File

@@ -11,12 +11,12 @@ Route::group([ 'prefix' => 'licenses', 'middleware' => ['auth'] ], function () {
'as' => 'licenses.freecheckout',
'uses' => 'LicensesController@getFreeLicense'
]);
Route::get('{licenseId}/checkout', [
Route::get('{licenseId}/checkout/{seatId?}', [
'as' => 'licenses.checkout',
'uses' => 'LicensesController@getCheckout'
]);
Route::post(
'{licenseId}/checkout',
'{licenseId}/checkout/{seatId?}',
[ 'as' => 'licenses.checkout', 'uses' => 'LicensesController@postCheckout' ]
);
Route::get('{licenseId}/checkin/{backto?}', [

View File

@@ -134,7 +134,7 @@ create_virtualhost () {
echo " <Directory $APP_PATH/public>"
echo " Allow From All"
echo " AllowOverride All"
echo " Options +Indexes"
echo " Options -Indexes"
echo " </Directory>"
echo ""
echo " DocumentRoot $APP_PATH/public"

View File

@@ -31,10 +31,15 @@ class ApiAssetsCest
$I->seeResponseIsJson();
$I->seeResponseCodeIs(200);
$response = json_decode($I->grabResponse(), true);
// FIXME: This is disabled because the statuslabel join is doing something weird in Api/AssetsController@index
// However, it's hiding other real test errors in other parts of the code, so disabling this for now until we can fix.
// $response = json_decode($I->grabResponse(), true);
// sample verify
$asset = Asset::orderByDesc('id')->take(20)->get()->first();
$I->seeResponseContainsJson($I->removeTimestamps((new AssetsTransformer)->transformAsset($asset)));
// $asset = Asset::orderByDesc('id')->take(20)->get()->first();
//
// $I->seeResponseContainsJson($I->removeTimestamps((new AssetsTransformer)->transformAsset($asset)));
}
/** @test */

View File

@@ -4,6 +4,7 @@ use App\Exceptions\CheckoutNotAllowed;
use App\Helpers\Helper;
use App\Models\Asset;
use App\Models\Setting;
use App\Models\Statuslabel;
use Illuminate\Support\Facades\Auth;
class ApiCheckoutAssetsCest
@@ -56,11 +57,13 @@ class ApiCheckoutAssetsCest
public function checkoutAssetToAsset(ApiTester $I) {
$I->wantTo('Check out an asset to an asset');
//Grab an asset from the database that isn't checked out.
$asset = Asset::whereNull('assigned_to')->where('model_id',8)->first(); // We need to make sure that this is an asset/model that doesn't require acceptance
$asset = Asset::whereNull('assigned_to')
->where('model_id',8)
->where('status_id', Statuslabel::deployable()->first()->id)
->first(); // We need to make sure that this is an asset/model that doesn't require acceptance
$targetAsset = factory('App\Models\Asset')->states('desktop-macpro')->create([
'name' => "Test Asset For Checkout to"
]);
// dd($targetAsset->model->category);
$data = [
'assigned_asset' => $targetAsset->id,
'checkout_to_type' => 'asset'
@@ -88,11 +91,13 @@ class ApiCheckoutAssetsCest
public function checkoutAssetToLocation(ApiTester $I) {
$I->wantTo('Check out an asset to an asset');
//Grab an asset from the database that isn't checked out.
$asset = Asset::whereNull('assigned_to')->where('model_id',8)->first();
$asset = Asset::whereNull('assigned_to')
->where('model_id',8)
->where('status_id', Statuslabel::deployable()->first()->id)
->first(); // We need to make sure that this is an asset/model that doesn't require acceptance
$targetLocation = factory('App\Models\Location')->create([
'name' => "Test Location for Checkout"
]);
// dd($targetAsset->model->category);
$data = [
'assigned_location' => $targetLocation->id,
'checkout_to_type' => 'location'

View File

@@ -58,7 +58,8 @@ class GroupsCest
public function allowsDelete(FunctionalTester $I, $scenario)
{
$scenario->incomplete('Fix this test to generate a group for deletes');
$scenario->incomplete('Fix this test to generate a group for deleting');
$I->wantTo('Ensure I can delete a group');
// create a group

View File

@@ -13,94 +13,87 @@ class AccessoryTest extends BaseTest
*/
protected $tester;
// public function testAccessoryAdd()
// {
// $accessory = factory(Accessory::class)->make();
public function testFailsEmptyValidation()
{
// An Accessory requires a name, a qty, and a category_id.
$a = Accessory::create();
$this->assertFalse($a->isValid());
$fields = [
'name' => 'name',
'qty' => 'qty',
'category_id' => 'category id'
];
$errors = $a->getErrors();
foreach ($fields as $field => $fieldTitle) {
$this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
}
}
public function testFailsMinValidation()
{
// An Accessory name has a min length of 3
// An Accessory has a min qty of 1
// An Accessory has a min amount of 0
$a = factory(Accessory::class)->make([
'name' => 'a',
'qty' => 0,
'min_amt' => -1
]);
$fields = [
'name' => 'name',
'qty' => 'qty',
'min_amt' => 'min amt'
];
$this->assertFalse($a->isValid());
$errors = $a->getErrors();
foreach ($fields as $field => $fieldTitle) {
$this->assertContains("The ${fieldTitle} must be at least", $errors->get($field)[0]);
}
}
// $values = [
// 'name' => $accessory->name,
// 'category_id' => $accessory->category_id,
// 'qty' => $accessory->qty,
// ];
// Accessory::create($values);
public function testCategoryIdMustExist()
{
$category = $this->createValidCategory('accessory-keyboard-category', ['category_type' => 'accessory']);
$accessory = factory(Accessory::class)->states('apple-bt-keyboard')->make(['category_id' => $category->id]);
$this->createValidManufacturer('apple');
// $this->tester->seeRecord('accessories', $values);
// }
$accessory->save();
$this->assertTrue($accessory->isValid());
$newId = $category->id + 1;
$accessory = factory(Accessory::class)->states('apple-bt-keyboard')->make(['category_id' => $newId]);
$accessory->save();
// public function testFailsEmptyValidation()
// {
// // An Accessory requires a name, a qty, and a category_id.
// $a = Accessory::create();
// $this->assertFalse($a->isValid());
// $fields = [
// 'name' => 'name',
// 'qty' => 'qty',
// 'category_id' => 'category id'
// ];
// $errors = $a->getErrors();
// foreach ($fields as $field => $fieldTitle) {
// $this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
// }
// }
$this->assertFalse($accessory->isValid());
$this->assertContains("The selected category id is invalid.", $accessory->getErrors()->get('category_id')[0]);
}
// public function testFailsMinValidation()
// {
// // An Accessory name has a min length of 3
// // An Accessory has a min qty of 1
// // An Accessory has a min amount of 0
// $a = factory(Accessory::class)->make([
// 'name' => 'a',
// 'qty' => 0,
// 'min_amt' => -1
// ]);
// $fields = [
// 'name' => 'name',
// 'qty' => 'qty',
// 'min_amt' => 'min amt'
// ];
// $this->assertFalse($a->isValid());
// $errors = $a->getErrors();
// foreach ($fields as $field => $fieldTitle) {
// $this->assertContains("The ${fieldTitle} must be at least", $errors->get($field)[0]);
// }
// }
public function testAnAccessoryBelongsToACompany()
{
$accessory = factory(Accessory::class)
->create(['company_id' => factory(App\Models\Company::class)->create()->id]);
$this->assertInstanceOf(App\Models\Company::class, $accessory->company);
}
// public function testCategoryIdMustExist()
// {
// $category = factory(Category::class)->create(['category_type' => 'accessory']);
// $accessory = factory(Accessory::class)->make(['category_id' => $category->id]);
// $accessory->save();
// $this->assertTrue($accessory->isValid());
// $newId = $category->id + 1;
// $accessory = factory(Accessory::class)->make(['category_id' => $newId]);
// $accessory->save();
public function testAnAccessoryHasALocation()
{
$accessory = factory(Accessory::class)
->create(['location_id' => factory(App\Models\Location::class)->create()->id]);
$this->assertInstanceOf(App\Models\Location::class, $accessory->location);
}
// $this->assertFalse($accessory->isValid());
// }
public function testAnAccessoryBelongsToACategory()
{
$accessory = factory(Accessory::class)->states('apple-bt-keyboard')
->create(['category_id' => factory(Category::class)->states('accessory-keyboard-category')->create(['category_type' => 'accessory'])->id]);
$this->assertInstanceOf(App\Models\Category::class, $accessory->category);
$this->assertEquals('accessory', $accessory->category->category_type);
}
// public function testAnAccessoryBelongsToACompany()
// {
// $accessory = factory(Accessory::class)->create();
// $this->assertInstanceOf(App\Models\Company::class, $accessory->company);
// }
// public function testAnAccessoryHasALocation()
// {
// $accessory = factory(Accessory::class)->create();
// $this->assertInstanceOf(App\Models\Location::class, $accessory->location);
// }
// public function testAnAccessoryBelongsToACategory()
// {
// $accessory = factory(Accessory::class)->create();
// $this->assertInstanceOf(App\Models\Category::class, $accessory->category);
// $this->assertEquals('accessory', $accessory->category->category_type);
// }
// public function testAnAccessoryHasAManufacturer()
// {
// $accessory = factory(Accessory::class)->create();
// $this->assertInstanceOf(App\Models\Manufacturer::class, $accessory->manufacturer);
// }
public function testAnAccessoryHasAManufacturer()
{
$this->createValidManufacturer('apple');
$this->createValidCategory('accessory-keyboard-category');
$accessory = factory(Accessory::class)->states('apple-bt-keyboard')->create(['category_id' => 1]);
$this->assertInstanceOf(App\Models\Manufacturer::class, $accessory->manufacturer);
}
}

View File

@@ -13,69 +13,58 @@ class AssetModelTest extends BaseTest
*/
protected $tester;
// public function testAssetModelAdd()
// {
// $assetmodel = factory(AssetModel::class)->make();
// $values = [
// 'name' => $assetmodel->name,
// 'manufacturer_id' => $assetmodel->manufacturer_id,
// 'category_id' => $assetmodel->category_id,
// 'eol' => $assetmodel->eol,
// ];
// AssetModel::create($values);
// $this->tester->seeRecord('models', $values);
// }
public function testAnAssetModelRequiresAttributes()
{
// An Asset Model requires a name, a category_id, and a manufacturer_id.
$a = AssetModel::create();
$this->assertFalse($a->isValid());
$fields = [
'name' => 'name',
'manufacturer_id' => 'manufacturer id',
'category_id' => 'category id'
];
$errors = $a->getErrors();
foreach ($fields as $field => $fieldTitle) {
$this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
}
}
// public function testAnAssetModelRequiresAttributes()
// {
// // An Asset Model requires a name, a category_id, and a manufacturer_id.
// $a = AssetModel::create();
// $this->assertFalse($a->isValid());
// $fields = [
// 'name' => 'name',
// 'manufacturer_id' => 'manufacturer id',
// 'category_id' => 'category id'
// ];
// $errors = $a->getErrors();
// foreach ($fields as $field => $fieldTitle) {
// $this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
// }
// }
public function testAnAssetModelZerosOutBlankEols()
{
$am = new AssetModel;
$am->eol = '';
$this->assertTrue($am->eol === 0);
$am->eol = '4';
$this->assertTrue($am->eol==4);
}
// public function testAnAssetModelZerosOutBlankEols()
// {
// $am = new AssetModel;
// $am->eol = '';
// $this->assertTrue($am->eol === 0);
// $am->eol = '4';
// $this->assertTrue($am->eol==4);
// }
public function testAnAssetModelContainsAssets()
{
$assetModel = $this->createValidAssetModel();
factory(Asset::class)->create([
'model_id' => $assetModel->id,
]);
$this->assertEquals(1,$assetModel->assets()->count());
}
// public function testAnAssetModelContainsAssets()
// {
// $assetmodel = factory(AssetModel::class)->create();
// $asset = factory(Asset::class)->create([
// 'model_id' => $assetmodel->id,
// ]);
// $this->assertEquals(1,$assetmodel->assets()->count());
// }
public function testAnAssetModelHasACategory()
{
$assetmodel = $this->createValidAssetModel();
$this->assertInstanceOf(App\Models\Category::class, $assetmodel->category);
}
// public function testAnAssetModelHasACategory()
// {
// $assetmodel = factory(AssetModel::class)->create();
// $this->assertInstanceOf(App\Models\Category::class, $assetmodel->category);
// }
public function testAnAssetModelHasADepreciation()
{
// public function anAssetModelHasADepreciation()
// {
// $assetmodel = factory(AssetModel::class)->create();
// $this->assertInstanceOf(App\Models\Depreciation::class, $assetmodel->depreciation);
// }
$assetmodel = $this->createValidAssetModel();
$this->assertInstanceOf(App\Models\Depreciation::class, $assetmodel->depreciation);
}
public function testAnAssetModelHasAManufacturer()
{
$assetmodel = $this->createValidAssetModel();
$this->assertInstanceOf(App\Models\Manufacturer::class, $assetmodel->manufacturer);
}
// public function testAnAssetModelHasAManufacturer()
// {
// $assetmodel = factory(AssetModel::class)->create();
// $this->assertInstanceOf(App\Models\Manufacturer::class, $assetmodel->manufacturer);
// }
}

View File

@@ -5,6 +5,7 @@ use App\Models\AssetModel;
use App\Models\Company;
use App\Models\Location;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Support\Facades\Hash;
@@ -16,36 +17,23 @@ class AssetTest extends BaseTest
*/
protected $tester;
// public function testAssetAdd()
// {
// $asset = factory(Asset::class)->make();
// $values = [
// 'name' => $asset->name,
// 'model_id' => $asset->model_id,
// 'status_id' => $asset->status_id,
// 'asset_tag' => $asset->asset_tag,
// ];
// Asset::create($values);
// $this->tester->seeRecord('assets', $values);
// }
public function testFailsEmptyValidation()
{
// An Asset requires a name, a qty, and a category_id.
$a = Asset::create();
$this->assertFalse($a->isValid());
// public function testFailsEmptyValidation()
// {
// // An Asset requires a name, a qty, and a category_id.
// $a = Asset::create();
// $this->assertFalse($a->isValid());
// $fields = [
// 'model_id' => 'model id',
// 'status_id' => 'status id',
// 'asset_tag' => 'asset tag'
// ];
// $errors = $a->getErrors();
// foreach ($fields as $field => $fieldTitle) {
// $this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
// }
// }
$fields = [
'model_id' => 'model id',
'status_id' => 'status id',
'asset_tag' => 'asset tag'
];
$errors = $a->getErrors();
foreach ($fields as $field => $fieldTitle) {
$this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
}
}
public function testAutoIncrementMixed()
@@ -66,246 +54,258 @@ class AssetTest extends BaseTest
$this->assertEquals($expected, $next);
}
// public function testAutoIncrementMixedFullTagNumber()
// {
// $expected = '123411';
// $next = Asset::nextAutoIncrement(
// [
// ['asset_tag' => '0012345'],
// ['asset_tag' => 'WTF00134'],
// ['asset_tag' => 'WTF-745'],
// ['asset_tag' => '0012346'],
// ['asset_tag' => '00123410'],
// ['asset_tag' => 'U8T7597h77']
// ]
// );
// $this->assertEquals($expected, $next);
// }
//
public function testAutoIncrementMixedFullTagNumber()
{
$expected = '123411';
$next = Asset::nextAutoIncrement(
[
['asset_tag' => '0012345'],
['asset_tag' => 'WTF00134'],
['asset_tag' => 'WTF-745'],
['asset_tag' => '0012346'],
['asset_tag' => '00123410'],
['asset_tag' => 'U8T7597h77']
]
);
$this->assertEquals($expected, $next);
}
/**
* @test
*/
// public function testWarrantyExpiresAttribute()
// {
// $asset = factory(\App\Models\Asset::class)->create();
public function testWarrantyExpiresAttribute()
{
$asset = factory(Asset::class)->states('laptop-mbp')->create(['model_id' => $this->createValidAssetModel()->id]);
// $asset->purchase_date = \Carbon\Carbon::createFromDate(2017, 1, 1)->hour(0)->minute(0)->second(0);
// $asset->warranty_months = 24;
// $asset->save();
$asset->purchase_date = Carbon::createFromDate(2017, 1, 1)->hour(0)->minute(0)->second(0);
$asset->warranty_months = 24;
$asset->save();
// $saved_asset = \App\Models\Asset::find($asset->id);
$saved_asset = Asset::find($asset->id);
// $this->tester->assertInstanceOf(\DateTime::class, $saved_asset->purchase_date);
// $this->tester->assertEquals(
// \Carbon\Carbon::createFromDate(2017, 1, 1)->format('Y-m-d'),
// $saved_asset->purchase_date->format('Y-m-d')
// );
// $this->tester->assertEquals(
// \Carbon\Carbon::createFromDate(2017, 1, 1)->setTime(0, 0, 0),
// $saved_asset->purchase_date
// );
// $this->tester->assertEquals(24, $saved_asset->warranty_months);
// $this->tester->assertInstanceOf(\DateTime::class, $saved_asset->warranty_expires);
// $this->tester->assertEquals(
// \Carbon\Carbon::createFromDate(2019, 1, 1)->format('Y-m-d'),
// $saved_asset->warranty_expires->format('Y-m-d')
// );
// $this->tester->assertEquals(
// \Carbon\Carbon::createFromDate(2019, 1, 1)->setTime(0, 0, 0),
// $saved_asset->warranty_expires
// );
// }
$this->tester->assertInstanceOf(\DateTime::class, $saved_asset->purchase_date);
$this->tester->assertEquals(
Carbon::createFromDate(2017, 1, 1)->format('Y-m-d'),
$saved_asset->purchase_date->format('Y-m-d')
);
$this->tester->assertEquals(
Carbon::createFromDate(2017, 1, 1)->setTime(0, 0, 0),
$saved_asset->purchase_date
);
$this->tester->assertEquals(24, $saved_asset->warranty_months);
$this->tester->assertInstanceOf(\DateTime::class, $saved_asset->warranty_expires);
$this->tester->assertEquals(
Carbon::createFromDate(2019, 1, 1)->format('Y-m-d'),
$saved_asset->warranty_expires->format('Y-m-d')
);
$this->tester->assertEquals(
Carbon::createFromDate(2019, 1, 1)->setTime(0, 0, 0),
$saved_asset->warranty_expires
);
}
// public function testModelIdMustExist()
// {
// $model = factory(AssetModel::class)->create();
// $asset = factory(Asset::class)->make(['model_id' => $model->id]);
// $asset->save();
// $this->assertTrue($asset->isValid());
// $newId = $model->id + 1;
// $asset = factory(Asset::class)->make(['model_id' => $newId]);
// $asset->save();
public function testModelIdMustExist()
{
$model = $this->createValidAssetModel();
$asset = factory(Asset::class)->make(['model_id' => $model->id]);
$asset->save();
$this->assertTrue($asset->isValid());
$newId = $model->id + 1;
$asset = factory(Asset::class)->make(['model_id' => $newId]);
$asset->save();
// $this->assertFalse($asset->isValid());
// }
$this->assertFalse($asset->isValid());
}
// public function testAnAssetHasRelationships()
// {
// $asset = factory(Asset::class)->create();
// $this->assertInstanceOf(AssetModel::class, $asset->model);
// $this->assertInstanceOf(Company::class, $asset->company);
// $this->assertInstanceOf(App\Models\Depreciation::class, $asset->depreciation);
// $this->assertInstanceOf(App\Models\Statuslabel::class, $asset->assetstatus);
// $this->assertInstanceOf(App\Models\Supplier::class, $asset->supplier);
// }
public function testAnAssetHasRelationships()
{
$asset = factory(Asset::class)->states('laptop-mbp')
->create([
'model_id' => $this->createValidAssetModel()->id,
'company_id' => $this->createValidCompany()->id,
'supplier_id' => $this->createValidSupplier()->id,
]);
$this->assertInstanceOf(AssetModel::class, $asset->model);
$this->assertInstanceOf(Company::class, $asset->company);
$this->assertInstanceOf(App\Models\Depreciation::class, $asset->depreciation);
$this->assertInstanceOf(App\Models\Statuslabel::class, $asset->assetstatus);
$this->assertInstanceOf(App\Models\Supplier::class, $asset->supplier);
}
// public function testAnAssetCanBeAvailableForCheckout()
// {
// // Logic: If the asset is not assigned to anyone,
// // and the statuslabel type is "deployable"
// // and the asset is not deleted
// // Then it is available for checkout
public function testAnAssetCanBeAvailableForCheckout()
{
// Logic: If the asset is not assigned to anyone,
// and the statuslabel type is "deployable"
// and the asset is not deleted
// Then it is available for checkout
// // An asset assigned to someone should not be available for checkout.
// $user = factory(App\Models\User::class)->create();
// $assetAssigned = factory(Asset::class)->create(['assigned_to' => $user->id]);
// $this->assertFalse($assetAssigned->availableForCheckout());
// An asset assigned to someone should not be available for checkout.
$assetAssigned = factory(Asset::class)
->states('laptop-mbp', 'assigned-to-user')
->create(['model_id' => $this->createValidAssetModel()]);
$this->assertFalse($assetAssigned->availableForCheckout());
// // An asset with a non deployable statuslabel should not be available for checkout.
// $status = factory(App\Models\Statuslabel::class)->states('archived')->create();
// $assetUndeployable = factory(Asset::class)->create(['status_id' => $status->id]);
// $this->assertFalse($assetUndeployable->availableForCheckout());
// An asset with a non deployable statuslabel should not be available for checkout.
$assetUndeployable = factory(Asset::class)->create([
'status_id' => $this->createValidStatuslabel('archived')->id,
'model_id' => $this->createValidAssetModel()
]);
// // An asset that has been deleted is not avaiable for checkout.
// $assetDeleted = factory(Asset::class)->states('deleted')->create();
// $this->assertFalse($assetDeleted->availableForCheckout());
$this->assertFalse($assetUndeployable->availableForCheckout());
// // A ready to deploy asset that isn't assigned to anyone is available for checkout
// $status = factory(App\Models\Statuslabel::class)->states('rtd')->create();
// $asset = factory(Asset::class)->create(['status_id' => $status->id]);
// $this->assertTrue($asset->availableForCheckout());
// }
// An asset that has been deleted is not avaiable for checkout.
$assetDeleted = factory(Asset::class)->states('deleted')->create([
'model_id' => $this->createValidAssetModel()
]);
$this->assertFalse($assetDeleted->availableForCheckout());
// public function testAnAssetCanHaveComponents()
// {
// $asset = factory(Asset::class)->create();
// $components = factory(App\Models\Component::class, 5)->create();
// $components->each(function($component) use ($asset) {
// $component->assets()->attach($component, [
// 'asset_id'=>$asset->id
// ]);
// });
// $this->assertInstanceOf(App\Models\Component::class, $asset->components()->first());
// $this->assertCount(5, $asset->components);
// }
// A ready to deploy asset that isn't assigned to anyone is available for checkout
$asset = factory(Asset::class)->create([
'status_id' => $this->createValidStatuslabel('rtd')->id,
'model_id' => $this->createValidAssetModel()
]);
$this->assertTrue($asset->availableForCheckout());
}
// public function testAnAssetCanHaveUploads()
// {
// $asset = factory(Asset::class)->create();
// $this->assertCount(0, $asset->uploads);
// factory(App\Models\Actionlog::class, 'asset-upload')->create(['item_id' => $asset->id]);
// $this->assertCount(1, $asset->fresh()->uploads);
// }
public function testAnAssetCanHaveComponents()
{
$asset = $this->createValidAsset();
// // Helper Method for checking in assets.... We should extract this to the model or a trait.
$components = factory(App\Models\Component::class, 5)->states('ram-crucial4')->create([
'category_id' => $this->createValidCategory('component-hdd-category')->id
]);
// private function checkin($asset, $target) {
// $asset->expected_checkin = null;
// $asset->last_checkout = null;
// $asset->assigned_to = null;
// $asset->assigned_type = null;
// $asset->assignedTo()->disassociate($asset);
// $asset->accepted = null;
// $asset->save();
// $asset->logCheckin($target, 'Test Checkin');
// }
$components->each(function($component) use ($asset) {
$component->assets()->attach($component, [
'asset_id'=>$asset->id
]);
});
$this->assertInstanceOf(App\Models\Component::class, $asset->components()->first());
$this->assertCount(5, $asset->components);
}
// public function testAnAssetCanBeCheckedOut()
// {
// // This tests Asset::checkOut(), Asset::assignedTo(), Asset::assignedAssets(), Asset::assetLoc(), Asset::assignedType(), defaultLoc()
// $asset = factory(Asset::class)->create();
// $adminUser = $this->signIn();
public function testAnAssetCanHaveUploads()
{
$asset = $this->createValidAsset();
$this->assertCount(0, $asset->uploads);
factory(App\Models\Actionlog::class, 'asset-upload')->create(['item_id' => $asset->id]);
$this->assertCount(1, $asset->fresh()->uploads);
}
// $target = factory(App\Models\User::class)->create();
// // An Asset Can be checked out to a user, and this should be logged.
// $asset->checkOut($target, $adminUser);
// $asset->save();
// Helper Method for checking in assets.... We should extract this to the model or a trait.
// $this->assertInstanceOf(App\Models\User::class, $asset->assignedTo);
// $this->assertEquals($asset->assetLoc->id, $target->userLoc->id);
// $this->assertEquals('user', $asset->assignedType());
// $this->assertEquals($asset->defaultLoc->id, $asset->rtd_location_id);
// $this->tester->seeRecord('action_logs', [
// 'action_type' => 'checkout',
// 'target_type' => get_class($target),
// 'target_id' => $target->id
// ]);
private function checkin($asset, $target) {
$asset->expected_checkin = null;
$asset->last_checkout = null;
$asset->assigned_to = null;
$asset->assigned_type = null;
$asset->location_id = $asset->rtd_location_id;
$asset->assignedTo()->disassociate($asset);
$asset->accepted = null;
$asset->save();
$asset->logCheckin($target, 'Test Checkin');
}
// $this->tester->seeRecord('assets', [
// 'id' => $asset->id,
// 'assigned_to' => $target->id,
// 'assigned_type' => User::class
// ]);
public function testAnAssetCanBeCheckedOut()
{
// This tests Asset::checkOut(), Asset::assignedTo(), Asset::assignedAssets(), Asset::assetLoc(), Asset::assignedType(), defaultLoc()
$asset = $this->createValidAsset();
$adminUser = $this->signIn();
// $this->checkin($asset, $target);
// $this->assertNull($asset->fresh()->assignedTo);
$target = factory(App\Models\User::class)->create([
'location_id' => factory(App\Models\Location::class)->create()
]);
// An Asset Can be checked out to a user, and this should be logged.
$asset->checkOut($target, $adminUser);
$asset->save();
$this->assertInstanceOf(App\Models\User::class, $asset->assignedTo);
// $this->tester->seeRecord('action_logs', [
// 'action_type' => 'checkin from',
// 'target_type' => get_class($target),
// 'target_id' => $target->id
// ]);
$this->assertEquals($asset->location->id, $target->userLoc->id);
$this->assertEquals('user', $asset->assignedType());
$this->assertEquals($asset->defaultLoc->id, $asset->rtd_location_id);
$this->tester->seeRecord('action_logs', [
'action_type' => 'checkout',
'target_type' => get_class($target),
'target_id' => $target->id
]);
// $this->tester->seeRecord('assets', [
// 'id' => $asset->id,
// 'assigned_to' => null,
// 'assigned_type' => null
// ]);
$this->tester->seeRecord('assets', [
'id' => $asset->id,
'assigned_to' => $target->id,
'assigned_type' => User::class
]);
// // An Asset Can be checked out to a asset, and this should be logged.
// $target = factory(App\Models\Asset::class)->create();
// $asset->checkOut($target, $adminUser);
// $asset->save();
// $this->assertInstanceOf(App\Models\Asset::class, $asset->fresh()->assignedTo);
// $this->assertEquals($asset->fresh()->assetLoc->id, $target->fresh()->assetLoc->id);
// $this->assertEquals('asset', $asset->assignedType());
// $this->assertEquals($asset->defaultLoc->id, $asset->rtd_location_id);
// $this->tester->seeRecord('action_logs', [
// 'action_type' => 'checkout',
// 'target_type' => get_class($target),
// 'target_id' => $target->id
// ]);
$this->checkin($asset, $target);
$this->assertNull($asset->fresh()->assignedTo);
// $this->assertCount(1, $target->assignedAssets);
// $this->checkin($asset, $target);
// $this->assertNull($asset->fresh()->assignedTo);
$this->tester->seeRecord('action_logs', [
'action_type' => 'checkin from',
'target_type' => get_class($target),
'target_id' => $target->id
]);
// $this->tester->seeRecord('action_logs', [
// 'action_type' => 'checkin from',
// 'target_type' => get_class($target),
// 'target_id' => $target->id
// ]);
$this->tester->seeRecord('assets', [
'id' => $asset->id,
'assigned_to' => null,
'assigned_type' => null
]);
// // An Asset Can be checked out to a location, and this should be logged.
// $target = factory(App\Models\Location::class)->create();
// $asset->checkOut($target, $adminUser);
// $asset->save();
// $this->assertInstanceOf(App\Models\Location::class, $asset->fresh()->assignedTo);
// $this->assertEquals($asset->fresh()->assetLoc->id, $target->fresh()->id);
// $this->assertEquals('location', $asset->assignedType());
// $this->assertEquals($asset->defaultLoc->id, $asset->rtd_location_id);
// $this->tester->seeRecord('action_logs', [
// 'action_type' => 'checkout',
// 'target_type' => get_class($target),
// 'target_id' => $target->id
// ]);
// $this->checkin($asset, $target);
// $this->assertNull($asset->fresh()->assignedTo);
// An Asset Can be checked out to a asset, and this should be logged.
$target = $this->createValidAsset();
// $this->tester->seeRecord('action_logs', [
// 'action_type' => 'checkin from',
// 'target_type' => get_class($target),
// 'target_id' => $target->id
// ]);
// }
$asset->checkOut($target, $adminUser);
$asset->save();
$this->assertInstanceOf(App\Models\Asset::class, $asset->fresh()->assignedTo);
$this->assertEquals($asset->fresh()->location->id, $target->fresh()->location->id);
$this->assertEquals('asset', $asset->assignedType());
$this->assertEquals($asset->defaultLoc->id, $asset->rtd_location_id);
$this->tester->seeRecord('action_logs', [
'action_type' => 'checkout',
'target_type' => get_class($target),
'target_id' => $target->id
]);
// public function testAnAssetHasMaintenances()
// {
// $asset = factory(Asset::class)->create();
// factory(App\Models\AssetMaintenance::class)->create(['asset_id' => $asset->id]);
// $this->assertCount(1, $asset->assetmaintenances);
// }
$this->assertCount(1, $target->assignedAssets);
$this->checkin($asset, $target);
$this->assertNull($asset->fresh()->assignedTo);
// public function testAnAssetThatRequiresAcceptanceCanNotBeCheckedOutToANonUser()
// {
// $this->expectException(CheckoutNotAllowed::class);
// $this->signIn();
$this->tester->seeRecord('action_logs', [
'action_type' => 'checkin from',
'target_type' => get_class($target),
'target_id' => $target->id
]);
// $asset = factory(Asset::class)->states('requires-acceptance')->create();
// An Asset Can be checked out to a location, and this should be logged.
$target = $this->createValidLocation();
// $location = factory(Location::class)->create();
// $asset->checkOut($location);
// }
$asset->checkOut($target, $adminUser);
$asset->save();
$this->assertInstanceOf(App\Models\Location::class, $asset->fresh()->assignedTo);
$this->assertEquals($asset->fresh()->location->id, $target->fresh()->id);
$this->assertEquals('location', $asset->assignedType());
$this->assertEquals($asset->defaultLoc->id, $asset->rtd_location_id);
$this->tester->seeRecord('action_logs', [
'action_type' => 'checkout',
'target_type' => get_class($target),
'target_id' => $target->id
]);
$this->checkin($asset, $target);
$this->assertNull($asset->fresh()->assignedTo);
$this->tester->seeRecord('action_logs', [
'action_type' => 'checkin from',
'target_type' => get_class($target),
'target_id' => $target->id
]);
}
public function testAnAssetHasMaintenances()
{
$asset = $this->createValidAsset();
factory(App\Models\AssetMaintenance::class)->create(['asset_id' => $asset->id]);
$this->assertCount(1, $asset->assetmaintenances);
}
}

View File

@@ -22,4 +22,74 @@ class BaseTest extends \Codeception\TestCase\Test
return $user;
}
protected function createValidAssetModel($state = 'mbp-13-model', $overrides = [])
{
return factory(\App\Models\AssetModel::class)->states($state)->create(array_merge([
'category_id' => $this->createValidCategory(),
'manufacturer_id' => $this->createValidManufacturer(),
'depreciation_id' => $this->createValidDepreciation(),
],$overrides));
}
protected function createValidCategory($state = 'asset-laptop-category', $overrides = [])
{
return factory(App\Models\Category::class)->states($state)->create($overrides);
}
protected function createValidCompany($overrides = [])
{
return factory(App\Models\Company::class)->create($overrides);
}
protected function createValidDepartment($state = 'engineering', $overrides = [])
{
return factory(App\Models\Department::class)->states($state)->create(array_merge([
'location_id' => $this->createValidLocation()->id
], $overrides));
}
protected function createValidDepreciation($state = 'computer', $overrides = [])
{
return factory(App\Models\Depreciation::class)->states($state)->create($overrides);
}
protected function createValidLocation($overrides = [])
{
return factory(App\Models\Location::class)->create($overrides);
}
protected function createValidManufacturer($state = 'apple', $overrides = [])
{
return factory(App\Models\Manufacturer::class)->states($state)->create($overrides);
}
protected function createValidSupplier($overrides = [])
{
return factory(App\Models\Supplier::class)->create($overrides);
}
protected function createValidStatuslabel($state = 'rtd', $overrides= [])
{
return factory(App\Models\Statuslabel::class)->states($state)->create($overrides);
}
protected function createValidUser($overrides= [])
{
return factory(App\Models\User::class)->create($overrides);
}
protected function createValidAsset($overrides = [])
{
$locId = $this->createValidLocation();
$this->createValidAssetModel();
return factory(\App\Models\Asset::class)->states('laptop-mbp')->create([
'rtd_location_id' => $locId,
'location_id' => $locId
], $overrides);
}
}

View File

@@ -12,84 +12,59 @@ class CategoryTest extends BaseTest
*/
protected $tester;
// public function testAssetCategoryAdd()
// {
// $category = factory(Category::class)->make(['category_type' => 'asset']);
// $values = [
// 'name' => $category->name,
// 'category_type' => $category->category_type,
// 'require_acceptance' => true,
// 'use_default_eula' => false
// ];
public function testFailsEmptyValidation()
{
// An Asset requires a name, a qty, and a category_id.
$a = Category::create();
$this->assertFalse($a->isValid());
// Category::create($values);
// $this->tester->seeRecord('categories', $values);
// }
$fields = [
'name' => 'name',
'category_type' => 'category type'
];
$errors = $a->getErrors();
foreach ($fields as $field => $fieldTitle) {
$this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
}
}
// public function testAccessoryCategoryAdd()
// {
// $category = factory(Category::class)->make(['category_type' => 'accessory']);
// $values = [
// 'name' => $category->name,
// 'category_type' => $category->category_type,
// 'require_acceptance' => true,
// 'use_default_eula' => false
// ];
public function testACategoryCanHaveAssets()
{
$this->createValidAssetModel(); //This will seed various things to make the following work better.
$category = $this->createValidCategory('asset-desktop-category');
$models = factory(App\Models\AssetModel::class, 5)->states('mbp-13-model')->create(['category_id' => $category->id]);
// Category::create($values);
// $this->tester->seeRecord('categories', $values);
// }
$this->assertEquals(5, $category->has_models());
$this->assertCount(5, $category->models);
// public function testFailsEmptyValidation()
// {
// // An Asset requires a name, a qty, and a category_id.
// $a = Category::create();
// $this->assertFalse($a->isValid());
$models->each(function($model) {
factory(App\Models\Asset::class, 2)->create(['model_id' => $model->id]);
});
$this->assertEquals(10, $category->itemCount());
}
// $fields = [
// 'name' => 'name',
// 'category_type' => 'category type'
// ];
// $errors = $a->getErrors();
// foreach ($fields as $field => $fieldTitle) {
// $this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
// }
// }
public function testACategoryCanHaveAccessories()
{
$category = $this->createValidCategory('accessory-keyboard-category');
factory(App\Models\Accessory::class, 5)->states('apple-bt-keyboard')->create(['category_id' => $category->id]);
// public function testACategoryCanHaveAssets()
// {
// $category = factory(Category::class)->create(['category_type' => 'asset']);
// $models = factory(App\Models\AssetModel::class, 5)->create(['category_id' => $category->id]);
// $this->assertEquals(5, $category->has_models());
// $this->assertCount(5, $category->models);
$this->assertCount(5, $category->accessories);
$this->assertEquals(5, $category->itemCount());
}
// $models->each(function($model) {
// factory(App\Models\Asset::class, 2)->create(['model_id' => $model->id]);
// });
// $this->assertEquals(10, $category->itemCount());
// }
public function testACategoryCanHaveConsumables()
{
$category = $this->createValidCategory('consumable-paper-category');
factory(App\Models\Consumable::class, 5)->states('cardstock')->create(['category_id' => $category->id]);
$this->assertCount(5, $category->consumables);
$this->assertEquals(5, $category->itemCount());
}
// public function testACategoryCanHaveAccessories()
// {
// $category = factory(Category::class)->create(['category_type' => 'accessory']);
// factory(App\Models\Accessory::class, 5)->create(['category_id' => $category->id]);
// $this->assertCount(5, $category->accessories);
// $this->assertEquals(5, $category->itemCount());
// }
// public function testACategoryCanHaveConsumables()
// {
// $category = factory(Category::class)->create(['category_type' => 'consumable']);
// factory(App\Models\Consumable::class, 5)->create(['category_id' => $category->id]);
// $this->assertCount(5, $category->consumables);
// $this->assertEquals(5, $category->itemCount());
// }
// public function testACategoryCanHaveComponents()
// {
// $category = factory(Category::class)->create(['category_type' => 'component']);
// factory(App\Models\Component::class, 5)->create(['category_id' => $category->id]);
// $this->assertCount(5, $category->components);
// $this->assertEquals(5, $category->itemCount());
// }
public function testACategoryCanHaveComponents()
{
$category = $this->createValidCategory('component-ram-category');
factory(App\Models\Component::class, 5)->states('ram-crucial4')->create(['category_id' => $category->id]);
$this->assertCount(5, $category->components);
$this->assertEquals(5, $category->itemCount());
}
}

View File

@@ -12,71 +12,78 @@ class CompanyTest extends BaseTest
*/
protected $tester;
// public function testCompanyAdd()
// {
// $company = factory(Company::class)->make();
// $values = [
// 'name' => $company->name,
// ];
// Company::create($values);
// $this->tester->seeRecord('companies', $values);
// }
public function testFailsEmptyValidation()
{
// An Company requires a name, a qty, and a category_id.
$a = Company::create();
$this->assertFalse($a->isValid());
// public function testFailsEmptyValidation()
// {
// // An Company requires a name, a qty, and a category_id.
// $a = Company::create();
// $this->assertFalse($a->isValid());
$fields = [
'name' => 'name',
];
$errors = $a->getErrors();
foreach ($fields as $field => $fieldTitle) {
$this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
}
}
// $fields = [
// 'name' => 'name',
// ];
// $errors = $a->getErrors();
// foreach ($fields as $field => $fieldTitle) {
// $this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
// }
// }
public function testACompanyCanHaveUsers()
{
$company = $this->createValidCompany();
factory(App\Models\User::class, 1)->create(['company_id'=>$company->id]);
$this->assertCount(1, $company->users);
}
// public function testACompanyCanHaveUsers()
// {
// $company = factory(Company::class)->create();
// factory(App\Models\User::class, 1)->create(['company_id'=>$company->id]);
// $this->assertCount(1, $company->users);
// }
public function testACompanyCanHaveAssets()
{
$company = $this->createValidCompany();
factory(App\Models\Asset::class, 1)->states('laptop-mbp')->create([
'company_id' => $company->id,
'model_id' => $this->createValidAssetModel()->id
]);
$this->assertCount(1, $company->assets);
}
// public function testACompanyCanHaveAssets()
// {
// $company = factory(Company::class)->create();
// factory(App\Models\Asset::class, 1)->create(['company_id'=>$company->id]);
// $this->assertCount(1, $company->assets);
// }
public function testACompanyCanHaveLicenses()
{
$company = $this->createValidCompany();
factory(App\Models\License::class, 1)->states('acrobat')->create([
'company_id'=>$company->id,
'manufacturer_id' => factory(App\Models\Manufacturer::class)->states('adobe')->create()->id,
'category_id' => factory(App\Models\Category::class)->states('license-office-category')->create()->id
]);
$this->assertCount(1, $company->licenses);
}
// public function testACompanyCanHaveLicenses()
// {
// $company = factory(Company::class)->create();
// factory(App\Models\License::class, 1)->create(['company_id'=>$company->id]);
// $this->assertCount(1, $company->licenses);
// }
public function testACompanyCanHaveAccessories()
{
$company = $this->createValidCompany();
$a = factory(App\Models\Accessory::class)->states('apple-bt-keyboard')->create([
'category_id' => factory(App\Models\Category::class)->states('accessory-keyboard-category')->create()->id,
'company_id' => $company->id
]);
// public function testACompanyCanHaveAccessories()
// {
// $company = factory(Company::class)->create();
// factory(App\Models\Accessory::class, 1)->create(['company_id'=>$company->id]);
// $this->assertCount(1, $company->accessories);
// }
$this->assertCount(1, $company->accessories);
}
// public function testACompanyCanHaveConsumables()
// {
// $company = factory(Company::class)->create();
// factory(App\Models\Consumable::class, 1)->create(['company_id'=>$company->id]);
// $this->assertCount(1, $company->consumables);
// }
public function testACompanyCanHaveConsumables()
{
$company = $this->createValidCompany();
factory(App\Models\Consumable::class, 1)->states('cardstock')->create([
'company_id' => $company->id,
'category_id' => factory(App\Models\Category::class)->states('consumable-paper-category')->create()->id
]);
$this->assertCount(1, $company->consumables);
}
// public function testACompanyCanHaveComponents()
// {
// $company = factory(Company::class)->create();
// factory(App\Models\Component::class, 1)->create(['company_id'=>$company->id]);
// $this->assertCount(1, $company->components);
// }
public function testACompanyCanHaveComponents()
{
$company = $this->createValidCompany();
factory(App\Models\Component::class, 1)->states('ram-crucial4')->create([
'company_id'=>$company->id,
'category_id' => factory(App\Models\Category::class)->states('component-ram-category')->create()->id
]);
$this->assertCount(1, $company->components);
}
}

View File

@@ -12,45 +12,39 @@ class ConsumableTest extends BaseTest
*/
protected $tester;
// public function testConsumableAdd()
// {
// $consumable = factory(Consumable::class)->make();
// $values = [
// 'name' => $consumable->name,
// 'qty' => $consumable->qty,
// 'category_id' => $consumable->category_id,
// 'company_id' => $consumable->company_id,
// ];
// Consumable::create($values);
// $this->tester->seeRecord('consumables', $values);
// }
public function testFailsEmptyValidation()
{
// An Consumable requires a name, a qty, and a category_id.
$a = Consumable::create();
$this->assertFalse($a->isValid());
// public function testFailsEmptyValidation()
// {
// // An Consumable requires a name, a qty, and a category_id.
// $a = Consumable::create();
// $this->assertFalse($a->isValid());
$fields = [
'name' => 'name',
'qty' => 'qty',
'category_id' => 'category id'
];
$errors = $a->getErrors();
foreach ($fields as $field => $fieldTitle) {
$this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
}
}
// $fields = [
// 'name' => 'name',
// 'qty' => 'qty',
// 'category_id' => 'category id'
// ];
// $errors = $a->getErrors();
// foreach ($fields as $field => $fieldTitle) {
// $this->assertEquals($errors->get($field)[0], "The ${fieldTitle} field is required.");
// }
// }
// public function testAConsumableHasRelationships()
// {
// $consumable = factory(Consumable::class)->create();
// $this->assertInstanceOf(App\Models\User::class, $consumable->admin);
// $this->assertInstanceOf(App\Models\Company::class, $consumable->company);
// $this->assertInstanceOf(App\Models\Manufacturer::class, $consumable->manufacturer);
// $this->assertInstanceOf(App\Models\Location::class, $consumable->location);
// $this->assertInstanceOf(App\Models\Category::class, $consumable->category);
// }
public function testAConsumableHasRelationships()
{
$consumable = factory(Consumable::class)->states('cardstock')->create([
'category_id' => $this->createValidCategory('consumable-paper-category')->id,
'manufacturer_id' => $this->createValidManufacturer('apple')->id,
'company_id' => $this->createValidCompany()->id,
'location_id' => $this->createValidLocation()->id,
'user_id' => $this->signIn()->id
]);
$this->assertInstanceOf(App\Models\User::class, $consumable->admin);
$this->assertInstanceOf(App\Models\Company::class, $consumable->company);
$this->assertInstanceOf(App\Models\Manufacturer::class, $consumable->manufacturer);
$this->assertInstanceOf(App\Models\Location::class, $consumable->location);
$this->assertInstanceOf(App\Models\Category::class, $consumable->category);
}
}

View File

@@ -11,45 +11,39 @@ class DepreciationTest extends BaseTest
*/
protected $tester;
// public function testDepreciationAdd()
// {
// $depreciations = factory(Depreciation::class)->make();
// $values = [
// 'name' => $depreciations->name,
// 'months' => $depreciations->months,
// ];
public function testFailsEmptyValidation()
{
// An Asset requires a name, a qty, and a category_id.
$a = Depreciation::create();
$this->assertFalse($a->isValid());
// Depreciation::create($values);
// $this->tester->seeRecord('depreciations', $values);
// }
$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 testFailsEmptyValidation()
// {
// // An Asset requires a name, a qty, and a category_id.
// $a = Depreciation::create();
// $this->assertFalse($a->isValid());
public function testADepreciationHasModels()
{
$this->createValidAssetModel();
$depreciation = $this->createValidDepreciation('computer', ['name' => 'New Depreciation']);
$models = factory(App\Models\AssetModel::class, 5)->states('mbp-13-model')->create(['depreciation_id'=>$depreciation->id]);
$this->assertEquals(5,$depreciation->has_models());
}
// $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 testADepreciationHasLicenses()
{
$category = $this->createValidCategory('license-graphics-category');
$depreciation = $this->createValidDepreciation('computer', ['name' => 'New Depreciation']);
$licenses = factory(App\Models\License::class, 5)->states('photoshop')->create([
'depreciation_id'=>$depreciation->id,
'category_id' => $category->id
]);
// public function testADepreciationHasModels()
// {
// $depreciation = factory(Depreciation::class)->create();
// factory(App\Models\AssetModel::class, 5)->create(['depreciation_id'=>$depreciation->id]);
// $this->assertEquals(5,$depreciation->has_models());
// }
// public function testADepreciationHasLicenses()
// {
// $depreciation = factory(Depreciation::class)->create();
// factory(App\Models\License::class, 5)->create(['depreciation_id'=>$depreciation->id]);
// $this->assertEquals(5,$depreciation->has_licenses());
// }
$this->assertEquals(5,$depreciation->has_licenses());
}
}

View File

@@ -19,31 +19,17 @@ class NotificationTest extends BaseTest
*/
protected $tester;
// public function testAUserIsEmailedIfTheyCheckoutAnAssetWithEULA()
// {
// $admin = factory(User::class)->states('superuser')->create();
// Auth::login($admin);
// $cat = factory(Category::class)->states('asset-category', 'requires-acceptance')->create();
// $model = factory(AssetModel::class)->create(['category_id' => $cat->id]);
// $asset = factory(Asset::class)->create(['model_id' => $model->id]);
public function testAUserIsEmailedIfTheyCheckoutAnAssetWithEULA()
{
$admin = factory(User::class)->states('superuser')->create();
Auth::login($admin);
$cat = $this->createValidCategory('asset-laptop-category', ['require_acceptance' => true]);
$model = $this->createValidAssetModel('mbp-13-model', ['category_id' => $cat->id]);
$asset = $this->createValidAsset(['model_id' => $model->id]);
$user = factory(User::class)->create();
Notification::fake();
$asset->checkOut($user, 1);
// $user = factory(User::class)->create();
// Notification::fake();
// $asset->checkOut($user, 1);
// Notification::assertSentTo($user, CheckoutNotification::class);
// }
// public function testAnAssetRequiringAEulaDoesNotExplodeWhenCheckedOutToALocation()
// {
// $this->signIn();
// $asset = factory(Asset::class)->states('requires-acceptance')->create();
// $this->expectException(CheckoutNotAllowed::class);
// $location = factory(Location::class)->create();
// Notification::fake();
// $asset->checkOut($location, 1);
// Notification::assertNotSentTo($location, CheckoutNotification::class);
// }
Notification::assertSentTo($user, CheckoutAssetNotification::class);
}
}

View File

@@ -12,102 +12,102 @@ class StatuslabelTest extends BaseTest
*/
protected $tester;
// public function testRTDStatuslabelAdd()
// {
// $statuslabel = factory(Statuslabel::class)->states('rtd')->make();
// $values = [
// 'name' => $statuslabel->name,
// 'deployable' => $statuslabel->deployable,
// 'pending' => $statuslabel->pending,
// 'archived' => $statuslabel->archived,
public function testRTDStatuslabelAdd()
{
$statuslabel = factory(Statuslabel::class)->states('rtd')->make();
$values = [
'name' => $statuslabel->name,
'deployable' => $statuslabel->deployable,
'pending' => $statuslabel->pending,
'archived' => $statuslabel->archived,
// ];
];
// Statuslabel::create($values);
// $this->tester->seeRecord('status_labels', $values);
// }
Statuslabel::create($values);
$this->tester->seeRecord('status_labels', $values);
}
// public function testPendingStatuslabelAdd()
// {
// $statuslabel = factory(Statuslabel::class)->states('pending')->make();
// $values = [
// 'name' => $statuslabel->name,
// 'deployable' => $statuslabel->deployable,
// 'pending' => $statuslabel->pending,
// 'archived' => $statuslabel->archived,
// ];
public function testPendingStatuslabelAdd()
{
$statuslabel = factory(Statuslabel::class)->states('pending')->make();
$values = [
'name' => $statuslabel->name,
'deployable' => $statuslabel->deployable,
'pending' => $statuslabel->pending,
'archived' => $statuslabel->archived,
];
// Statuslabel::create($values);
// $this->tester->seeRecord('status_labels', $values);
// }
Statuslabel::create($values);
$this->tester->seeRecord('status_labels', $values);
}
// public function testArchivedStatuslabelAdd()
// {
// $statuslabel = factory(Statuslabel::class)->states('archived')->make();
// $values = [
// 'name' => $statuslabel->name,
// 'deployable' => $statuslabel->deployable,
// 'pending' => $statuslabel->pending,
// 'archived' => $statuslabel->archived,
// ];
public function testArchivedStatuslabelAdd()
{
$statuslabel = factory(Statuslabel::class)->states('archived')->make();
$values = [
'name' => $statuslabel->name,
'deployable' => $statuslabel->deployable,
'pending' => $statuslabel->pending,
'archived' => $statuslabel->archived,
];
// Statuslabel::create($values);
// $this->tester->seeRecord('status_labels', $values);
// }
Statuslabel::create($values);
$this->tester->seeRecord('status_labels', $values);
}
// public function testOutForRepairStatuslabelAdd()
// {
// $statuslabel = factory(Statuslabel::class)->states('out_for_repair')->make();
// $values = [
// 'name' => $statuslabel->name,
// 'deployable' => $statuslabel->deployable,
// 'pending' => $statuslabel->pending,
// 'archived' => $statuslabel->archived,
// ];
public function testOutForRepairStatuslabelAdd()
{
$statuslabel = factory(Statuslabel::class)->states('out_for_repair')->make();
$values = [
'name' => $statuslabel->name,
'deployable' => $statuslabel->deployable,
'pending' => $statuslabel->pending,
'archived' => $statuslabel->archived,
];
// Statuslabel::create($values);
// $this->tester->seeRecord('status_labels', $values);
// }
Statuslabel::create($values);
$this->tester->seeRecord('status_labels', $values);
}
// public function testOutForDiagnosticsStatuslabelAdd()
// {
// $statuslabel = factory(Statuslabel::class)->states('out_for_diagnostics')->make();
// $values = [
// 'name' => $statuslabel->name,
// 'deployable' => $statuslabel->deployable,
// 'pending' => $statuslabel->pending,
// 'archived' => $statuslabel->archived,
// ];
public function testOutForDiagnosticsStatuslabelAdd()
{
$statuslabel = factory(Statuslabel::class)->states('out_for_diagnostics')->make();
$values = [
'name' => $statuslabel->name,
'deployable' => $statuslabel->deployable,
'pending' => $statuslabel->pending,
'archived' => $statuslabel->archived,
];
// Statuslabel::create($values);
// $this->tester->seeRecord('status_labels', $values);
// }
Statuslabel::create($values);
$this->tester->seeRecord('status_labels', $values);
}
// public function testBrokenStatuslabelAdd()
// {
// $statuslabel = factory(Statuslabel::class)->states('broken')->make();
// $values = [
// 'name' => $statuslabel->name,
// 'deployable' => $statuslabel->deployable,
// 'pending' => $statuslabel->pending,
// 'archived' => $statuslabel->archived,
// ];
public function testBrokenStatuslabelAdd()
{
$statuslabel = factory(Statuslabel::class)->states('broken')->make();
$values = [
'name' => $statuslabel->name,
'deployable' => $statuslabel->deployable,
'pending' => $statuslabel->pending,
'archived' => $statuslabel->archived,
];
// Statuslabel::create($values);
// $this->tester->seeRecord('status_labels', $values);
// }
Statuslabel::create($values);
$this->tester->seeRecord('status_labels', $values);
}
// public function testLostStatuslabelAdd()
// {
// $statuslabel = factory(Statuslabel::class)->states('lost')->make();
// $values = [
// 'name' => $statuslabel->name,
// 'deployable' => $statuslabel->deployable,
// 'pending' => $statuslabel->pending,
// 'archived' => $statuslabel->archived,
// ];
public function testLostStatuslabelAdd()
{
$statuslabel = factory(Statuslabel::class)->states('lost')->make();
$values = [
'name' => $statuslabel->name,
'deployable' => $statuslabel->deployable,
'pending' => $statuslabel->pending,
'archived' => $statuslabel->archived,
];
// Statuslabel::create($values);
// $this->tester->seeRecord('status_labels', $values);
// }
Statuslabel::create($values);
$this->tester->seeRecord('status_labels', $values);
}
}