mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-14 01:24:06 -08:00
Merge remote-tracking branch 'origin/develop'
This commit is contained in:
commit
6134dfa8f2
|
@ -131,7 +131,8 @@ class AccessoriesController extends Controller
|
||||||
// Check if the asset exists
|
// Check if the asset exists
|
||||||
if (is_null($accessory_to_clone = Accessory::find($accessoryId))) {
|
if (is_null($accessory_to_clone = Accessory::find($accessoryId))) {
|
||||||
// Redirect to the asset management page
|
// Redirect to the asset management page
|
||||||
return redirect()->route('accessory.index')->with('error', trans('admin/accessories/message.does_not_exist'));
|
return redirect()->route('accessories.index')
|
||||||
|
->with('error', trans('admin/accessories/message.does_not_exist', ['id' => $accessoryId]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$accessory = clone $accessory_to_clone;
|
$accessory = clone $accessory_to_clone;
|
||||||
|
|
|
@ -590,7 +590,7 @@ class ReportsController extends Controller
|
||||||
$executionTime = microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'];
|
$executionTime = microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'];
|
||||||
\Log::debug('Added headers: '.$executionTime);
|
\Log::debug('Added headers: '.$executionTime);
|
||||||
|
|
||||||
$assets = \App\Models\Company::scopeCompanyables(Asset::select('assets.*'))->with(
|
$assets = Asset::select('assets.*')->with(
|
||||||
'location', 'assetstatus', 'company', 'defaultLoc', 'assignedTo',
|
'location', 'assetstatus', 'company', 'defaultLoc', 'assignedTo',
|
||||||
'model.category', 'model.manufacturer', 'supplier');
|
'model.category', 'model.manufacturer', 'supplier');
|
||||||
|
|
||||||
|
|
|
@ -432,4 +432,13 @@ class UserFactory extends Factory
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function canViewReports()
|
||||||
|
{
|
||||||
|
return $this->state(function () {
|
||||||
|
return [
|
||||||
|
'permissions' => '{"reports.view":"1"}',
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
110
tests/Feature/Reports/CustomReportTest.php
Normal file
110
tests/Feature/Reports/CustomReportTest.php
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Reports;
|
||||||
|
|
||||||
|
use App\Models\Asset;
|
||||||
|
use App\Models\Company;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Testing\TestResponse;
|
||||||
|
use League\Csv\Reader;
|
||||||
|
use PHPUnit\Framework\Assert;
|
||||||
|
use Tests\Support\InteractsWithSettings;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class CustomReportTest extends TestCase
|
||||||
|
{
|
||||||
|
use InteractsWithSettings;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
TestResponse::macro(
|
||||||
|
'assertSeeTextInStreamedResponse',
|
||||||
|
function (string $needle) {
|
||||||
|
Assert::assertTrue(
|
||||||
|
collect(Reader::createFromString($this->streamedContent())->getRecords())
|
||||||
|
->pluck(0)
|
||||||
|
->contains($needle)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
TestResponse::macro(
|
||||||
|
'assertDontSeeTextInStreamedResponse',
|
||||||
|
function (string $needle) {
|
||||||
|
Assert::assertFalse(
|
||||||
|
collect(Reader::createFromString($this->streamedContent())->getRecords())
|
||||||
|
->pluck(0)
|
||||||
|
->contains($needle)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCustomAssetReport()
|
||||||
|
{
|
||||||
|
Asset::factory()->create(['name' => 'Asset A']);
|
||||||
|
Asset::factory()->create(['name' => 'Asset B']);
|
||||||
|
|
||||||
|
$this->actingAs(User::factory()->canViewReports()->create())
|
||||||
|
->post('reports/custom', [
|
||||||
|
'asset_name' => '1',
|
||||||
|
'asset_tag' => '1',
|
||||||
|
'serial' => '1',
|
||||||
|
])->assertOk()
|
||||||
|
->assertHeader('content-type', 'text/csv; charset=UTF-8')
|
||||||
|
->assertSeeTextInStreamedResponse('Asset A')
|
||||||
|
->assertSeeTextInStreamedResponse('Asset B');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCustomAssetReportAdheresToCompanyScoping()
|
||||||
|
{
|
||||||
|
[$companyA, $companyB] = Company::factory()->count(2)->create();
|
||||||
|
|
||||||
|
Asset::factory()->for($companyA)->create(['name' => 'Asset A']);
|
||||||
|
Asset::factory()->for($companyB)->create(['name' => 'Asset B']);
|
||||||
|
|
||||||
|
$superUser = $companyA->users()->save(User::factory()->superuser()->make());
|
||||||
|
$userInCompanyA = $companyA->users()->save(User::factory()->canViewReports()->make());
|
||||||
|
$userInCompanyB = $companyB->users()->save(User::factory()->canViewReports()->make());
|
||||||
|
|
||||||
|
$this->settings->disableMultipleFullCompanySupport();
|
||||||
|
|
||||||
|
$this->actingAs($superUser)
|
||||||
|
->post('reports/custom', ['asset_name' => '1', 'asset_tag' => '1', 'serial' => '1'])
|
||||||
|
->assertSeeTextInStreamedResponse('Asset A')
|
||||||
|
->assertSeeTextInStreamedResponse('Asset B');
|
||||||
|
|
||||||
|
$this->actingAs($userInCompanyA)
|
||||||
|
->post('reports/custom', ['asset_name' => '1', 'asset_tag' => '1', 'serial' => '1'])
|
||||||
|
->assertSeeTextInStreamedResponse('Asset A')
|
||||||
|
->assertSeeTextInStreamedResponse('Asset B');
|
||||||
|
|
||||||
|
$this->actingAs($userInCompanyB)
|
||||||
|
->post('reports/custom', ['asset_name' => '1', 'asset_tag' => '1', 'serial' => '1'])
|
||||||
|
->assertSeeTextInStreamedResponse('Asset A')
|
||||||
|
->assertSeeTextInStreamedResponse('Asset B');
|
||||||
|
|
||||||
|
$this->settings->enableMultipleFullCompanySupport();
|
||||||
|
|
||||||
|
$this->actingAs($superUser)
|
||||||
|
->post('reports/custom', ['asset_name' => '1', 'asset_tag' => '1', 'serial' => '1'])
|
||||||
|
->assertSeeTextInStreamedResponse('Asset A')
|
||||||
|
->assertSeeTextInStreamedResponse('Asset B');
|
||||||
|
|
||||||
|
$this->actingAs($userInCompanyA)
|
||||||
|
->post('reports/custom', ['asset_name' => '1', 'asset_tag' => '1', 'serial' => '1'])
|
||||||
|
->assertSeeTextInStreamedResponse('Asset A')
|
||||||
|
->assertDontSeeTextInStreamedResponse('Asset B');
|
||||||
|
|
||||||
|
$this->actingAs($userInCompanyB)
|
||||||
|
->post('reports/custom', ['asset_name' => '1', 'asset_tag' => '1', 'serial' => '1'])
|
||||||
|
->assertDontSeeTextInStreamedResponse('Asset A')
|
||||||
|
->assertSeeTextInStreamedResponse('Asset B');
|
||||||
|
}
|
||||||
|
}
|
|
@ -24,7 +24,10 @@ trait CustomTestMacros
|
||||||
function (Model $model, string $property = 'name') use ($guardAgainstNullProperty) {
|
function (Model $model, string $property = 'name') use ($guardAgainstNullProperty) {
|
||||||
$guardAgainstNullProperty($model, $property);
|
$guardAgainstNullProperty($model, $property);
|
||||||
|
|
||||||
Assert::assertTrue(collect($this['rows'])->pluck($property)->contains($model->{$property}));
|
Assert::assertTrue(
|
||||||
|
collect($this['rows'])->pluck($property)->contains(e($model->{$property})),
|
||||||
|
"Response did not contain the expected value: {$model->{$property}}"
|
||||||
|
);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +38,10 @@ trait CustomTestMacros
|
||||||
function (Model $model, string $property = 'name') use ($guardAgainstNullProperty) {
|
function (Model $model, string $property = 'name') use ($guardAgainstNullProperty) {
|
||||||
$guardAgainstNullProperty($model, $property);
|
$guardAgainstNullProperty($model, $property);
|
||||||
|
|
||||||
Assert::assertFalse(collect($this['rows'])->pluck($property)->contains($model->{$property}));
|
Assert::assertFalse(
|
||||||
|
collect($this['rows'])->pluck($property)->contains(e($model->{$property})),
|
||||||
|
"Response contained unexpected value: {$model->{$property}}"
|
||||||
|
);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +52,10 @@ trait CustomTestMacros
|
||||||
function (Model $model, string $property = 'id') use ($guardAgainstNullProperty) {
|
function (Model $model, string $property = 'id') use ($guardAgainstNullProperty) {
|
||||||
$guardAgainstNullProperty($model, $property);
|
$guardAgainstNullProperty($model, $property);
|
||||||
|
|
||||||
Assert::assertTrue(collect($this->json('results'))->pluck('id')->contains($model->{$property}));
|
Assert::assertTrue(
|
||||||
|
collect($this->json('results'))->pluck('id')->contains(e($model->{$property})),
|
||||||
|
"Response did not contain the expected value: {$model->{$property}}"
|
||||||
|
);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +66,10 @@ trait CustomTestMacros
|
||||||
function (Model $model, string $property = 'id') use ($guardAgainstNullProperty) {
|
function (Model $model, string $property = 'id') use ($guardAgainstNullProperty) {
|
||||||
$guardAgainstNullProperty($model, $property);
|
$guardAgainstNullProperty($model, $property);
|
||||||
|
|
||||||
Assert::assertFalse(collect($this->json('results'))->pluck('id')->contains($model->{$property}));
|
Assert::assertFalse(
|
||||||
|
collect($this->json('results'))->pluck('id')->contains(e($model->{$property})),
|
||||||
|
"Response contained unexpected value: {$model->{$property}}"
|
||||||
|
);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// Here you can initialize variables that will be available to your tests
|
|
|
@ -1,3 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// This is global bootstrap for autoloading
|
|
|
@ -1,26 +0,0 @@
|
||||||
Item Name,Purchase Date,Purchase Cost,Location,Company,Order Number,Category,Requestable,Quantity
|
|
||||||
Walter Carter,09/01/2006,20.89,metus. Vivamus,Macromedia,J935H60W,Customer Relations,False,278
|
|
||||||
Hayes Delgado,06/15/2011,82.33,conubia,Macromedia,R444V77O,Advertising,No,374
|
|
||||||
Cairo Franks,02/17/2004,91.82,Suspendisse eleifend.,Sibelius,B562M80I,Accounting,True,86
|
|
||||||
Kasimir Best,04/26/2009,63.50,ipsum cursus vestibulum.,Adobe,T496S42R,Payroll,False,374
|
|
||||||
Rajah Garcia,07/23/2014,41.44,Nunc laoreet lectus,Sibelius,H299H99S,Customer Relations,No,514
|
|
||||||
Damon Pearson,08/22/2010,11.16,luctus,Microsoft,K403K24X,Finances,False,596
|
|
||||||
Jin Buckley,10/07/2005,15.36,euismod,Borland,U911L77O,Sales and Marketing,False,462
|
|
||||||
Barrett Simon,04/06/2013,54.85,ipsum nunc,Sibelius,R642D18D,Tech Support,Yes,297
|
|
||||||
Reece Hayden,05/12/2017,43.76,et nunc. Quisque,Lavasoft,R389I62U,Finances,1,500
|
|
||||||
Honorato Greene,07/04/2007,67.66,interdum. Curabitur,Google,P231H53Z,Accounting,1,38
|
|
||||||
Kennan Levine,12/09/2007,47.84,sociis,Lavasoft,K271S85U,Legal Department,1,268
|
|
||||||
Chadwick Ryan,03/23/2011,49.92,fermentum,Finale,S458L71D,Quality Assurance,Yes,579
|
|
||||||
Abraham Wynn,11/17/2009,32.19,Vestibulum,Lavasoft,Q317N85T,Quality Assurance,Yes,84
|
|
||||||
Tyrone Vazquez,05/02/2014,93.61,"feugiat nec, diam.",Apple Systems,X530P10G,Public Relations,No,6
|
|
||||||
Lester Holmes,11/20/2016,8.18,non magna.,Cakewalk,M377B05F,Research and Development,True,538
|
|
||||||
Ryder Stafford,08/06/2014,65.77,consectetuer rhoncus. Nullam,Lavasoft,R754A44P,Finances,False,428
|
|
||||||
Dylan Guy,09/26/2012,45.14,"a,",Chami,G531X03G,Tech Support,1,502
|
|
||||||
Igor Salinas,10/14/2009,90.90,viverra. Donec,Borland,V076X60Y,Asset Management,False,532
|
|
||||||
Xavier Mason,12/11/2004,89.76,mus. Proin,Sibelius,V002M54F,Tech Support,False,306
|
|
||||||
Kane Mcintyre,05/22/2011,7.79,"erat,",Cakewalk,B393H89J,Quality Assurance,1,256
|
|
||||||
Wade Silva,10/10/2010,78.71,Sed et libero.,Lavasoft,D573N25A,Customer Service,1,87
|
|
||||||
Brock Lowery,11/01/2012,22.07,"dolor,",Macromedia,H112I50Y,Human Resources,1,587
|
|
||||||
Gil Bright,07/30/2009,70.11,"id,",Sibelius,J429A36Y,Sales and Marketing,1,212
|
|
||||||
Raja Brewer,02/03/2015,42.75,"id,",Apple Systems,R567P48B,Asset Management,1,338
|
|
||||||
Malachi Conner,11/14/2008,71.79,Mauris,Yahoo,D522O37S,Tech Support,Yes,447
|
|
|
|
@ -1,25 +0,0 @@
|
||||||
Name,Email,Username,item Name,item Category,Model name,Manufacturer,Model Number,Serial number,Asset Tag,Location,Notes,Purchase Date,Purchase Cost,Company,Status,Warranty,Supplier
|
|
||||||
Bonnie Nelson,bnelson0@cdbaby.com,bnelson0,eget nunc donec quis,quam,massa id,Linkbridge,6377018600094472,27aa8378-b0f4-4289-84a4-405da95c6147,970882174-8,Daping,"Curabitur in libero ut massa volutpat convallis. Morbi odio odio, elementum eu, interdum eu, tincidunt in, leo. Maecenas pulvinar lobortis est.",2016-04-05,289.59,Alpha,Undeployable,14,Blogspan
|
|
||||||
Judith Ferguson,jferguson1@state.tx.us,jferguson1,mi in porttitor,justo,congue diam id,Flipstorm,5.02043359569189E+018,4bc7fc90-5a97-412f-8eed-77ecacc643fc,544574073-0,Cirangga Kidul,,2016-03-08,763.46,,Undeployable,12,Oyope
|
|
||||||
Mildred Gibson,mgibson2@wiley.com,mgibson2,morbi quis tortor id,nunc nisl duis,convallis tortor risus,Lajo,374622546776765,2837ab20-8f0d-4935-8a52-226392f2b1b0,710141467-2,Shekou,In congue. Etiam justo. Etiam pretium iaculis justo.,2015-08-09,233.57,Konklab,Lost,,
|
|
||||||
Brandon Lee,blee3@quantcast.com,blee3,amet cursus id turpis,sed,in faucibus orci,Zoomlounge,3549618015236095,18d6e6a4-d362-4de9-beb4-7f62fb93de6f,103538064-1,Leksand,Integer ac leo. Pellentesque ultrices mattis odio. Donec vitae nisi.,2015-10-11,,,Pending Diagnostics,,
|
|
||||||
Betty Powell,bpowell4@tuttocitta.it,bpowell4,ipsum praesent,condimentum curabitur,et ultrices,Kazu,3567082842822626,f9b473c6-c810-42f2-8335-27ce468889a8,118753405-6,Dresi Wetan,,2015-06-16,324.8,,Ready to Deploy,,
|
|
||||||
Anthony Wheeler,awheeler5@cocolog-nifty.com,awheeler5,dictumst maecenas ut,sem praesent,accumsan felis,Layo,30052522651756,4751495c-cee0-4961-b788-94a545b5643e,998233705-X,Dante Delgado,,2016-04-16,261.79,,Archived,15,Ntag
|
|
||||||
Dennis Reynolds,dreynolds6@ustream.tv,dreynolds6,libero nam,risus,interdum mauris,Twiyo,3585438057660291,17b3cf8d-fead-46f5-a8b0-49906bb90a00,177687256-8,Pingle,"Proin interdum mauris non ligula pellentesque ultrices. Phasellus id sapien in sapien iaculis congue. Vivamus metus arcu, adipiscing molestie, hendrerit at, vulputate vitae, nisl.",2015-05-24,,,Pending Diagnostics,,
|
|
||||||
Andrea Arnold,aarnold7@cbc.ca,aarnold7,mauris morbi non,ante vel,sapien dignissim,Cogibox,3548511052883500,7a6a2fdb-160c-4d91-8e05-a0337a90d9db,129556040-2,Zhuli,Duis aliquam convallis nunc. Proin at turpis a pede posuere nonummy. Integer non velit.,2015-09-15,434.86,,Archived,14,Kwilith
|
|
||||||
Anna Butler,abutler8@wikia.com,abutler8,eleifend pede libero,sapien a libero,et ultrices posuere cubilia,Flipbug,6.75911579996746E+017,c1a57909-3b2e-47fe-ab2f-843401b2a7de,117517007-0,Niopanda,"Maecenas tristique, est et tempus semper, est quam pharetra magna, ac consequat metus sapien ut nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Mauris viverra diam vitae quam. Suspendisse potenti.",2016-04-13,89.53,,Archived,15,Linkbridge
|
|
||||||
Mark Bennett,mbennett9@diigo.com,mbennett9,convallis nulla neque,eu sapien,duis mattis egestas metus aenean,Centimia,378342677410961,07540238-fb3c-4c8a-8e11-d43883ee4268,007968217-0,Zoumaling,,2015-07-04,,,Lost,,
|
|
||||||
Emily Wheeler,ewheelera@google.de,ewheelera,in felis,leo odio,quam sapien varius,Roombo,201954480670574,527b2445-2c67-4f76-912f-6ec42400a584,441402118-9,Luts’k,Suspendisse potenti. In eleifend quam a odio. In hac habitasse platea dictumst.,2016-05-18,,Bitwolf,Lost,36,Wikizz
|
|
||||||
Wanda Fox,wfoxb@virginia.edu,wfoxb,vel ipsum praesent,potenti nullam porttitor,augue vestibulum rutrum rutrum neque,Yakijo,3567636803247485,,863829558-8,Pravdinsk,"Aenean fermentum. Donec ut mauris eget massa tempor convallis. Nulla neque libero, convallis eget, eleifend luctus, ultricies eu, nibh.",2015-11-10,,,Lost,14,Linkbridge
|
|
||||||
,,,odio elementum,posuere cubilia curae,ante vel ipsum praesent blandit,Oyope,3529462300753736,9a863968-180e-451d-a723-dc85e2d5d8ff,742114860-4,Panay,Pellentesque at nulla. Suspendisse potenti. Cras in purus eu magna vulputate luctus.,2016-03-20,881.4,,,30,Tagcat
|
|
||||||
Janet Grant,jgrantd@cpanel.net,jgrantd,viverra diam vitae,semper sapien,dapibus dolor vel,Flashset,3559785746335392,e287bb64-ff4f-434c-88ab-210ad433c77b,927820758-6,Achiaman,,2016-03-05,675.3,,Archived,22,Meevee
|
|
||||||
Antonio Larson,alarsone@tripod.com,alarsone,felis sed interdum venenatis,id lobortis,dui proin,Chatterbridge,4070995882635,90bcab28-ffd4-48c9-ba5d-c2eeb1400698,789757925-5,Oemanu,Phasellus sit amet erat. Nulla tempus. Vivamus in felis eu sapien cursus vestibulum.,2015-07-25,,,Ready to Deploy,30,Shuffledrive
|
|
||||||
Lois Powell,lpowellf@com.com,lpowellf,id consequat,justo nec,odio porttitor id consequat in,Skipstorm,36309149183447,08e440f7-bd0b-47a7-a577-4a3ce3c7dfe7,202652281-2,Qiaolin,"Proin interdum mauris non ligula pellentesque ultrices. Phasellus id sapien in sapien iaculis congue. Vivamus metus arcu, adipiscing molestie, hendrerit at, vulputate vitae, nisl.",2015-08-13,446.22,,Lost,,
|
|
||||||
Mildred Allen,malleng@com.com,malleng,porta volutpat quam pede,in hac habitasse,donec vitae nisi nam,Devpulse,3543783295297294,5f900903-0ffe-4405-b5ad-aa4aa59d911c,210119288-8,Accha,"Nam ultrices, libero non mattis pulvinar, nulla pede ullamcorper augue, a suscipit nulla elit ac nulla. Sed vel enim sit amet nunc viverra dapibus. Nulla suscipit ligula in lacus.",2015-12-24,923.9,,Lost,20,Quamba
|
|
||||||
Clarence Austin,caustinh@bigcartel.com,caustinh,libero nam dui proin,aliquet at feugiat,eget tincidunt eget tempus,Photobug,201967051902986,bde85740-f103-4b49-a691-a60c7f6859a8,022102715-7,Kerkrade,In hac habitasse platea dictumst. Etiam faucibus cursus urna. Ut tellus.,2016-03-29,,,Undeployable,22,Browsedrive
|
|
||||||
Walter Chavez,wchavezi@blogs.com,wchavezi,sociis natoque penatibus,vel est,at diam nam,Photofeed,3533016005480310,bf4a2a92-6f29-4d24-be90-8126d4dcbd64,610672722-8,Villa Regina,,2016-05-13,442.51,,Archived,28,Tekfly
|
|
||||||
Marie Elliott,melliottj@constantcontact.com,melliottj,sed tristique in,rutrum,luctus et ultrices,Riffpath,4547299861035,9a02817e-de79-4850-a212-84c9ae3dd1a2,898880851-7,Tibro,Integer ac leo. Pellentesque ultrices mattis odio. Donec vitae nisi.,2015-09-10,906.39,,Undeployable,,
|
|
||||||
,,,dui luctus rutrum,sapien ut nunc,dictumst morbi vestibulum,Aivee,4405382067928809,514aca2a-9080-4c49-8695-7ba4c78edc65,466008300-4,Menglie,Duis consequat dui nec nisi volutpat eleifend. Donec ut dolor. Morbi vel lectus in quam fringilla rhoncus.,2015-12-21,151.27,,,,
|
|
||||||
,,,ut massa volutpat,sed,quis odio consequat varius integer,Abatz,3537252931689981,b99208e2-b8d8-4f7a-8a06-366a27733b97,313295582-5,Solidaridad,"Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus vestibulum sagittis sapien. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.",2016-02-15,211.07,,,,
|
|
||||||
Benjamin Ford,bfordm@woothemes.com,bfordm,habitasse platea dictumst,primis in faucibus,quam a odio in,Blogtag,5018304036665243,c8680b36-a13c-427f-a6a1-1b9b351eb129,552327520-4,Sorinomo,In quis justo. Maecenas rhoncus aliquam lacus. Morbi quis tortor id nulla ultrices aliquet.,2015-11-25,112.11,,Ready to Deploy,18,Quatz
|
|
||||||
Timothy Warren,twarrenn@printfriendly.com,twarrenn,leo pellentesque ultrices,vestibulum,in sapien iaculis congue vivamus,Brightdog,30355105682126,6c1e7556-063f-4c71-87ce-e46b06e8c238,446504693-6,Tamel,"Nam ultrices, libero non mattis pulvinar, nulla pede ullamcorper augue, a suscipit nulla elit ac nulla. Sed vel enim sit amet nunc viverra dapibus. Nulla suscipit ligula in lacus.",2015-08-19,221.03,,Undeployable,26,Mydeo
|
|
|
|
@ -1,25 +0,0 @@
|
||||||
Item Name,Purchase Date,Purchase Cost,Location,Company,Order Number,Category,Requestable,Quantity
|
|
||||||
eget,01/03/2011,85.91,mauris blandit mattis.,Lycos,T295T06V,Triamterene/Hydrochlorothiazide,No,322
|
|
||||||
Morbi,10/24/2016,87.42,iaculis,Lavasoft,W787T62Q,Ranitidine HCl,1,374
|
|
||||||
arcu.,09/22/2007,48.34,ornare,Google,N961E50A,Amoxicillin,False,252
|
|
||||||
nec,08/16/2009,8.71,lectus,Apple Systems,X624N14C,Lantus Solostar,1,30
|
|
||||||
Nam,03/30/2017,24.07,"a,",Macromedia,N618A20S,Hydrocodone/APAP,True,551
|
|
||||||
Nullam,12/16/2003,73.23,"Donec est mauris,",Yahoo,B386I67L,Fluticasone Propionate,No,395
|
|
||||||
erat,08/03/2010,17.49,Proin,Borland,G606H92I,Amlodipine Besylate,1,297
|
|
||||||
purus,10/12/2004,63.52,tellus justo sit,Chami,R660Z45O,Omeprazole (Rx),Yes,557
|
|
||||||
dignissim,11/10/2010,77.94,nibh vulputate mauris,Lavasoft,G230Z67X,Risperidone,1,47
|
|
||||||
Nam,01/25/2015,64.33,taciti sociosqu ad,Microsoft,B613L84C,Suboxone,No,310
|
|
||||||
Nunc,04/13/2017,81.02,nec orci.,Borland,O367N55N,Fluoxetine HCl,No,404
|
|
||||||
Phasellus,12/23/2005,70.67,"quis, tristique ac,",Borland,K941C02T,Alendronate Sodium,0,590
|
|
||||||
Nulla,07/21/2017,99.04,augue malesuada malesuada.,Lycos,D663L90H,Allopurinol,No,48
|
|
||||||
at,10/31/2007,58.42,"dolor sit amet,",Lavasoft,Y229E62I,Simvastatin,No,181
|
|
||||||
Sed,04/14/2011,48.86,"lectus convallis est,",Cakewalk,T666E70K,Fluconazole,True,169
|
|
||||||
quis,01/08/2014,55.64,"varius orci,",Lycos,T767G07U,Advair Diskus,False,264
|
|
||||||
viverra.,01/07/2013,93.48,"cursus et, magna.",Sibelius,T276L44H,Loestrin 24 Fe,No,293
|
|
||||||
Sed,03/20/2008,64.75,arcu. Sed,Cakewalk,A933E55V,Pantoprazole Sodium,No,407
|
|
||||||
iaculis,07/17/2015,56.74,nec,Borland,N568F73C,Venlafaxine HCl ER,No,115
|
|
||||||
leo.,12/09/2012,96.88,Aenean,Altavista,H283Z42U,Cephalexin,True,208
|
|
||||||
leo.,04/24/2007,40.87,tincidunt adipiscing. Mauris,Lycos,T054Q83U,Lyrica,0,486
|
|
||||||
pede.,09/29/2010,19.64,nec enim. Nunc,Chami,L842O70A,Simvastatin,Yes,214
|
|
||||||
massa,05/18/2015,18.43,nisi magna sed,Adobe,V029Q52K,Meloxicam,0,131
|
|
||||||
urna,10/22/2014,7.41,ac,Sibelius,Z708U15X,Flovent HFA,Yes,15
|
|
|
|
@ -1,11 +0,0 @@
|
||||||
# `functional-travis` enviromodules:
|
|
||||||
class_name: FunctionalTester
|
|
||||||
modules:
|
|
||||||
config:
|
|
||||||
# add framework module here
|
|
||||||
Laravel5:
|
|
||||||
environment_file: .env.testing-ci
|
|
||||||
Db:
|
|
||||||
dsn: 'mysql:host=localhost;dbname=snipeit_unit'
|
|
||||||
user: 'travis'
|
|
||||||
password: ''
|
|
|
@ -1,19 +0,0 @@
|
||||||
# Codeception Test Suite Configuration
|
|
||||||
|
|
||||||
# suite for acceptance tests.
|
|
||||||
# perform tests in browser using the Selenium-like tools.
|
|
||||||
# powered by Mink (http://mink.behat.org).
|
|
||||||
# (tip: that's what your customer will see).
|
|
||||||
# (tip: test your ajax and javascript by one of Mink drivers).
|
|
||||||
|
|
||||||
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
|
|
||||||
class_name: AcceptanceTester
|
|
||||||
modules:
|
|
||||||
config:
|
|
||||||
WebDriver:
|
|
||||||
url: 'http://localhost:8000'
|
|
||||||
browser: 'phantomjs'
|
|
||||||
Laravel5:
|
|
||||||
part: ORM
|
|
||||||
environment_file: .env
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
# Codeception Test Suite Configuration
|
|
||||||
|
|
||||||
# suite for acceptance tests.
|
|
||||||
# perform tests in browser using the Selenium-like tools.
|
|
||||||
# powered by Mink (http://mink.behat.org).
|
|
||||||
# (tip: that's what your customer will see).
|
|
||||||
# (tip: test your ajax and javascript by one of Mink drivers).
|
|
||||||
|
|
||||||
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
|
|
||||||
class_name: AcceptanceTester
|
|
||||||
modules:
|
|
||||||
enabled:
|
|
||||||
- WebDriver:
|
|
||||||
url: http://localhost:8000
|
|
||||||
browser: phantomjs
|
|
||||||
- \Helper\Acceptance
|
|
||||||
- Laravel5:
|
|
||||||
part: ORM
|
|
2
tests/_output/.gitignore
vendored
2
tests/_output/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
*
|
|
||||||
!.gitignore
|
|
|
@ -1,37 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inherited Methods
|
|
||||||
* @method void wantToTest($text)
|
|
||||||
* @method void wantTo($text)
|
|
||||||
* @method void execute($callable)
|
|
||||||
* @method void expectTo($prediction)
|
|
||||||
* @method void expect($prediction)
|
|
||||||
* @method void amGoingTo($argumentation)
|
|
||||||
* @method void am($role)
|
|
||||||
* @method void lookForwardTo($achieveValue)
|
|
||||||
* @method void comment($description)
|
|
||||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD)
|
|
||||||
*/
|
|
||||||
class AcceptanceTester extends \Codeception\Actor
|
|
||||||
{
|
|
||||||
use _generated\AcceptanceTesterActions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define custom actions here
|
|
||||||
*/
|
|
||||||
public static function test_login($I)
|
|
||||||
{
|
|
||||||
// if snapshot exists - skipping login
|
|
||||||
//if ($I->loadSessionSnapshot('login')) return;
|
|
||||||
|
|
||||||
// logging in
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'snipe');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
//$I->saveSessionSnapshot('login');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,58 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inherited Methods
|
|
||||||
* @method void wantToTest($text)
|
|
||||||
* @method void wantTo($text)
|
|
||||||
* @method void execute($callable)
|
|
||||||
* @method void expectTo($prediction)
|
|
||||||
* @method void expect($prediction)
|
|
||||||
* @method void amGoingTo($argumentation)
|
|
||||||
* @method void am($role)
|
|
||||||
* @method void lookForwardTo($achieveValue)
|
|
||||||
* @method void comment($description)
|
|
||||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD)
|
|
||||||
*/
|
|
||||||
class ApiTester extends \Codeception\Actor
|
|
||||||
{
|
|
||||||
use _generated\ApiTesterActions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define custom actions here
|
|
||||||
*/
|
|
||||||
public function getToken(App\Models\User $user)
|
|
||||||
{
|
|
||||||
$client_repository = new \Laravel\Passport\ClientRepository();
|
|
||||||
$client = $client_repository->createPersonalAccessClient($user->id, 'Codeception API Test Client',
|
|
||||||
'http://localhost/');
|
|
||||||
|
|
||||||
\Illuminate\Support\Facades\DB::table('oauth_personal_access_clients')->insert([
|
|
||||||
'client_id' => $client->id,
|
|
||||||
'created_at' => new DateTime,
|
|
||||||
'updated_at' => new DateTime,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$user->permissions = json_encode(['superuser' => true]);
|
|
||||||
$user->save();
|
|
||||||
|
|
||||||
$token = $user->createToken('CodeceptionAPItestToken')->accessToken;
|
|
||||||
|
|
||||||
return $token;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove Timestamps from transformed array
|
|
||||||
* This fixes false negatives when comparing json due to timestamp second rounding issues
|
|
||||||
* @param array $array Array returned from the transformer
|
|
||||||
* @return array Transformed item striped of created_at and updated_at
|
|
||||||
*/
|
|
||||||
public function removeTimeStamps($array)
|
|
||||||
{
|
|
||||||
unset($array['created_at']);
|
|
||||||
unset($array['updated_at']);
|
|
||||||
|
|
||||||
return $array;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,151 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Models\Accessory;
|
|
||||||
use App\Models\Asset;
|
|
||||||
use App\Models\AssetModel;
|
|
||||||
use App\Models\Category;
|
|
||||||
use App\Models\Company;
|
|
||||||
use App\Models\Component;
|
|
||||||
use App\Models\Consumable;
|
|
||||||
use App\Models\Depreciation;
|
|
||||||
use App\Models\Location;
|
|
||||||
use App\Models\Manufacturer;
|
|
||||||
use App\Models\Statuslabel;
|
|
||||||
use App\Models\Supplier;
|
|
||||||
use App\Models\User;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inherited Methods
|
|
||||||
* @method void wantToTest($text)
|
|
||||||
* @method void wantTo($text)
|
|
||||||
* @method void execute($callable)
|
|
||||||
* @method void expectTo($prediction)
|
|
||||||
* @method void expect($prediction)
|
|
||||||
* @method void amGoingTo($argumentation)
|
|
||||||
* @method void am($role)
|
|
||||||
* @method void lookForwardTo($achieveValue)
|
|
||||||
* @method void comment($description)
|
|
||||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD)
|
|
||||||
*/
|
|
||||||
class FunctionalTester extends \Codeception\Actor
|
|
||||||
{
|
|
||||||
use _generated\FunctionalTesterActions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define custom actions here
|
|
||||||
*/
|
|
||||||
public function getCompanyId()
|
|
||||||
{
|
|
||||||
return Company::inRandomOrder()->first()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCategoryId()
|
|
||||||
{
|
|
||||||
return Category::inRandomOrder()->first()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getManufacturerId()
|
|
||||||
{
|
|
||||||
return Manufacturer::inRandomOrder()->first()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getLocationId()
|
|
||||||
{
|
|
||||||
return Location::inRandomOrder()->first()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed Random Accessory Id
|
|
||||||
*/
|
|
||||||
public function getAccessoryId()
|
|
||||||
{
|
|
||||||
return Accessory::inRandomOrder()->first()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed Random Asset Model Id;
|
|
||||||
*/
|
|
||||||
public function getModelId()
|
|
||||||
{
|
|
||||||
return AssetModel::inRandomOrder()->first()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed Id of Empty Asset Model
|
|
||||||
*/
|
|
||||||
public function getEmptyModelId()
|
|
||||||
{
|
|
||||||
return AssetModel::doesntHave('assets')->first()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed Id of random status
|
|
||||||
*/
|
|
||||||
public function getStatusId()
|
|
||||||
{
|
|
||||||
return StatusLabel::inRandomOrder()->first()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Id of random user
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getUserId()
|
|
||||||
{
|
|
||||||
return User::inRandomOrder()->first()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed Id of random supplier
|
|
||||||
*/
|
|
||||||
public function getSupplierId()
|
|
||||||
{
|
|
||||||
return Supplier::inRandomOrder()->first()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mixed Id of Random Asset
|
|
||||||
*/
|
|
||||||
public function getAssetId()
|
|
||||||
{
|
|
||||||
return Asset::inRandomOrder()->first()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An Empty category
|
|
||||||
* @return mixed Id of Empty Category
|
|
||||||
*/
|
|
||||||
public function getEmptyCategoryId()
|
|
||||||
{
|
|
||||||
return Category::where('category_type', 'asset')->doesntHave('models')->first()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A random component id for testing
|
|
||||||
* @return mixed Id of random component
|
|
||||||
*/
|
|
||||||
public function getComponentId()
|
|
||||||
{
|
|
||||||
return Component::inRandomOrder()->first()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A random consumable Id for testing
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getConsumableId()
|
|
||||||
{
|
|
||||||
return Consumable::inRandomOrder()->first()->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return a random depreciation id for tests.
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getDepreciationId()
|
|
||||||
{
|
|
||||||
return Depreciation::inRandomOrder()->first()->id;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Helper;
|
|
||||||
|
|
||||||
// here you can define custom actions
|
|
||||||
// all public methods declared in helper class will be available in $I
|
|
||||||
|
|
||||||
class Acceptance extends \Codeception\Module
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Helper;
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Artisan;
|
|
||||||
|
|
||||||
// here you can define custom actions
|
|
||||||
// all public methods declared in helper class will be available in $I
|
|
||||||
|
|
||||||
class Api extends \Codeception\Module
|
|
||||||
{
|
|
||||||
public function setupDatabase()
|
|
||||||
{
|
|
||||||
Artisan::call('migrate');
|
|
||||||
Artisan::call('db:seed');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Helper;
|
|
||||||
|
|
||||||
// here you can define custom actions
|
|
||||||
// all public methods declared in helper class will be available in $I
|
|
||||||
|
|
||||||
class Functional extends \Codeception\Module
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -1,133 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A helper class for Codeception (http://codeception.com/) that allows automated HTML5 Validation
|
|
||||||
* using the Nu Html Checker (http://validator.github.io/validator/) during acceptance testing.
|
|
||||||
* It uses local binaries and can therefore be run offline.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Requirements:
|
|
||||||
* =============
|
|
||||||
*
|
|
||||||
* - Codeception with WebDriver set up (PhpBrowser doesn't work)
|
|
||||||
* - java is installed locally
|
|
||||||
* - The vnu.jar is installed locally (download the .zip from https://github.com/validator/validator/releases,
|
|
||||||
* it contains the .jar file)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Installation:
|
|
||||||
* =============
|
|
||||||
*
|
|
||||||
* - Copy this file to _support/Helper/ in the codeception directory
|
|
||||||
* - Merge the following configuration to acceptance.suite.yml:
|
|
||||||
*
|
|
||||||
* modules:
|
|
||||||
* enabled:
|
|
||||||
* - \Helper\HTMLValidator
|
|
||||||
* config:
|
|
||||||
* \Helper\HTMLValidator:
|
|
||||||
* javaPath: /usr/bin/java
|
|
||||||
* vnuPath: /usr/local/bin/vnu.jar
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Usage:
|
|
||||||
* ======
|
|
||||||
*
|
|
||||||
* Validate the HTML of the current page:
|
|
||||||
* $I->validateHTML();
|
|
||||||
*
|
|
||||||
* Validate the HTML of the current page, but ignore errors containing the string "Ignoreit":
|
|
||||||
* $I->validateHTML(["Ignoreme"]);
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
||||||
* @author Tobias Hößl <tobias@hoessl.eu>
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Helper;
|
|
||||||
|
|
||||||
use Codeception\TestCase;
|
|
||||||
|
|
||||||
class HTMLValidator extends \Codeception\Module
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param string $html
|
|
||||||
* @return array
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
private function validateByVNU($html)
|
|
||||||
{
|
|
||||||
$javaPath = $this->_getConfig('javaPath');
|
|
||||||
if (! $javaPath) {
|
|
||||||
$javaPath = 'java';
|
|
||||||
}
|
|
||||||
$vnuPath = $this->_getConfig('vnuPath');
|
|
||||||
if (! $vnuPath) {
|
|
||||||
$vnuPath = '/usr/local/bin/vnu.jar';
|
|
||||||
}
|
|
||||||
|
|
||||||
$filename = DIRECTORY_SEPARATOR.'tmp'.DIRECTORY_SEPARATOR.uniqid('html-validate').'.html';
|
|
||||||
file_put_contents($filename, $html);
|
|
||||||
exec($javaPath.' -Xss1024k -jar '.$vnuPath.' --format json '.$filename.' 2>&1', $return);
|
|
||||||
$data = json_decode($return[0], true);
|
|
||||||
if (! $data || ! isset($data['messages']) || ! is_array($data['messages'])) {
|
|
||||||
throw new \Exception('Invalid data returned from validation service: '.$return);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data['messages'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
* @throws \Codeception\Exception\ModuleException
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
private function getPageSource()
|
|
||||||
{
|
|
||||||
if (! $this->hasModule('WebDriver')) {
|
|
||||||
throw new \Exception('This validator needs WebDriver to work');
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var \Codeception\Module\WebDriver $webdriver */
|
|
||||||
$webdriver = $this->getModule('WebDriver');
|
|
||||||
|
|
||||||
return $webdriver->webDriver->getPageSource();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string[] $ignoreMessages
|
|
||||||
*/
|
|
||||||
public function validateHTML($ignoreMessages = [])
|
|
||||||
{
|
|
||||||
$source = $this->getPageSource();
|
|
||||||
try {
|
|
||||||
$messages = $this->validateByVNU($source);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$this->fail($e->getMessage());
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$failMessages = [];
|
|
||||||
$lines = explode("\n", $source);
|
|
||||||
foreach ($messages as $message) {
|
|
||||||
if ($message['type'] == 'error') {
|
|
||||||
$formattedMsg = '- Line '.$message['lastLine'].', column '.$message['lastColumn'].': '.
|
|
||||||
$message['message']."\n > ".$lines[$message['lastLine'] - 1];
|
|
||||||
$ignoring = false;
|
|
||||||
foreach ($ignoreMessages as $ignoreMessage) {
|
|
||||||
if (mb_stripos($formattedMsg, $ignoreMessage) !== false) {
|
|
||||||
$ignoring = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (! $ignoring) {
|
|
||||||
$failMessages[] = $formattedMsg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (count($failMessages) > 0) {
|
|
||||||
\PHPUnit_Framework_Assert::fail('Invalid HTML: '."\n".implode("\n", $failMessages));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Helper;
|
|
||||||
|
|
||||||
// here you can define custom actions
|
|
||||||
// all public methods declared in helper class will be available in $I
|
|
||||||
|
|
||||||
class Unit extends \Codeception\Module
|
|
||||||
{
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inherited Methods
|
|
||||||
* @method void wantToTest($text)
|
|
||||||
* @method void wantTo($text)
|
|
||||||
* @method void execute($callable)
|
|
||||||
* @method void expectTo($prediction)
|
|
||||||
* @method void expect($prediction)
|
|
||||||
* @method void amGoingTo($argumentation)
|
|
||||||
* @method void am($role)
|
|
||||||
* @method void lookForwardTo($achieveValue)
|
|
||||||
* @method void comment($description)
|
|
||||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD)
|
|
||||||
*/
|
|
||||||
class UnitTester extends \Codeception\Actor
|
|
||||||
{
|
|
||||||
use _generated\UnitTesterActions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define custom actions here
|
|
||||||
*/
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
# Codeception Test Suite Configuration
|
|
||||||
|
|
||||||
# suite for acceptance tests.
|
|
||||||
# perform tests in browser using the Selenium-like tools.
|
|
||||||
# powered by Mink (http://mink.behat.org).
|
|
||||||
# (tip: that's what your customer will see).
|
|
||||||
# (tip: test your ajax and javascript by one of Mink drivers).
|
|
||||||
|
|
||||||
# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
|
|
||||||
class_name: AcceptanceTester
|
|
||||||
modules:
|
|
||||||
enabled:
|
|
||||||
- WebDriver:
|
|
||||||
url: 'https://snipe-it.local:8890'
|
|
||||||
browser: 'firefox'
|
|
||||||
- \Helper\Acceptance
|
|
||||||
- Laravel5:
|
|
||||||
part: ORM
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$I = new AcceptanceTester($scenario);
|
|
||||||
AcceptanceTester::test_login($I);
|
|
||||||
|
|
||||||
$I->am('logged in user');
|
|
||||||
$I->wantTo('ensure that the accessories listing page loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/accessories');
|
|
||||||
$I->waitForElement('.table', 5); // secs
|
|
||||||
$I->seeNumberOfElements('table[name="accessories"] tr', [5, 30]);
|
|
||||||
$I->seeInTitle('Accessories');
|
|
||||||
$I->see('Accessories');
|
|
||||||
$I->seeInPageSource('accessories/create');
|
|
||||||
$I->dontSee('Accessories', '.page-header');
|
|
||||||
$I->see('Accessories', 'h1.pull-left');
|
|
||||||
|
|
||||||
/* Create Form */
|
|
||||||
$I->wantTo('ensure that the create accessories form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->click(['link' => 'Create New']);
|
|
||||||
$I->amOnPage('/accessories/create');
|
|
||||||
$I->dontSee('Create Accessory', '.page-header');
|
|
||||||
$I->see('Create Accessory', 'h1.pull-left');
|
|
||||||
$I->dontSee('<span class="');
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$I = new AcceptanceTester($scenario);
|
|
||||||
AcceptanceTester::test_login($I);
|
|
||||||
$I->am('logged in user');
|
|
||||||
$I->wantTo('ensure that assets page loads without errors');
|
|
||||||
$I->amGoingTo('go to the assets listing page');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/hardware');
|
|
||||||
$I->waitForElement('.table', 5); // secs
|
|
||||||
$I->seeNumberOfElements('table[name="assets"] tr', [5, 50]);
|
|
||||||
$I->seeInTitle('Assets');
|
|
||||||
$I->see('Assets');
|
|
||||||
$I->seeInPageSource('hardware/create');
|
|
||||||
$I->dontSee('Assets', '.page-header');
|
|
||||||
$I->see('Assets', 'h1.pull-left');
|
|
||||||
|
|
||||||
/* Create Form */
|
|
||||||
$I->wantTo('ensure that the create assets form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/hardware/create');
|
|
||||||
$I->dontSee('Create Asset', '.page-header');
|
|
||||||
$I->see('Create Asset', 'h1.pull-left');
|
|
||||||
$I->dontSee('<span class="');
|
|
|
@ -1,33 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class AssetsCest
|
|
||||||
{
|
|
||||||
public function _before(AcceptanceTester $I)
|
|
||||||
{
|
|
||||||
AcceptanceTester::test_login($I);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function listAssets(AcceptanceTester $I)
|
|
||||||
{
|
|
||||||
$I->am('logged in user');
|
|
||||||
$I->wantTo('ensure that assets page loads without errors');
|
|
||||||
$I->amGoingTo('go to the assets listing page');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/hardware');
|
|
||||||
$I->waitForElement('.table', 20); // secs
|
|
||||||
$I->seeNumberOfElements('table[name="assets"] tr', [5, 50]);
|
|
||||||
$I->seeInTitle(trans('general.assets'));
|
|
||||||
$I->see(trans('general.assets'));
|
|
||||||
$I->seeInPageSource('hardware/create');
|
|
||||||
$I->see(trans('general.assets'), 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createAsset(AcceptanceTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('ensure that the create assets form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/hardware/create');
|
|
||||||
$I->dontSee('Create Asset', '.page-header');
|
|
||||||
$I->see('Create Asset', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$I = new AcceptanceTester($scenario);
|
|
||||||
AcceptanceTester::test_login($I);
|
|
||||||
$I->am('logged in user');
|
|
||||||
$I->wantTo('ensure that the categories listing page loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/categories');
|
|
||||||
$I->waitForElement('.table', 5); // secs
|
|
||||||
$I->seeNumberOfElements('table[name="categories"] tr', [5, 30]);
|
|
||||||
$I->seeInTitle('Categories');
|
|
||||||
$I->see('Categories');
|
|
||||||
$I->seeInPageSource('/categories/create');
|
|
||||||
$I->dontSee('Categories', '.page-header');
|
|
||||||
$I->see('Categories', 'h1.pull-left');
|
|
||||||
|
|
||||||
/* Create Form */
|
|
||||||
$I->wantTo('ensure that the create category form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->click(['link' => 'Create New']);
|
|
||||||
$I->amOnPage('/categories/create');
|
|
||||||
$I->dontSee('Create Category', '.page-header');
|
|
||||||
$I->see('Create Category', 'h1.pull-left');
|
|
||||||
$I->dontSee('<span class="');
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$I = new AcceptanceTester($scenario);
|
|
||||||
AcceptanceTester::test_login($I);
|
|
||||||
|
|
||||||
$I->am('logged in user');
|
|
||||||
$I->wantTo('ensure that the company listing page loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/companies');
|
|
||||||
$I->waitForElement('.table', 5); // secs
|
|
||||||
$I->seeNumberOfElements('table[name="companies"] tr', [5, 30]);
|
|
||||||
$I->seeInTitle('Companies');
|
|
||||||
$I->see('Companies');
|
|
||||||
$I->seeInPageSource('companies/create');
|
|
||||||
$I->dontSee('Companies', '.page-header');
|
|
||||||
$I->see('Companies', 'h1.pull-left');
|
|
||||||
|
|
||||||
/* Create Form */
|
|
||||||
$I->wantTo('ensure that the create company form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->click(['link' => 'Create New']);
|
|
||||||
$I->amOnPage('/companies/create');
|
|
||||||
$I->dontSee('Create Company', '.page-header');
|
|
||||||
$I->see('Create Company', 'h1.pull-left');
|
|
||||||
$I->dontSee('<span class="');
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$I = new AcceptanceTester($scenario);
|
|
||||||
AcceptanceTester::test_login($I);
|
|
||||||
$I->am('logged in user');
|
|
||||||
$I->wantTo('ensure that the consumables listing page loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/consumables');
|
|
||||||
$I->waitForElement('.table', 5); // secs
|
|
||||||
$I->seeNumberOfElements('table[name="consumables"] tr', [5, 30]);
|
|
||||||
$I->seeInTitle('Consumables');
|
|
||||||
$I->see('Consumables');
|
|
||||||
$I->seeInPageSource('/consumables/create');
|
|
||||||
$I->dontSee('Consumables', '.page-header');
|
|
||||||
$I->see('Consumables', 'h1.pull-left');
|
|
||||||
|
|
||||||
/* Create Form */
|
|
||||||
$I->wantTo('ensure that the create consumables form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->click(['link' => 'Create New']);
|
|
||||||
$I->amOnPage('/consumables/create');
|
|
||||||
$I->dontSee('Create Consumable', '.page-header');
|
|
||||||
$I->see('Create Consumable', 'h1.pull-left');
|
|
||||||
$I->dontSee('<span class="');
|
|
|
@ -1,14 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$I = new AcceptanceTester($scenario);
|
|
||||||
AcceptanceTester::test_login($I);
|
|
||||||
$I->am('logged in user');
|
|
||||||
$I->wantTo('ensure that the custom fields page loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/fields');
|
|
||||||
$I->seeInTitle('Custom Fields');
|
|
||||||
$I->see('Custom Fields');
|
|
||||||
$I->seeInPageSource('/fields/create');
|
|
||||||
$I->dontSee('Custom Fields', '.page-header');
|
|
||||||
$I->dontSee('Fieldsets', '.page-header');
|
|
||||||
$I->see('Manage Custom Fields', 'h1.pull-left');
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$I = new AcceptanceTester($scenario);
|
|
||||||
AcceptanceTester::test_login($I);
|
|
||||||
|
|
||||||
$I->am('logged in user');
|
|
||||||
$I->wantTo('ensure that the department listing page loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/departments');
|
|
||||||
$I->waitForElement('.table', 5); // secs
|
|
||||||
$I->seeNumberOfElements('table[name="departments"] tr', [5, 30]);
|
|
||||||
$I->seeInTitle('Departments');
|
|
||||||
$I->see('Departments');
|
|
||||||
$I->seeInPageSource('departments/create');
|
|
||||||
$I->dontSee('Departments', '.page-header');
|
|
||||||
$I->see('Departments', 'h1.pull-left');
|
|
||||||
|
|
||||||
/* Create Form */
|
|
||||||
$I->wantTo('ensure that the create department form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->click(['link' => 'Create New']);
|
|
||||||
$I->amOnPage('/department/create');
|
|
||||||
$I->dontSee('Create Department', '.page-header');
|
|
||||||
$I->see('Create Department', 'h1.pull-left');
|
|
||||||
$I->dontSee('<span class="');
|
|
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$I = new AcceptanceTester($scenario);
|
|
||||||
AcceptanceTester::test_login($I);
|
|
||||||
$I->am('logged in user');
|
|
||||||
$I->wantTo('ensure that depreciations page loads without errors');
|
|
||||||
$I->amGoingTo('go to the depreciations listing page');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/depreciations');
|
|
||||||
$I->seeInTitle('Depreciations');
|
|
||||||
$I->waitForElement('.table', 5); // secs
|
|
||||||
$I->seeNumberOfElements('table[name="depreciations"] tbody tr', [1, 5]);
|
|
||||||
$I->seeInPageSource('/depreciations/create');
|
|
||||||
$I->dontSee('Depreciations', '.page-header');
|
|
||||||
$I->see('Depreciations', 'h1.pull-left');
|
|
||||||
|
|
||||||
/* Create Form */
|
|
||||||
$I->wantTo('ensure that the create depreciation form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->click(['link' => 'Create New']);
|
|
||||||
$I->amOnPage('/depreciations/create');
|
|
||||||
$I->seeInTitle('Create Depreciation');
|
|
||||||
$I->dontSee('Create Depreciation', '.page-header');
|
|
||||||
$I->see('Create Depreciation', 'h1.pull-left');
|
|
||||||
$I->dontSee('<span class="');
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$I = new AcceptanceTester($scenario);
|
|
||||||
AcceptanceTester::test_login($I);
|
|
||||||
$I->am('logged in user');
|
|
||||||
$I->wantTo('ensure that the locations listing page loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/locations');
|
|
||||||
$I->waitForElement('.table', 5); // secs
|
|
||||||
$I->seeNumberOfElements('tr', [5, 30]);
|
|
||||||
$I->seeInTitle('Locations');
|
|
||||||
$I->see('Locations');
|
|
||||||
$I->seeInPageSource('/locations/create');
|
|
||||||
$I->dontSee('Locations', '.page-header');
|
|
||||||
$I->see('Locations', 'h1.pull-left');
|
|
||||||
|
|
||||||
/* Create Form */
|
|
||||||
$I->wantTo('ensure that the create location form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->click(['link' => 'Create New']);
|
|
||||||
$I->amOnPage('/locations/create');
|
|
||||||
$I->dontSee('Create Location', '.page-header');
|
|
||||||
$I->see('Create Location', 'h1.pull-left');
|
|
||||||
$I->dontSee('<span class="');
|
|
|
@ -1,18 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class LoginCest
|
|
||||||
{
|
|
||||||
public function _before(AcceptanceTester $I)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function tryToLogin(AcceptanceTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('sign in');
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->see(trans('auth/general.login_prompt'));
|
|
||||||
$I->seeElement('input[type=text]');
|
|
||||||
$I->seeElement('input[type=password]');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$I = new AcceptanceTester($scenario);
|
|
||||||
AcceptanceTester::test_login($I);
|
|
||||||
$I->am('logged in user');
|
|
||||||
$I->wantTo('ensure that the manufacturers listing page loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/manufacturers');
|
|
||||||
$I->seeNumberOfElements('table[name="manufacturers"] tr', [5, 30]);
|
|
||||||
$I->see('Manufacturers');
|
|
||||||
$I->seeInTitle('Manufacturers');
|
|
||||||
$I->seeInPageSource('manufacturers/create');
|
|
||||||
$I->dontSee('Manufacturers', '.page-header');
|
|
||||||
$I->see('Manufacturers', 'h1.pull-left');
|
|
||||||
|
|
||||||
/* Create Form */
|
|
||||||
$I->wantTo('ensure that the create manufacturer form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->click(['link' => 'Create New']);
|
|
||||||
$I->amOnPage('/manufacturers/create');
|
|
||||||
$I->dontSee('Create Manufacturer', '.page-header');
|
|
||||||
$I->see('Create Manufacturer', 'h1.pull-left');
|
|
||||||
$I->dontSee('<span class="');
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$I = new AcceptanceTester($scenario);
|
|
||||||
AcceptanceTester::test_login($I);
|
|
||||||
$I->am('logged in user');
|
|
||||||
$I->wantTo('ensure the status labels listing page loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/statuslabels');
|
|
||||||
$I->waitForElement('.table', 5); // secs
|
|
||||||
$I->seeNumberOfElements('tr', [1, 30]);
|
|
||||||
$I->seeInTitle('Status Labels');
|
|
||||||
$I->see('Status Labels');
|
|
||||||
$I->seeInPageSource('statuslabels/create');
|
|
||||||
$I->dontSee('Status Labels', '.page-header');
|
|
||||||
$I->see('Status Labels', 'h1.pull-left');
|
|
||||||
|
|
||||||
/* Create Form */
|
|
||||||
$I->wantTo('ensure the create status labels form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->click(['link' => 'Create New']);
|
|
||||||
$I->amOnPage('/statuslabels/create');
|
|
||||||
$I->dontSee('Create Status Label', '.page-header');
|
|
||||||
$I->see('Create Status Label', 'h1.pull-left');
|
|
||||||
$I->dontSee('<span class="');
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$I = new AcceptanceTester($scenario);
|
|
||||||
AcceptanceTester::test_login($I);
|
|
||||||
$I->am('logged in user');
|
|
||||||
$I->wantTo('ensure that the suppliers listing page loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/suppliers');
|
|
||||||
$I->waitForElement('.table', 5); // secs
|
|
||||||
$I->seeNumberOfElements('table[name="suppliers"] tr', [5, 25]);
|
|
||||||
$I->seeInTitle('Suppliers');
|
|
||||||
$I->see('Suppliers');
|
|
||||||
$I->seeInPageSource('suppliers/create');
|
|
||||||
$I->dontSee('Suppliers', '.page-header');
|
|
||||||
$I->see('Suppliers', 'h1.pull-left');
|
|
||||||
|
|
||||||
/* Create Form */
|
|
||||||
$I->wantTo('ensure the create supplier form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->click(['link' => 'Create New']);
|
|
||||||
$I->amOnPage('/suppliers/create');
|
|
||||||
$I->dontSee('Create Supplier', '.page-header');
|
|
||||||
$I->see('Create Supplier', 'h1.pull-left');
|
|
||||||
$I->dontSee('<span class="');
|
|
|
@ -1,63 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$I = new AcceptanceTester($scenario);
|
|
||||||
AcceptanceTester::test_login($I);
|
|
||||||
$I->am('logged in user');
|
|
||||||
$I->wantTo('ensure that the users listing page loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/users');
|
|
||||||
//$I->waitForJS("return $.active == 0;", 60);
|
|
||||||
$I->waitForElement('.table', 5); // secs
|
|
||||||
//$I->seeNumberOfElements('tr', [1,10]);
|
|
||||||
$I->seeInTitle('Users');
|
|
||||||
$I->see('Users');
|
|
||||||
$I->seeInPageSource('users/create');
|
|
||||||
$I->dontSee('Users', '.page-header');
|
|
||||||
$I->see('Users', 'h1.pull-left');
|
|
||||||
$I->seeLink('Create New'); // matches <a href="/logout">Logout</a>
|
|
||||||
|
|
||||||
/* Create form */
|
|
||||||
$I->am('logged in admin');
|
|
||||||
$I->wantTo('ensure that you get errors when you submit an incomplete form');
|
|
||||||
$I->lookForwardTo('seeing errors display');
|
|
||||||
$I->click(['link' => 'Create New']);
|
|
||||||
$I->amOnPage('users/create');
|
|
||||||
$I->dontSee('Create User', '.page-header');
|
|
||||||
$I->see('Create User', 'h1.pull-left');
|
|
||||||
|
|
||||||
/* Submit form and expect errors */
|
|
||||||
$I->click(['name' => 'email']);
|
|
||||||
$I->submitForm('#userForm', [
|
|
||||||
'email' => 'me@example.com',
|
|
||||||
]);
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->dontSeeInSource('<br><');
|
|
||||||
|
|
||||||
/* Submit form and expect errors */
|
|
||||||
$I->click(['name' => 'email']);
|
|
||||||
$I->click(['name' => 'username']);
|
|
||||||
$I->submitForm('#userForm', [
|
|
||||||
'email' => Helper::generateRandomString(15).'@example.com',
|
|
||||||
'first_name' => 'Joe',
|
|
||||||
'last_name' => 'Smith',
|
|
||||||
'username' => Helper::generateRandomString(15),
|
|
||||||
]);
|
|
||||||
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->dontSeeInSource('<br><');
|
|
||||||
|
|
||||||
/* Submit form and expect success */
|
|
||||||
$I->wantTo('submit the form successfully');
|
|
||||||
$I->click(['name' => 'email']);
|
|
||||||
$I->fillField(['name' => 'email'], Helper::generateRandomString(15).'@example.com');
|
|
||||||
$I->fillField(['name' => 'first_name'], 'Joe');
|
|
||||||
$I->fillField(['name' => 'last_name'], 'Smith');
|
|
||||||
$I->click(['name' => 'username']);
|
|
||||||
$I->fillField(['name' => 'username'], Helper::generateRandomString(15));
|
|
||||||
$I->click(['name' => 'password']);
|
|
||||||
$I->fillField(['name' => 'password'], 'password');
|
|
||||||
$I->click(['name' => 'password_confirmation']);
|
|
||||||
$I->fillField(['name' => 'password_confirmation'], 'password');
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
$I->dontSeeInSource('<br><');
|
|
|
@ -1,3 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// Here you can initialize variables that will be available to your tests
|
|
|
@ -1,14 +0,0 @@
|
||||||
class_name: ApiTester
|
|
||||||
modules:
|
|
||||||
enabled:
|
|
||||||
- \Helper\Api
|
|
||||||
- REST:
|
|
||||||
url: /api/v1
|
|
||||||
depends: Laravel5
|
|
||||||
timeout: 10
|
|
||||||
- Asserts
|
|
||||||
config:
|
|
||||||
- Laravel5:
|
|
||||||
environment_file: .env.tests
|
|
||||||
disable_middleware: true
|
|
||||||
cleanup: true
|
|
|
@ -1,155 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
|
||||||
use App\Http\Transformers\AccessoriesTransformer;
|
|
||||||
use App\Models\Accessory;
|
|
||||||
use App\Models\Setting;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class ApiAccessoriesCest
|
|
||||||
{
|
|
||||||
protected $user;
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
public function _before(ApiTester $I)
|
|
||||||
{
|
|
||||||
$this->user = \App\Models\User::find(1);
|
|
||||||
$I->haveHttpHeader('Accept', 'application/json');
|
|
||||||
$I->amBearerAuthenticated($I->getToken($this->user));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function indexAccessories(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Get a list of accessories');
|
|
||||||
|
|
||||||
// call
|
|
||||||
$I->sendGET('/accessories?limit=10');
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse(), true);
|
|
||||||
// sample verify
|
|
||||||
$accessory = App\Models\Accessory::orderByDesc('created_at')->take(10)->get()->shuffle()->first();
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new AccessoriesTransformer)->transformAccessory($accessory)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function createAccessory(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Create a new accessory');
|
|
||||||
|
|
||||||
$temp_accessory = \App\Models\Accessory::factory()->appleBtKeyboard()->make([
|
|
||||||
'name' => 'Test Accessory Name',
|
|
||||||
'company_id' => 2,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// setup
|
|
||||||
$data = [
|
|
||||||
'category_id' => $temp_accessory->category_id,
|
|
||||||
'company_id' => $temp_accessory->company->id,
|
|
||||||
'location_id' => $temp_accessory->location_id,
|
|
||||||
'name' => $temp_accessory->name,
|
|
||||||
'order_number' => $temp_accessory->order_number,
|
|
||||||
'purchase_cost' => $temp_accessory->purchase_cost,
|
|
||||||
'purchase_date' => $temp_accessory->purchase_date,
|
|
||||||
'model_number' => $temp_accessory->model_number,
|
|
||||||
'manufacturer_id' => $temp_accessory->manufacturer_id,
|
|
||||||
'supplier_id' => $temp_accessory->supplier_id,
|
|
||||||
'qty' => $temp_accessory->qty,
|
|
||||||
];
|
|
||||||
|
|
||||||
// create
|
|
||||||
$I->sendPOST('/accessories', $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put is routed to the same method in the controller
|
|
||||||
// DO we actually need to test both?
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function updateAccessoryWithPatch(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Update an accessory with PATCH');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$accessory = \App\Models\Accessory::factory()->appleBtKeyboard()->create([
|
|
||||||
'name' => 'Original Accessory Name',
|
|
||||||
'company_id' => 2,
|
|
||||||
'location_id' => 3,
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Accessory::class, $accessory);
|
|
||||||
|
|
||||||
$temp_accessory = \App\Models\Accessory::factory()->microsoftMouse()->make([
|
|
||||||
'company_id' => 3,
|
|
||||||
'name' => 'updated accessory name',
|
|
||||||
'location_id' => 1,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'category_id' => $temp_accessory->category_id,
|
|
||||||
'company_id' => $temp_accessory->company->id,
|
|
||||||
'location_id' => $temp_accessory->location_id,
|
|
||||||
'name' => $temp_accessory->name,
|
|
||||||
'order_number' => $temp_accessory->order_number,
|
|
||||||
'purchase_cost' => $temp_accessory->purchase_cost,
|
|
||||||
'purchase_date' => $temp_accessory->purchase_date,
|
|
||||||
'model_number' => $temp_accessory->model_number,
|
|
||||||
'manufacturer_id' => $temp_accessory->manufacturer_id,
|
|
||||||
'supplier_id' => $temp_accessory->supplier_id,
|
|
||||||
'image' => $temp_accessory->image,
|
|
||||||
'qty' => $temp_accessory->qty,
|
|
||||||
];
|
|
||||||
|
|
||||||
$I->assertNotEquals($accessory->name, $data['name']);
|
|
||||||
|
|
||||||
// update
|
|
||||||
$I->sendPATCH('/accessories/'.$accessory->id, $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/accessories/message.update.success'), $response->messages);
|
|
||||||
$I->assertEquals($accessory->id, $response->payload->id); // accessory id does not change
|
|
||||||
$I->assertEquals($temp_accessory->company_id, $response->payload->company_id); // company_id updated
|
|
||||||
$I->assertEquals($temp_accessory->name, $response->payload->name); // accessory name updated
|
|
||||||
$I->assertEquals($temp_accessory->location_id, $response->payload->location_id); // accessory location_id updated
|
|
||||||
$temp_accessory->created_at = Carbon::parse($response->payload->created_at);
|
|
||||||
$temp_accessory->updated_at = Carbon::parse($response->payload->updated_at);
|
|
||||||
$temp_accessory->id = $accessory->id;
|
|
||||||
// verify
|
|
||||||
$I->sendGET('/accessories/'.$accessory->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson((new AccessoriesTransformer)->transformAccessory($temp_accessory));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function deleteAccessoryTest(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Delete an accessory');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$accessory = \App\Models\Accessory::factory()->appleBtKeyboard()->create([
|
|
||||||
'name' => 'Soon to be deleted',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Accessory::class, $accessory);
|
|
||||||
|
|
||||||
// delete
|
|
||||||
$I->sendDELETE('/accessories/'.$accessory->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/accessories/message.delete.success'), $response->messages);
|
|
||||||
|
|
||||||
// verify, expect a 200
|
|
||||||
$I->sendGET('/accessories/'.$accessory->id);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,168 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
|
||||||
use App\Http\Transformers\AssetsTransformer;
|
|
||||||
use App\Models\Asset;
|
|
||||||
use App\Models\Setting;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class ApiAssetsCest
|
|
||||||
{
|
|
||||||
protected $faker;
|
|
||||||
protected $user;
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
public function _before(ApiTester $I)
|
|
||||||
{
|
|
||||||
$this->faker = \Faker\Factory::create();
|
|
||||||
$this->user = \App\Models\User::find(1);
|
|
||||||
Setting::getSettings()->time_display_format = 'H:i';
|
|
||||||
$I->amBearerAuthenticated($I->getToken($this->user));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function indexAssets(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Get a list of assets');
|
|
||||||
|
|
||||||
// call
|
|
||||||
$I->sendGET('/hardware?limit=20&sort=id&order=desc');
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
// 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)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function createAsset(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Create a new asset');
|
|
||||||
|
|
||||||
$temp_asset = \App\Models\Asset::factory()->laptopMbp()->make([
|
|
||||||
'asset_tag' => 'Test Asset Tag',
|
|
||||||
'company_id' => 2,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// setup
|
|
||||||
$data = [
|
|
||||||
'asset_tag' => $temp_asset->asset_tag,
|
|
||||||
'assigned_to' => $temp_asset->assigned_to,
|
|
||||||
'company_id' => $temp_asset->company->id,
|
|
||||||
'image' => $temp_asset->image,
|
|
||||||
'model_id' => $temp_asset->model_id,
|
|
||||||
'name' => $temp_asset->name,
|
|
||||||
'notes' => $temp_asset->notes,
|
|
||||||
'purchase_cost' => $temp_asset->purchase_cost,
|
|
||||||
'purchase_date' => $temp_asset->purchase_date,
|
|
||||||
'rtd_location_id' => $temp_asset->rtd_location_id,
|
|
||||||
'serial' => $temp_asset->serial,
|
|
||||||
'status_id' => $temp_asset->status_id,
|
|
||||||
'supplier_id' => $temp_asset->supplier_id,
|
|
||||||
'warranty_months' => $temp_asset->warranty_months,
|
|
||||||
];
|
|
||||||
|
|
||||||
// create
|
|
||||||
$I->sendPOST('/hardware', $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function updateAssetWithPatch(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Update an asset with PATCH');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$asset = \App\Models\Asset::factory()->laptopMbp()->create([
|
|
||||||
'company_id' => 2,
|
|
||||||
'rtd_location_id' => 3,
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Asset::class, $asset);
|
|
||||||
|
|
||||||
$temp_asset = \App\Models\Asset::factory()->laptopAir()->make([
|
|
||||||
'company_id' => 3,
|
|
||||||
'name' => 'updated asset name',
|
|
||||||
'rtd_location_id' => 1,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'asset_tag' => $temp_asset->asset_tag,
|
|
||||||
'assigned_to' => $temp_asset->assigned_to,
|
|
||||||
'company_id' => $temp_asset->company->id,
|
|
||||||
'image' => $temp_asset->image,
|
|
||||||
'model_id' => $temp_asset->model_id,
|
|
||||||
'name' => $temp_asset->name,
|
|
||||||
'notes' => $temp_asset->notes,
|
|
||||||
'order_number' => $temp_asset->order_number,
|
|
||||||
'purchase_cost' => $temp_asset->purchase_cost,
|
|
||||||
'purchase_date' => $temp_asset->purchase_date->format('Y-m-d'),
|
|
||||||
'rtd_location_id' => $temp_asset->rtd_location_id,
|
|
||||||
'serial' => $temp_asset->serial,
|
|
||||||
'status_id' => $temp_asset->status_id,
|
|
||||||
'supplier_id' => $temp_asset->supplier_id,
|
|
||||||
'warranty_months' => $temp_asset->warranty_months,
|
|
||||||
];
|
|
||||||
|
|
||||||
$I->assertNotEquals($asset->name, $data['name']);
|
|
||||||
|
|
||||||
// update
|
|
||||||
$I->sendPATCH('/hardware/'.$asset->id, $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
// dd($response);
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/hardware/message.update.success'), $response->messages);
|
|
||||||
$I->assertEquals($asset->id, $response->payload->id); // asset id does not change
|
|
||||||
$I->assertEquals($temp_asset->asset_tag, $response->payload->asset_tag); // asset tag updated
|
|
||||||
$I->assertEquals($temp_asset->name, $response->payload->name); // asset name updated
|
|
||||||
$I->assertEquals($temp_asset->rtd_location_id, $response->payload->rtd_location_id); // asset rtd_location_id updated
|
|
||||||
$temp_asset->created_at = Carbon::parse($response->payload->created_at);
|
|
||||||
$temp_asset->updated_at = Carbon::parse($response->payload->updated_at);
|
|
||||||
$temp_asset->id = $asset->id;
|
|
||||||
$temp_asset->location_id = $response->payload->rtd_location_id;
|
|
||||||
|
|
||||||
// verify
|
|
||||||
$I->sendGET('/hardware/'.$asset->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson((new AssetsTransformer)->transformAsset($temp_asset));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function deleteAssetTest(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Delete an asset');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$asset = \App\Models\Asset::factory()->laptopMbp()->create();
|
|
||||||
$I->assertInstanceOf(\App\Models\Asset::class, $asset);
|
|
||||||
|
|
||||||
// delete
|
|
||||||
$I->sendDELETE('/hardware/'.$asset->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/hardware/message.delete.success'), $response->messages);
|
|
||||||
|
|
||||||
// verify, expect a 200
|
|
||||||
$I->sendGET('/hardware/'.$asset->id);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
|
|
||||||
// Make sure we're soft deleted.
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertNotNull($response->deleted_at);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,141 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
|
||||||
use App\Http\Transformers\CategoriesTransformer;
|
|
||||||
use App\Models\Category;
|
|
||||||
use App\Models\Setting;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class ApiCategoriesCest
|
|
||||||
{
|
|
||||||
protected $user;
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
public function _before(ApiTester $I)
|
|
||||||
{
|
|
||||||
$this->user = \App\Models\User::find(1);
|
|
||||||
$I->haveHttpHeader('Accept', 'application/json');
|
|
||||||
$I->amBearerAuthenticated($I->getToken($this->user));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function indexCategorys(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Get a list of categories');
|
|
||||||
|
|
||||||
// call
|
|
||||||
$I->sendGET('/categories?order_by=id&limit=10');
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse(), true);
|
|
||||||
// sample verify
|
|
||||||
$category = App\Models\Category::withCount('assets as assets_count', 'accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'licenses as licenses_count')
|
|
||||||
->orderByDesc('created_at')->take(10)->get()->shuffle()->first();
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new CategoriesTransformer)->transformCategory($category)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function createCategory(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Create a new category');
|
|
||||||
|
|
||||||
$temp_category = \App\Models\Category::factory()->assetLaptopCategory()->make([
|
|
||||||
'name' => 'Test Category Tag',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// setup
|
|
||||||
$data = [
|
|
||||||
'category_type' => $temp_category->category_type,
|
|
||||||
'checkin_email' => $temp_category->checkin_email,
|
|
||||||
'eula_text' => $temp_category->eula_text,
|
|
||||||
'name' => $temp_category->name,
|
|
||||||
'require_acceptance' => $temp_category->require_acceptance,
|
|
||||||
'use_default_eula' => $temp_category->use_default_eula,
|
|
||||||
];
|
|
||||||
|
|
||||||
// create
|
|
||||||
$I->sendPOST('/categories', $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put is routed to the same method in the controller
|
|
||||||
// DO we actually need to test both?
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function updateCategoryWithPatch(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Update an category with PATCH');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$category = \App\Models\Category::factory()->assetLaptopCategory()
|
|
||||||
->create([
|
|
||||||
'name' => 'Original Category Name',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Category::class, $category);
|
|
||||||
|
|
||||||
$temp_category = \App\Models\Category::factory()->accessoryMouseCategory()->make([
|
|
||||||
'name' => 'updated category name',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'category_type' => $temp_category->category_type,
|
|
||||||
'checkin_email' => $temp_category->checkin_email,
|
|
||||||
'eula_text' => $temp_category->eula_text,
|
|
||||||
'name' => $temp_category->name,
|
|
||||||
'require_acceptance' => $temp_category->require_acceptance,
|
|
||||||
'use_default_eula' => $temp_category->use_default_eula,
|
|
||||||
];
|
|
||||||
|
|
||||||
$I->assertNotEquals($category->name, $data['name']);
|
|
||||||
|
|
||||||
// update
|
|
||||||
$I->sendPATCH('/categories/'.$category->id, $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/categories/message.update.success'), $response->messages);
|
|
||||||
$I->assertEquals($category->id, $response->payload->id); // category id does not change
|
|
||||||
$I->assertEquals($temp_category->name, $response->payload->name); // category name updated
|
|
||||||
// Some manual copying to compare against
|
|
||||||
$temp_category->created_at = Carbon::parse($response->payload->created_at);
|
|
||||||
$temp_category->updated_at = Carbon::parse($response->payload->updated_at);
|
|
||||||
$temp_category->id = $category->id;
|
|
||||||
|
|
||||||
// verify
|
|
||||||
$I->sendGET('/categories/'.$category->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson((new CategoriesTransformer)->transformCategory($temp_category));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function deleteCategoryTest(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Delete an category');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$category = \App\Models\Category::factory()->assetLaptopCategory()->create([
|
|
||||||
'name' => 'Soon to be deleted',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Category::class, $category);
|
|
||||||
|
|
||||||
// delete
|
|
||||||
$I->sendDELETE('/categories/'.$category->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/categories/message.delete.success'), $response->messages);
|
|
||||||
|
|
||||||
// verify, expect a 200
|
|
||||||
$I->sendGET('/categories/'.$category->id);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,147 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
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
|
|
||||||
{
|
|
||||||
protected $faker;
|
|
||||||
protected $user;
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
public function _before(ApiTester $I)
|
|
||||||
{
|
|
||||||
$this->user = \App\Models\User::find(1);
|
|
||||||
$I->amBearerAuthenticated($I->getToken($this->user));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function checkoutAssetToUser(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Check out an asset to a user');
|
|
||||||
//Grab an asset from the database that isn't checked out.
|
|
||||||
$asset = Asset::whereNull('assigned_to')->first();
|
|
||||||
$targetUser = \App\Models\User::factory()->create();
|
|
||||||
$data = [
|
|
||||||
'assigned_user' => $targetUser->id,
|
|
||||||
'note' => 'This is a test checkout note',
|
|
||||||
'expected_checkin' => '2018-05-24',
|
|
||||||
'name' => 'Updated Asset Name',
|
|
||||||
'checkout_to_type' => 'user',
|
|
||||||
];
|
|
||||||
$I->sendPOST("/hardware/{$asset->id}/checkout", $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/hardware/message.checkout.success'), $response->messages);
|
|
||||||
|
|
||||||
// Confirm results.
|
|
||||||
$I->sendGET("/hardware/{$asset->id}");
|
|
||||||
$I->seeResponseContainsJson([
|
|
||||||
'assigned_to' => [
|
|
||||||
'id' => $targetUser->id,
|
|
||||||
'type' => 'user',
|
|
||||||
],
|
|
||||||
'name' => 'Updated Asset Name',
|
|
||||||
'expected_checkin' => Helper::getFormattedDateObject('2018-05-24', 'date'),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
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)
|
|
||||||
->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 = \App\Models\Asset::factory()->desktopMacpro()->create([
|
|
||||||
'name' => 'Test Asset For Checkout to',
|
|
||||||
]);
|
|
||||||
$data = [
|
|
||||||
'assigned_asset' => $targetAsset->id,
|
|
||||||
'checkout_to_type' => 'asset',
|
|
||||||
];
|
|
||||||
$I->sendPOST("/hardware/{$asset->id}/checkout", $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/hardware/message.checkout.success'), $response->messages);
|
|
||||||
|
|
||||||
// Confirm results.
|
|
||||||
$I->sendGET("/hardware/{$asset->id}");
|
|
||||||
$I->seeResponseContainsJson([
|
|
||||||
'assigned_to' => [
|
|
||||||
'id' => $targetAsset->id,
|
|
||||||
'type' => 'asset',
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
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)
|
|
||||||
->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 = \App\Models\Location::factory()->create([
|
|
||||||
'name' => 'Test Location for Checkout',
|
|
||||||
]);
|
|
||||||
$data = [
|
|
||||||
'assigned_location' => $targetLocation->id,
|
|
||||||
'checkout_to_type' => 'location',
|
|
||||||
];
|
|
||||||
$I->sendPOST("/hardware/{$asset->id}/checkout", $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/hardware/message.checkout.success'), $response->messages);
|
|
||||||
|
|
||||||
// Confirm results.
|
|
||||||
$I->sendGET("/hardware/{$asset->id}");
|
|
||||||
$I->seeResponseContainsJson([
|
|
||||||
'assigned_to' => [
|
|
||||||
'id' => $targetLocation->id,
|
|
||||||
'type' => 'location',
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function checkinAsset(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Checkin an asset that is currently checked out');
|
|
||||||
|
|
||||||
$asset = Asset::whereNotNull('assigned_to')->first();
|
|
||||||
|
|
||||||
$I->sendPOST("/hardware/{$asset->id}/checkin", [
|
|
||||||
'note' => 'Checkin Note',
|
|
||||||
]);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/hardware/message.checkin.success'), $response->messages);
|
|
||||||
|
|
||||||
// Verify
|
|
||||||
$I->sendGET("/hardware/{$asset->id}");
|
|
||||||
$I->seeResponseContainsJson([
|
|
||||||
'assigned_to' => null,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,132 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
|
||||||
use App\Http\Transformers\CompaniesTransformer;
|
|
||||||
use App\Models\Company;
|
|
||||||
use App\Models\Setting;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class ApiCompaniesCest
|
|
||||||
{
|
|
||||||
protected $user;
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
public function _before(ApiTester $I)
|
|
||||||
{
|
|
||||||
$this->user = \App\Models\User::find(1);
|
|
||||||
$I->haveHttpHeader('Accept', 'application/json');
|
|
||||||
$I->amBearerAuthenticated($I->getToken($this->user));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function indexCompanys(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Get a list of companies');
|
|
||||||
|
|
||||||
// call
|
|
||||||
$I->sendGET('/companies?order_by=id&limit=10');
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse(), true);
|
|
||||||
// dd($response);
|
|
||||||
// sample verify
|
|
||||||
$company = App\Models\Company::withCount('assets as assets_count', 'licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count', 'components as components_count', 'users as users_count')
|
|
||||||
->orderByDesc('created_at')->take(10)->get()->shuffle()->first();
|
|
||||||
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new CompaniesTransformer)->transformCompany($company)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function createCompany(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Create a new company');
|
|
||||||
|
|
||||||
$temp_company = \App\Models\Company::factory()->make([
|
|
||||||
'name' => 'Test Company Tag',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// setup
|
|
||||||
$data = [
|
|
||||||
'name' => $temp_company->name,
|
|
||||||
];
|
|
||||||
|
|
||||||
// create
|
|
||||||
$I->sendPOST('/companies', $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put is routed to the same method in the controller
|
|
||||||
// DO we actually need to test both?
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function updateCompanyWithPatch(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Update an company with PATCH');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$company = \App\Models\Company::factory()->create([
|
|
||||||
'name' => 'Original Company Name',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Company::class, $company);
|
|
||||||
|
|
||||||
$temp_company = \App\Models\Company::factory()->make([
|
|
||||||
'name' => 'updated company name',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'name' => $temp_company->name,
|
|
||||||
];
|
|
||||||
|
|
||||||
$I->assertNotEquals($company->name, $data['name']);
|
|
||||||
|
|
||||||
// update
|
|
||||||
$I->sendPATCH('/companies/'.$company->id, $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/companies/message.update.success'), $response->messages);
|
|
||||||
$I->assertEquals($company->id, $response->payload->id); // company id does not change
|
|
||||||
$I->assertEquals($temp_company->name, $response->payload->name); // company name updated
|
|
||||||
// Some manual copying to compare against
|
|
||||||
$temp_company->created_at = Carbon::parse($response->payload->created_at->datetime);
|
|
||||||
$temp_company->updated_at = Carbon::parse($response->payload->updated_at->datetime);
|
|
||||||
$temp_company->id = $company->id;
|
|
||||||
|
|
||||||
// verify
|
|
||||||
$I->sendGET('/companies/'.$company->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson((new CompaniesTransformer)->transformCompany($temp_company));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function deleteCompanyTest(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Delete an company');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$company = \App\Models\Company::factory()->create([
|
|
||||||
'name' => 'Soon to be deleted',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Company::class, $company);
|
|
||||||
|
|
||||||
// delete
|
|
||||||
$I->sendDELETE('/companies/'.$company->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/companies/message.delete.success'), $response->messages);
|
|
||||||
|
|
||||||
// verify, expect a 200
|
|
||||||
$I->sendGET('/companies/'.$company->id);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,80 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class ApiComponentsAssetsCest
|
|
||||||
{
|
|
||||||
protected $faker;
|
|
||||||
protected $user;
|
|
||||||
|
|
||||||
// public function _before(ApiTester $I)
|
|
||||||
// {
|
|
||||||
// $this->faker = \Faker\Factory::create();
|
|
||||||
// $this->user = \App\Models\User::find(1);
|
|
||||||
|
|
||||||
// $I->amBearerAuthenticated($I->getToken($this->user));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // /** @test */
|
|
||||||
// // public function indexComponentsAssets(ApiTester $I)
|
|
||||||
// // {
|
|
||||||
// // $I->wantTo('Get a list of assets related to a component');
|
|
||||||
|
|
||||||
// // // generate component
|
|
||||||
// // $component = factory(\App\Models\Component::class)
|
|
||||||
// // ->create(['user_id' => $this->user->id, 'qty' => 20]);
|
|
||||||
|
|
||||||
// // // generate assets and associate component
|
|
||||||
// // $assets = factory(\App\Models\Asset::class, 2)
|
|
||||||
// // ->create(['user_id' => $this->user->id])
|
|
||||||
// // ->each(function ($asset) use ($component) {
|
|
||||||
// // $component->assets()->attach($component->id, [
|
|
||||||
// // 'component_id' => $component->id,
|
|
||||||
// // 'user_id' => $this->user->id,
|
|
||||||
// // 'created_at' => date('Y-m-d H:i:s'),
|
|
||||||
// // 'assigned_qty' => 2,
|
|
||||||
// // 'asset_id' => $asset->id
|
|
||||||
// // ]);
|
|
||||||
// // });
|
|
||||||
|
|
||||||
// // // verify
|
|
||||||
// // $I->sendGET('/components/' . $component->id . '/assets/');
|
|
||||||
// // $I->seeResponseIsJson();
|
|
||||||
// // $I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
// // $response = json_decode($I->grabResponse());
|
|
||||||
// // $I->assertEquals(2, $response->total);
|
|
||||||
|
|
||||||
// // $I->assertInstanceOf(\Illuminate\Database\Eloquent\Collection::class, $assets);
|
|
||||||
|
|
||||||
// // $I->seeResponseContainsJson(['rows' => [
|
|
||||||
// // 0 => [
|
|
||||||
// // 'name' => $assets[0]->name,
|
|
||||||
// // 'id' => $assets[0]->id,
|
|
||||||
// // 'created_at' => $assets[0]->created_at->format('Y-m-d'),
|
|
||||||
// // ],
|
|
||||||
// // 1 => [
|
|
||||||
// // 'name' => $assets[1]->name,
|
|
||||||
// // 'id' => $assets[1]->id,
|
|
||||||
// // 'created_at' => $assets[1]->created_at->format('Y-m-d'),
|
|
||||||
// // ],
|
|
||||||
// // ]
|
|
||||||
// // ]);
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// // /** @test */
|
|
||||||
// // public function expectEmptyResponseWithoutAssociatedAssets(ApiTester $I, $scenario)
|
|
||||||
// // {
|
|
||||||
// // $I->wantTo('See an empty response when there are no associated assets to a component');
|
|
||||||
|
|
||||||
// // $component = factory(\App\Models\Component::class)
|
|
||||||
// // ->create(['user_id' => $this->user->id, 'qty' => 20]);
|
|
||||||
|
|
||||||
// // $I->sendGET('/components/' . $component->id . '/assets');
|
|
||||||
// // $I->seeResponseCodeIs(200);
|
|
||||||
// // $I->seeResponseIsJson();
|
|
||||||
|
|
||||||
// // $response = json_decode($I->grabResponse());
|
|
||||||
// // $I->assertEquals(0, $response->total);
|
|
||||||
// // $I->assertEquals([], $response->rows);
|
|
||||||
// // $I->seeResponseContainsJson(['total' => 0, 'rows' => []]);
|
|
||||||
// // }
|
|
||||||
}
|
|
|
@ -1,156 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
|
||||||
use App\Http\Transformers\ComponentsTransformer;
|
|
||||||
use App\Models\Component;
|
|
||||||
use App\Models\Setting;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class ApiComponentsCest
|
|
||||||
{
|
|
||||||
protected $user;
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
public function _before(ApiTester $I)
|
|
||||||
{
|
|
||||||
$this->user = \App\Models\User::find(1);
|
|
||||||
$I->haveHttpHeader('Accept', 'application/json');
|
|
||||||
$I->amBearerAuthenticated($I->getToken($this->user));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function indexComponents(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Get a list of components');
|
|
||||||
|
|
||||||
// call
|
|
||||||
$I->sendGET('/components?limit=10');
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse(), true);
|
|
||||||
// sample verify
|
|
||||||
$component = App\Models\Component::orderByDesc('created_at')->take(10)->get()->shuffle()->first();
|
|
||||||
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new ComponentsTransformer)->transformComponent($component)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function createComponent(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Create a new component');
|
|
||||||
|
|
||||||
$temp_component = \App\Models\Component::factory()->ramCrucial4()->make([
|
|
||||||
'name' => 'Test Component Name',
|
|
||||||
'company_id' => 2,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// setup
|
|
||||||
$data = [
|
|
||||||
'category_id' => $temp_component->category_id,
|
|
||||||
'company_id' => $temp_component->company->id,
|
|
||||||
'location_id' => $temp_component->location_id,
|
|
||||||
'manufacturer_id' => $temp_component->manufacturer_id,
|
|
||||||
'model_number' => $temp_component->model_number,
|
|
||||||
'name' => $temp_component->name,
|
|
||||||
'order_number' => $temp_component->order_number,
|
|
||||||
'purchase_cost' => $temp_component->purchase_cost,
|
|
||||||
'purchase_date' => $temp_component->purchase_date,
|
|
||||||
'qty' => $temp_component->qty,
|
|
||||||
'serial' => $temp_component->serial,
|
|
||||||
];
|
|
||||||
|
|
||||||
// create
|
|
||||||
$I->sendPOST('/components', $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put is routed to the same method in the controller
|
|
||||||
// DO we actually need to test both?
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function updateComponentWithPatch(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Update an component with PATCH');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$component = \App\Models\Component::factory()->ramCrucial4()->create([
|
|
||||||
'name' => 'Original Component Name',
|
|
||||||
'company_id' => 2,
|
|
||||||
'location_id' => 3,
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Component::class, $component);
|
|
||||||
|
|
||||||
$temp_component = \App\Models\Component::factory()->ssdCrucial240()->make([
|
|
||||||
'company_id' => 3,
|
|
||||||
'name' => 'updated component name',
|
|
||||||
'location_id' => 1,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'category_id' => $temp_component->category_id,
|
|
||||||
'company_id' => $temp_component->company->id,
|
|
||||||
'location_id' => $temp_component->location_id,
|
|
||||||
'min_amt' => $temp_component->min_amt,
|
|
||||||
'name' => $temp_component->name,
|
|
||||||
'order_number' => $temp_component->order_number,
|
|
||||||
'purchase_cost' => $temp_component->purchase_cost,
|
|
||||||
'purchase_date' => $temp_component->purchase_date,
|
|
||||||
'qty' => $temp_component->qty,
|
|
||||||
'serial' => $temp_component->serial,
|
|
||||||
];
|
|
||||||
|
|
||||||
$I->assertNotEquals($component->name, $data['name']);
|
|
||||||
|
|
||||||
// update
|
|
||||||
$I->sendPATCH('/components/'.$component->id, $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/components/message.update.success'), $response->messages);
|
|
||||||
$I->assertEquals($component->id, $response->payload->id); // component id does not change
|
|
||||||
$I->assertEquals($temp_component->company_id, $response->payload->company_id); // company_id updated
|
|
||||||
$I->assertEquals($temp_component->name, $response->payload->name); // component name updated
|
|
||||||
$I->assertEquals($temp_component->location_id, $response->payload->location_id); // component location_id updated
|
|
||||||
$temp_component->created_at = Carbon::parse($response->payload->created_at);
|
|
||||||
$temp_component->updated_at = Carbon::parse($response->payload->updated_at);
|
|
||||||
$temp_component->id = $component->id;
|
|
||||||
// verify
|
|
||||||
$I->sendGET('/components/'.$component->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson((new ComponentsTransformer)->transformComponent($temp_component));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function deleteComponentTest(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Delete an component');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$component = \App\Models\Component::factory()->ramCrucial4()->create([
|
|
||||||
'name' => 'Soon to be deleted',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Component::class, $component);
|
|
||||||
|
|
||||||
// delete
|
|
||||||
$I->sendDELETE('/components/'.$component->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
// dd($response);
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/components/message.delete.success'), $response->messages);
|
|
||||||
|
|
||||||
// verify, expect a 200
|
|
||||||
$I->sendGET('/components/'.$component->id);
|
|
||||||
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,155 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
|
||||||
use App\Http\Transformers\ConsumablesTransformer;
|
|
||||||
use App\Models\Consumable;
|
|
||||||
use App\Models\Setting;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class ApiConsumablesCest
|
|
||||||
{
|
|
||||||
protected $user;
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
public function _before(ApiTester $I)
|
|
||||||
{
|
|
||||||
$this->user = \App\Models\User::find(1);
|
|
||||||
$I->haveHttpHeader('Accept', 'application/json');
|
|
||||||
$I->amBearerAuthenticated($I->getToken($this->user));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function indexConsumables(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Get a list of consumables');
|
|
||||||
|
|
||||||
// call
|
|
||||||
$I->sendGET('/consumables?limit=10');
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse(), true);
|
|
||||||
// sample verify
|
|
||||||
$consumable = App\Models\Consumable::orderByDesc('created_at')->take(10)->get()->shuffle()->first();
|
|
||||||
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new ConsumablesTransformer)->transformConsumable($consumable)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function createConsumable(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Create a new consumable');
|
|
||||||
|
|
||||||
$temp_consumable = \App\Models\Consumable::factory()->ink()->make([
|
|
||||||
'name' => 'Test Consumable Name',
|
|
||||||
'company_id' => 2,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// setup
|
|
||||||
$data = [
|
|
||||||
'category_id' => $temp_consumable->category_id,
|
|
||||||
'company_id' => $temp_consumable->company->id,
|
|
||||||
'location_id' => $temp_consumable->location_id,
|
|
||||||
'manufacturer_id' => $temp_consumable->manufacturer_id,
|
|
||||||
'name' => $temp_consumable->name,
|
|
||||||
'order_number' => $temp_consumable->order_number,
|
|
||||||
'purchase_cost' => $temp_consumable->purchase_cost,
|
|
||||||
'purchase_date' => $temp_consumable->purchase_date,
|
|
||||||
'qty' => $temp_consumable->qty,
|
|
||||||
'model_number' => $temp_consumable->model_number,
|
|
||||||
];
|
|
||||||
|
|
||||||
// create
|
|
||||||
$I->sendPOST('/consumables', $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put is routed to the same method in the controller
|
|
||||||
// DO we actually need to test both?
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function updateConsumableWithPatch(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Update an consumable with PATCH');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$consumable = \App\Models\Consumable::factory()->ink()->create([
|
|
||||||
'name' => 'Original Consumable Name',
|
|
||||||
'company_id' => 2,
|
|
||||||
'location_id' => 3,
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Consumable::class, $consumable);
|
|
||||||
|
|
||||||
$temp_consumable = \App\Models\Consumable::factory()->cardstock()->make([
|
|
||||||
'company_id' => 3,
|
|
||||||
'name' => 'updated consumable name',
|
|
||||||
'location_id' => 1,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'category_id' => $temp_consumable->category_id,
|
|
||||||
'company_id' => $temp_consumable->company->id,
|
|
||||||
'item_no' => $temp_consumable->item_no,
|
|
||||||
'location_id' => $temp_consumable->location_id,
|
|
||||||
'name' => $temp_consumable->name,
|
|
||||||
'order_number' => $temp_consumable->order_number,
|
|
||||||
'purchase_cost' => $temp_consumable->purchase_cost,
|
|
||||||
'purchase_date' => $temp_consumable->purchase_date,
|
|
||||||
'model_number' => $temp_consumable->model_number,
|
|
||||||
'manufacturer_id' => $temp_consumable->manufacturer_id,
|
|
||||||
'supplier_id' => $temp_consumable->supplier_id,
|
|
||||||
'qty' => $temp_consumable->qty,
|
|
||||||
];
|
|
||||||
|
|
||||||
$I->assertNotEquals($consumable->name, $data['name']);
|
|
||||||
|
|
||||||
// update
|
|
||||||
$I->sendPATCH('/consumables/'.$consumable->id, $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/consumables/message.update.success'), $response->messages);
|
|
||||||
$I->assertEquals($consumable->id, $response->payload->id); // consumable id does not change
|
|
||||||
$I->assertEquals($temp_consumable->company_id, $response->payload->company_id); // company_id updated
|
|
||||||
$I->assertEquals($temp_consumable->name, $response->payload->name); // consumable name updated
|
|
||||||
$I->assertEquals($temp_consumable->location_id, $response->payload->location_id); // consumable location_id updated
|
|
||||||
$temp_consumable->created_at = Carbon::parse($response->payload->created_at);
|
|
||||||
$temp_consumable->updated_at = Carbon::parse($response->payload->updated_at);
|
|
||||||
$temp_consumable->id = $consumable->id;
|
|
||||||
// verify
|
|
||||||
$I->sendGET('/consumables/'.$consumable->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson((new ConsumablesTransformer)->transformConsumable($temp_consumable));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function deleteConsumableTest(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Delete an consumable');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$consumable = \App\Models\Consumable::factory()->ink()->create([
|
|
||||||
'name' => 'Soon to be deleted',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Consumable::class, $consumable);
|
|
||||||
|
|
||||||
// delete
|
|
||||||
$I->sendDELETE('/consumables/'.$consumable->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/consumables/message.delete.success'), $response->messages);
|
|
||||||
|
|
||||||
// verify, expect a 200
|
|
||||||
$I->sendGET('/consumables/'.$consumable->id);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,185 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Http\Transformers\LicenseSeatsTransformer;
|
|
||||||
use App\Models\Asset;
|
|
||||||
use App\Models\License;
|
|
||||||
use App\Models\LicenseSeat;
|
|
||||||
use App\Models\User;
|
|
||||||
|
|
||||||
class ApiLicenseSeatsCest
|
|
||||||
{
|
|
||||||
protected $license;
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
public function _before(ApiTester $I)
|
|
||||||
{
|
|
||||||
$this->user = \App\Models\User::find(1);
|
|
||||||
$I->haveHttpHeader('Accept', 'application/json');
|
|
||||||
$I->amBearerAuthenticated($I->getToken($this->user));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function indexLicenseSeats(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Get a list of license seats for a specific license');
|
|
||||||
|
|
||||||
// call
|
|
||||||
$I->sendGET('/licenses/1/seats?limit=10&order=desc');
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
// sample verify
|
|
||||||
$licenseSeats = App\Models\LicenseSeat::where('license_id', 1)
|
|
||||||
->orderBy('id', 'desc')->take(10)->get();
|
|
||||||
// pick a random seat
|
|
||||||
$licenseSeat = $licenseSeats->random();
|
|
||||||
// need the index in the original list so that the "name" field is determined correctly
|
|
||||||
$licenseSeatNumber = 0;
|
|
||||||
foreach ($licenseSeats as $index=>$seat) {
|
|
||||||
if ($licenseSeat === $seat) {
|
|
||||||
$licenseSeatNumber = $index + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new LicenseSeatsTransformer)->transformLicenseSeat($licenseSeat, $licenseSeatNumber)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function showLicenseSeat(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Get a license seat');
|
|
||||||
|
|
||||||
// call
|
|
||||||
$I->sendGET('/licenses/1/seats/10');
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
// sample verify
|
|
||||||
$licenseSeat = App\Models\LicenseSeat::findOrFail(10);
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new LicenseSeatsTransformer)->transformLicenseSeat($licenseSeat)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function checkoutLicenseSeatToUser(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Checkout a license seat to a user');
|
|
||||||
|
|
||||||
$user = App\Models\User::all()->random();
|
|
||||||
$licenseSeat = App\Models\LicenseSeat::all()->random();
|
|
||||||
$endpoint = '/licenses/'.$licenseSeat->license_id.'/seats/'.$licenseSeat->id;
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'assigned_to' => $user->id,
|
|
||||||
'note' => 'Test Checkout to User via API',
|
|
||||||
];
|
|
||||||
|
|
||||||
// update
|
|
||||||
$I->sendPATCH($endpoint, $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/licenses/message.update.success'), $response->messages);
|
|
||||||
$I->assertEquals($licenseSeat->license_id, $response->payload->license_id); // license id does not change
|
|
||||||
$I->assertEquals($licenseSeat->id, $response->payload->id); // license seat id does not change
|
|
||||||
|
|
||||||
// verify
|
|
||||||
$licenseSeat = $licenseSeat->fresh();
|
|
||||||
$I->sendGET($endpoint);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new LicenseSeatsTransformer)->transformLicenseSeat($licenseSeat)));
|
|
||||||
|
|
||||||
// verify that the last logged action is a checkout
|
|
||||||
$I->sendGET('/reports/activity?item_type=license&limit=1&item_id='.$licenseSeat->license_id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson([
|
|
||||||
'action_type' => 'checkout',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function checkoutLicenseSeatToAsset(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Checkout a license seat to an asset');
|
|
||||||
|
|
||||||
$asset = App\Models\Asset::all()->random();
|
|
||||||
$licenseSeat = App\Models\LicenseSeat::all()->random();
|
|
||||||
$endpoint = '/licenses/'.$licenseSeat->license_id.'/seats/'.$licenseSeat->id;
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'asset_id' => $asset->id,
|
|
||||||
'note' => 'Test Checkout to Asset via API',
|
|
||||||
];
|
|
||||||
|
|
||||||
// update
|
|
||||||
$I->sendPATCH($endpoint, $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/licenses/message.update.success'), $response->messages);
|
|
||||||
$I->assertEquals($licenseSeat->license_id, $response->payload->license_id); // license id does not change
|
|
||||||
$I->assertEquals($licenseSeat->id, $response->payload->id); // license seat id does not change
|
|
||||||
|
|
||||||
// verify
|
|
||||||
$licenseSeat = $licenseSeat->fresh();
|
|
||||||
$I->sendGET($endpoint);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new LicenseSeatsTransformer)->transformLicenseSeat($licenseSeat)));
|
|
||||||
|
|
||||||
// verify that the last logged action is a checkout
|
|
||||||
$I->sendGET('/reports/activity?item_type=license&limit=1&item_id='.$licenseSeat->license_id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson([
|
|
||||||
'action_type' => 'checkout',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function checkoutLicenseSeatToUserAndAsset(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Checkout a license seat to a user AND an asset');
|
|
||||||
|
|
||||||
$asset = App\Models\Asset::all()->random();
|
|
||||||
$user = App\Models\User::all()->random();
|
|
||||||
$licenseSeat = App\Models\LicenseSeat::all()->random();
|
|
||||||
$endpoint = '/licenses/'.$licenseSeat->license_id.'/seats/'.$licenseSeat->id;
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'asset_id' => $asset->id,
|
|
||||||
'assigned_to' => $user->id,
|
|
||||||
'note' => 'Test Checkout to User and Asset via API',
|
|
||||||
];
|
|
||||||
|
|
||||||
// update
|
|
||||||
$I->sendPATCH($endpoint, $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/licenses/message.update.success'), $response->messages);
|
|
||||||
$I->assertEquals($licenseSeat->license_id, $response->payload->license_id); // license id does not change
|
|
||||||
$I->assertEquals($licenseSeat->id, $response->payload->id); // license seat id does not change
|
|
||||||
|
|
||||||
// verify
|
|
||||||
$licenseSeat = $licenseSeat->fresh();
|
|
||||||
$I->sendGET($endpoint);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new LicenseSeatsTransformer)->transformLicenseSeat($licenseSeat)));
|
|
||||||
|
|
||||||
// verify that the last logged action is a checkout
|
|
||||||
$I->sendGET('/reports/activity?item_type=license&limit=1&item_id='.$licenseSeat->license_id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson([
|
|
||||||
'action_type' => 'checkout',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,194 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
|
||||||
use App\Http\Transformers\LicensesTransformer;
|
|
||||||
use App\Models\License;
|
|
||||||
use App\Models\Setting;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class ApiLicensesCest
|
|
||||||
{
|
|
||||||
protected $license;
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
public function _before(ApiTester $I)
|
|
||||||
{
|
|
||||||
$this->user = \App\Models\User::find(1);
|
|
||||||
$I->haveHttpHeader('Accept', 'application/json');
|
|
||||||
$I->amBearerAuthenticated($I->getToken($this->user));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function indexLicenses(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Get a list of licenses');
|
|
||||||
|
|
||||||
// call
|
|
||||||
$I->sendGET('/licenses?limit=10&sort=created_at');
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse(), true);
|
|
||||||
// sample verify
|
|
||||||
$license = App\Models\License::orderByDesc('created_at')
|
|
||||||
->withCount('freeSeats as free_seats_count')
|
|
||||||
->take(10)->get()->shuffle()->first();
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new LicensesTransformer)->transformLicense($license)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function createLicense(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Create a new license');
|
|
||||||
|
|
||||||
$temp_license = \App\Models\License::factory()->acrobat()->make([
|
|
||||||
'name' => 'Test License Name',
|
|
||||||
'depreciation_id' => 3,
|
|
||||||
'company_id' => 2,
|
|
||||||
]);
|
|
||||||
|
|
||||||
// setup
|
|
||||||
$data = [
|
|
||||||
'company_id' => $temp_license->company_id,
|
|
||||||
'depreciation_id' => $temp_license->depreciation_id,
|
|
||||||
'expiration_date' => $temp_license->expiration_date,
|
|
||||||
'license_email' => $temp_license->license_email,
|
|
||||||
'license_name' => $temp_license->license_name,
|
|
||||||
'maintained' => $temp_license->maintained,
|
|
||||||
'manufacturer_id' => $temp_license->manufacturer_id,
|
|
||||||
'name' => $temp_license->name,
|
|
||||||
'notes' => $temp_license->notes,
|
|
||||||
'order_number' => $temp_license->order_number,
|
|
||||||
'purchase_cost' => $temp_license->purchase_cost,
|
|
||||||
'purchase_date' => $temp_license->purchase_date,
|
|
||||||
'purchase_order' => $temp_license->purchase_order,
|
|
||||||
'reassignable' => $temp_license->reassignable,
|
|
||||||
'seats' => $temp_license->seats,
|
|
||||||
'serial' => $temp_license->serial,
|
|
||||||
'supplier_id' => $temp_license->supplier_id,
|
|
||||||
'termination_date' => $temp_license->termination_date,
|
|
||||||
];
|
|
||||||
|
|
||||||
// create
|
|
||||||
$I->sendPOST('/licenses', $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put is routed to the same method in the controller
|
|
||||||
// DO we actually need to test both?
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function updateLicenseWithPatch(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Update a license with PATCH');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$license = \App\Models\License::factory()->acrobat()->create([
|
|
||||||
'name' => 'Original License Name',
|
|
||||||
'depreciation_id' => 3,
|
|
||||||
'company_id' => 2,
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\License::class, $license);
|
|
||||||
|
|
||||||
$temp_license = \App\Models\License::factory()->office()->make([
|
|
||||||
'company_id' => 3,
|
|
||||||
'depreciation_id' => 2,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'company_id' => $temp_license->company_id,
|
|
||||||
'depreciation_id' => $temp_license->depreciation_id,
|
|
||||||
'expiration_date' => $temp_license->expiration_date,
|
|
||||||
'license_email' => $temp_license->license_email,
|
|
||||||
'license_name' => $temp_license->license_name,
|
|
||||||
'maintained' => $temp_license->maintained,
|
|
||||||
'manufacturer_id' => $temp_license->manufacturer_id,
|
|
||||||
'name' => $temp_license->name,
|
|
||||||
'notes' => $temp_license->notes,
|
|
||||||
'order_number' => $temp_license->order_number,
|
|
||||||
'purchase_cost' => $temp_license->purchase_cost,
|
|
||||||
'purchase_date' => $temp_license->purchase_date,
|
|
||||||
'purchase_order' => $temp_license->purchase_order,
|
|
||||||
'reassignable' => $temp_license->reassignable,
|
|
||||||
'seats' => $temp_license->seats,
|
|
||||||
'serial' => $temp_license->serial,
|
|
||||||
'supplier_id' => $temp_license->supplier_id,
|
|
||||||
'category_id' => $temp_license->category_id,
|
|
||||||
'termination_date' => $temp_license->termination_date,
|
|
||||||
];
|
|
||||||
// We aren't checking anyhting out in this test, so this fakes the withCount() that happens on a normal db fetch.
|
|
||||||
$temp_license->free_seats_count = $temp_license->seats;
|
|
||||||
$I->assertNotEquals($license->name, $data['name']);
|
|
||||||
|
|
||||||
// update
|
|
||||||
$I->sendPATCH('/licenses/'.$license->id, $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/licenses/message.update.success'), $response->messages);
|
|
||||||
$I->assertEquals($license->id, $response->payload->id); // license id does not change
|
|
||||||
$I->assertEquals($temp_license->name, $response->payload->name); // license name
|
|
||||||
$temp_license->created_at = Carbon::parse($response->payload->created_at);
|
|
||||||
$temp_license->updated_at = Carbon::parse($response->payload->updated_at);
|
|
||||||
$temp_license->id = $license->id;
|
|
||||||
// verify
|
|
||||||
$I->sendGET('/licenses/'.$license->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson((new LicensesTransformer)->transformLicense($temp_license));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function deleteLicenseWithUsersTest(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Ensure a license with seats checked out cannot be deleted');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$license = \App\Models\License::factory()->acrobat()->create([
|
|
||||||
'name' => 'Soon to be deleted',
|
|
||||||
]);
|
|
||||||
$licenseSeat = $license->freeSeat();
|
|
||||||
$licenseSeat->assigned_to = $this->user->id;
|
|
||||||
$licenseSeat->save();
|
|
||||||
$I->assertInstanceOf(\App\Models\License::class, $license);
|
|
||||||
|
|
||||||
// delete
|
|
||||||
$I->sendDELETE('/licenses/'.$license->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('error', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/licenses/message.assoc_users'), $response->messages);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function deleteLicenseTest(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Delete an license');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$license = \App\Models\License::factory()->acrobat()->create([
|
|
||||||
'name' => 'Soon to be deleted',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\License::class, $license);
|
|
||||||
|
|
||||||
// delete
|
|
||||||
$I->sendDELETE('/licenses/'.$license->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/licenses/message.delete.success'), $response->messages);
|
|
||||||
|
|
||||||
// verify, expect a 200
|
|
||||||
$I->sendGET('/licenses/'.$license->id);
|
|
||||||
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,154 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
|
||||||
use App\Http\Transformers\LocationsTransformer;
|
|
||||||
use App\Models\Location;
|
|
||||||
use App\Models\Setting;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class ApiLocationsCest
|
|
||||||
{
|
|
||||||
protected $user;
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
public function _before(ApiTester $I)
|
|
||||||
{
|
|
||||||
$this->user = \App\Models\User::find(1);
|
|
||||||
$I->haveHttpHeader('Accept', 'application/json');
|
|
||||||
$I->amBearerAuthenticated($I->getToken($this->user));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function indexLocations(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Get a list of locations');
|
|
||||||
|
|
||||||
// call
|
|
||||||
$I->sendGET('/locations?limit=10');
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse(), true);
|
|
||||||
// sample verify
|
|
||||||
$location = App\Models\Location::orderByDesc('created_at')
|
|
||||||
->withCount('assignedAssets as assigned_assets_count', 'assets as assets_count', 'users as users_count')
|
|
||||||
->take(10)->get()->shuffle()->first();
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new LocationsTransformer)->transformLocation($location)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function createLocation(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Create a new location');
|
|
||||||
|
|
||||||
$temp_location = \App\Models\Location::factory()->make([
|
|
||||||
'name' => 'Test Location Tag',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// setup
|
|
||||||
$data = [
|
|
||||||
'name' => $temp_location->name,
|
|
||||||
'image' => $temp_location->image,
|
|
||||||
'address' => $temp_location->address,
|
|
||||||
'address2' => $temp_location->address2,
|
|
||||||
'city' => $temp_location->city,
|
|
||||||
'state' => $temp_location->state,
|
|
||||||
'country' => $temp_location->country,
|
|
||||||
'zip' => $temp_location->zip,
|
|
||||||
'parent_id' => $temp_location->parent_id,
|
|
||||||
'parent_id' => $temp_location->parent_id,
|
|
||||||
'manager_id' => $temp_location->manager_id,
|
|
||||||
'currency' => $temp_location->currency,
|
|
||||||
];
|
|
||||||
|
|
||||||
// create
|
|
||||||
$I->sendPOST('/locations', $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put is routed to the same method in the controller
|
|
||||||
// DO we actually need to test both?
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function updateLocationWithPatch(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Update an location with PATCH');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$location = \App\Models\Location::factory()->create([
|
|
||||||
'name' => 'Original Location Name',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Location::class, $location);
|
|
||||||
|
|
||||||
$temp_location = \App\Models\Location::factory()->make([
|
|
||||||
'name' => 'updated location name',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'name' => $temp_location->name,
|
|
||||||
'image' => $temp_location->image,
|
|
||||||
'address' => $temp_location->address,
|
|
||||||
'address2' => $temp_location->address2,
|
|
||||||
'city' => $temp_location->city,
|
|
||||||
'state' => $temp_location->state,
|
|
||||||
'country' => $temp_location->country,
|
|
||||||
'zip' => $temp_location->zip,
|
|
||||||
'parent_id' => $temp_location->parent_id,
|
|
||||||
'parent_id' => $temp_location->parent_id,
|
|
||||||
'manager_id' => $temp_location->manager_id,
|
|
||||||
'currency' => $temp_location->currency,
|
|
||||||
];
|
|
||||||
|
|
||||||
$I->assertNotEquals($location->name, $data['name']);
|
|
||||||
|
|
||||||
// update
|
|
||||||
$I->sendPATCH('/locations/'.$location->id, $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/locations/message.update.success'), $response->messages);
|
|
||||||
$I->assertEquals($location->id, $response->payload->id); // location id does not change
|
|
||||||
$I->assertEquals($temp_location->name, $response->payload->name); // location name updated
|
|
||||||
|
|
||||||
// Some necessary manual copying
|
|
||||||
$temp_location->created_at = Carbon::parse($response->payload->created_at->datetime);
|
|
||||||
$temp_location->updated_at = Carbon::parse($response->payload->updated_at->datetime);
|
|
||||||
$temp_location->id = $location->id;
|
|
||||||
|
|
||||||
// verify
|
|
||||||
$I->sendGET('/locations/'.$location->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson((new LocationsTransformer)->transformLocation($temp_location));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function deleteLocationTest(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Delete an location');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$location = \App\Models\Location::factory()->create([
|
|
||||||
'name' => 'Soon to be deleted',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Location::class, $location);
|
|
||||||
|
|
||||||
// delete
|
|
||||||
$I->sendDELETE('/locations/'.$location->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/locations/message.delete.success'), $response->messages);
|
|
||||||
|
|
||||||
// verify, expect a 200
|
|
||||||
$I->sendGET('/locations/'.$location->id);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,142 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
|
||||||
use App\Http\Transformers\ManufacturersTransformer;
|
|
||||||
use App\Models\Manufacturer;
|
|
||||||
use App\Models\Setting;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class ApiManufacturersCest
|
|
||||||
{
|
|
||||||
protected $user;
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
public function _before(ApiTester $I)
|
|
||||||
{
|
|
||||||
$this->user = \App\Models\User::find(1);
|
|
||||||
$I->haveHttpHeader('Accept', 'application/json');
|
|
||||||
$I->amBearerAuthenticated($I->getToken($this->user));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function indexManufacturers(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Get a list of manufacturers');
|
|
||||||
|
|
||||||
// call
|
|
||||||
$I->sendGET('/manufacturers?order_by=id&limit=10');
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse(), true);
|
|
||||||
// sample verify
|
|
||||||
$manufacturer = App\Models\Manufacturer::withCount('assets as assets_count', 'accessories as accessories_count', 'consumables as consumables_count', 'licenses as licenses_count')
|
|
||||||
->orderByDesc('created_at')->take(10)->get()->shuffle()->first();
|
|
||||||
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new ManufacturersTransformer)->transformManufacturer($manufacturer)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function createManufacturer(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Create a new manufacturer');
|
|
||||||
|
|
||||||
$temp_manufacturer = \App\Models\Manufacturer::factory()->apple()->make([
|
|
||||||
'name' => 'Test Manufacturer Tag',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// setup
|
|
||||||
$data = [
|
|
||||||
'image' => $temp_manufacturer->image,
|
|
||||||
'name' => $temp_manufacturer->name,
|
|
||||||
'support_email' => $temp_manufacturer->support_email,
|
|
||||||
'support_phone' => $temp_manufacturer->support_phone,
|
|
||||||
'support_url' => $temp_manufacturer->support_url,
|
|
||||||
'url' => $temp_manufacturer->url,
|
|
||||||
];
|
|
||||||
|
|
||||||
// create
|
|
||||||
$I->sendPOST('/manufacturers', $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put is routed to the same method in the controller
|
|
||||||
// DO we actually need to test both?
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function updateManufacturerWithPatch(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Update an manufacturer with PATCH');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$manufacturer = \App\Models\Manufacturer::factory()->apple()
|
|
||||||
->create([
|
|
||||||
'name' => 'Original Manufacturer Name',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Manufacturer::class, $manufacturer);
|
|
||||||
|
|
||||||
$temp_manufacturer = \App\Models\Manufacturer::factory()->dell()->make([
|
|
||||||
'name' => 'updated manufacturer name',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'image' => $temp_manufacturer->image,
|
|
||||||
'name' => $temp_manufacturer->name,
|
|
||||||
'support_email' => $temp_manufacturer->support_email,
|
|
||||||
'support_phone' => $temp_manufacturer->support_phone,
|
|
||||||
'support_url' => $temp_manufacturer->support_url,
|
|
||||||
'url' => $temp_manufacturer->url,
|
|
||||||
];
|
|
||||||
|
|
||||||
$I->assertNotEquals($manufacturer->name, $data['name']);
|
|
||||||
|
|
||||||
// update
|
|
||||||
$I->sendPATCH('/manufacturers/'.$manufacturer->id, $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/manufacturers/message.update.success'), $response->messages);
|
|
||||||
$I->assertEquals($manufacturer->id, $response->payload->id); // manufacturer id does not change
|
|
||||||
$I->assertEquals($temp_manufacturer->name, $response->payload->name); // manufacturer name updated
|
|
||||||
// Some manual copying to compare against
|
|
||||||
$temp_manufacturer->created_at = Carbon::parse($response->payload->created_at);
|
|
||||||
$temp_manufacturer->updated_at = Carbon::parse($response->payload->updated_at);
|
|
||||||
$temp_manufacturer->id = $manufacturer->id;
|
|
||||||
|
|
||||||
// verify
|
|
||||||
$I->sendGET('/manufacturers/'.$manufacturer->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson((new ManufacturersTransformer)->transformManufacturer($temp_manufacturer));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function deleteManufacturerTest(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Delete an manufacturer');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$manufacturer = \App\Models\Manufacturer::factory()->apple()->create([
|
|
||||||
'name' => 'Soon to be deleted',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Manufacturer::class, $manufacturer);
|
|
||||||
|
|
||||||
// delete
|
|
||||||
$I->sendDELETE('/manufacturers/'.$manufacturer->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/manufacturers/message.delete.success'), $response->messages);
|
|
||||||
|
|
||||||
// verify, expect a 200
|
|
||||||
$I->sendGET('/manufacturers/'.$manufacturer->id);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,145 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
|
||||||
use App\Http\Transformers\AssetModelsTransformer;
|
|
||||||
use App\Models\AssetModel;
|
|
||||||
use App\Models\Setting;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class ApiModelsCest
|
|
||||||
{
|
|
||||||
protected $user;
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
public function _before(ApiTester $I)
|
|
||||||
{
|
|
||||||
$this->user = \App\Models\User::find(1);
|
|
||||||
$I->haveHttpHeader('Accept', 'application/json');
|
|
||||||
$I->amBearerAuthenticated($I->getToken($this->user));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function indexAssetModels(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Get a list of assetmodels');
|
|
||||||
|
|
||||||
// call
|
|
||||||
$I->sendGET('/models?limit=10');
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse(), true);
|
|
||||||
$assetmodel = App\Models\AssetModel::orderByDesc('created_at')
|
|
||||||
->withCount('assets as assets_count')->take(10)->get()->shuffle()->first();
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new AssetModelsTransformer)->transformAssetModel($assetmodel)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function createAssetModel(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Create a new assetmodel');
|
|
||||||
|
|
||||||
$temp_assetmodel = \App\Models\AssetModel::factory()->mbp13Model()->make([
|
|
||||||
'name' => 'Test AssetModel Tag',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// setup
|
|
||||||
$data = [
|
|
||||||
'category_id' => $temp_assetmodel->category_id,
|
|
||||||
'depreciation_id' => $temp_assetmodel->depreciation_id,
|
|
||||||
'eol' => $temp_assetmodel->eol,
|
|
||||||
'image' => $temp_assetmodel->image,
|
|
||||||
'manufacturer_id' => $temp_assetmodel->manufacturer_id,
|
|
||||||
'model_number' => $temp_assetmodel->model_number,
|
|
||||||
'name' => $temp_assetmodel->name,
|
|
||||||
'notes' => $temp_assetmodel->notes,
|
|
||||||
];
|
|
||||||
|
|
||||||
// create
|
|
||||||
$I->sendPOST('/models', $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put is routed to the same method in the controller
|
|
||||||
// DO we actually need to test both?
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function updateAssetModelWithPatch(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Update an assetmodel with PATCH');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$assetmodel = \App\Models\AssetModel::factory()->mbp13Model()->create([
|
|
||||||
'name' => 'Original AssetModel Name',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\AssetModel::class, $assetmodel);
|
|
||||||
|
|
||||||
$temp_assetmodel = \App\Models\AssetModel::factory()->polycomcxModel()->make([
|
|
||||||
'name' => 'updated AssetModel name',
|
|
||||||
'fieldset_id' => 2,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'category_id' => $temp_assetmodel->category_id,
|
|
||||||
'depreciation_id' => $temp_assetmodel->depreciation_id,
|
|
||||||
'eol' => $temp_assetmodel->eol,
|
|
||||||
'image' => $temp_assetmodel->image,
|
|
||||||
'manufacturer_id' => $temp_assetmodel->manufacturer_id,
|
|
||||||
'model_number' => $temp_assetmodel->model_number,
|
|
||||||
'name' => $temp_assetmodel->name,
|
|
||||||
'notes' => $temp_assetmodel->notes,
|
|
||||||
'fieldset' => $temp_assetmodel->fieldset->id,
|
|
||||||
];
|
|
||||||
|
|
||||||
$I->assertNotEquals($assetmodel->name, $data['name']);
|
|
||||||
|
|
||||||
// update
|
|
||||||
$I->sendPATCH('/models/'.$assetmodel->id, $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/models/message.update.success'), $response->messages);
|
|
||||||
$I->assertEquals($assetmodel->id, $response->payload->id); // assetmodel id does not change
|
|
||||||
$I->assertEquals($temp_assetmodel->name, $response->payload->name); // assetmodel name updated
|
|
||||||
|
|
||||||
// Some necessary manual copying
|
|
||||||
$temp_assetmodel->created_at = Carbon::parse($response->payload->created_at);
|
|
||||||
$temp_assetmodel->updated_at = Carbon::parse($response->payload->updated_at);
|
|
||||||
$temp_assetmodel->id = $assetmodel->id;
|
|
||||||
// verify
|
|
||||||
$I->sendGET('/models/'.$assetmodel->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson((new AssetModelsTransformer)->transformAssetModel($temp_assetmodel));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function deleteAssetModelTest(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Delete an assetmodel');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$assetmodel = \App\Models\AssetModel::factory()->mbp13Model()->create([
|
|
||||||
'name' => 'Soon to be deleted',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\AssetModel::class, $assetmodel);
|
|
||||||
|
|
||||||
// delete
|
|
||||||
$I->sendDELETE('/models/'.$assetmodel->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/models/message.delete.success'), $response->messages);
|
|
||||||
|
|
||||||
// verify, expect a 200
|
|
||||||
$I->sendGET('/models/'.$assetmodel->id);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,142 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
|
||||||
use App\Http\Transformers\StatuslabelsTransformer;
|
|
||||||
use App\Models\Setting;
|
|
||||||
use App\Models\Statuslabel;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class ApiStatusLabelsCest
|
|
||||||
{
|
|
||||||
protected $user;
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
public function _before(ApiTester $I)
|
|
||||||
{
|
|
||||||
$this->user = \App\Models\User::find(1);
|
|
||||||
$I->haveHttpHeader('Accept', 'application/json');
|
|
||||||
$I->amBearerAuthenticated($I->getToken($this->user));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function indexStatuslabels(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Get a list of statuslabels');
|
|
||||||
|
|
||||||
// call
|
|
||||||
$I->sendGET('/statuslabels?limit=10');
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse(), true);
|
|
||||||
// sample verify
|
|
||||||
$statuslabel = App\Models\Statuslabel::orderByDesc('created_at')
|
|
||||||
->withCount('assets as assets_count')
|
|
||||||
->take(10)->get()->shuffle()->first();
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new StatuslabelsTransformer)->transformStatuslabel($statuslabel)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function createStatuslabel(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Create a new statuslabel');
|
|
||||||
|
|
||||||
$temp_statuslabel = \App\Models\Statuslabel::factory()->make([
|
|
||||||
'name' => 'Test Statuslabel Tag',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// setup
|
|
||||||
$data = [
|
|
||||||
'name' => $temp_statuslabel->name,
|
|
||||||
'archived' => $temp_statuslabel->archived,
|
|
||||||
'deployable' => $temp_statuslabel->deployable,
|
|
||||||
'notes' => $temp_statuslabel->notes,
|
|
||||||
'pending' => $temp_statuslabel->pending,
|
|
||||||
'type' => 'deployable',
|
|
||||||
];
|
|
||||||
|
|
||||||
// create
|
|
||||||
$I->sendPOST('/statuslabels', $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put is routed to the same method in the controller
|
|
||||||
// DO we actually need to test both?
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function updateStatuslabelWithPatch(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Update an statuslabel with PATCH');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$statuslabel = \App\Models\Statuslabel::factory()->rtd()->create([
|
|
||||||
'name' => 'Original Statuslabel Name',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Statuslabel::class, $statuslabel);
|
|
||||||
|
|
||||||
$temp_statuslabel = \App\Models\Statuslabel::factory()->pending()->make([
|
|
||||||
'name' => 'updated statuslabel name',
|
|
||||||
'type' => 'pending',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'name' => $temp_statuslabel->name,
|
|
||||||
'archived' => $temp_statuslabel->archived,
|
|
||||||
'deployable' => $temp_statuslabel->deployable,
|
|
||||||
'notes' => $temp_statuslabel->notes,
|
|
||||||
'pending' => $temp_statuslabel->pending,
|
|
||||||
'type' => $temp_statuslabel->type,
|
|
||||||
];
|
|
||||||
|
|
||||||
$I->assertNotEquals($statuslabel->name, $data['name']);
|
|
||||||
|
|
||||||
// update
|
|
||||||
$I->sendPATCH('/statuslabels/'.$statuslabel->id, $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
// dd($response);
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/statuslabels/message.update.success'), $response->messages);
|
|
||||||
$I->assertEquals($statuslabel->id, $response->payload->id); // statuslabel id does not change
|
|
||||||
$I->assertEquals($temp_statuslabel->name, $response->payload->name); // statuslabel name updated
|
|
||||||
// Some manual copying to compare against
|
|
||||||
$temp_statuslabel->created_at = Carbon::parse($response->payload->created_at);
|
|
||||||
$temp_statuslabel->updated_at = Carbon::parse($response->payload->updated_at);
|
|
||||||
$temp_statuslabel->id = $statuslabel->id;
|
|
||||||
|
|
||||||
// verify
|
|
||||||
$I->sendGET('/statuslabels/'.$statuslabel->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson((new StatuslabelsTransformer)->transformStatuslabel($temp_statuslabel));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function deleteStatuslabelTest(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Delete an statuslabel');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$statuslabel = \App\Models\Statuslabel::factory()->create([
|
|
||||||
'name' => 'Soon to be deleted',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\Statuslabel::class, $statuslabel);
|
|
||||||
|
|
||||||
// delete
|
|
||||||
$I->sendDELETE('/statuslabels/'.$statuslabel->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/statuslabels/message.delete.success'), $response->messages);
|
|
||||||
|
|
||||||
// verify, expect a 200
|
|
||||||
$I->sendGET('/statuslabels/'.$statuslabel->id);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,205 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Helpers\Helper;
|
|
||||||
use App\Http\Transformers\UsersTransformer;
|
|
||||||
use App\Models\Group;
|
|
||||||
use App\Models\Setting;
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
|
|
||||||
class ApiUsersCest
|
|
||||||
{
|
|
||||||
protected $user;
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
public function _before(ApiTester $I)
|
|
||||||
{
|
|
||||||
$this->user = \App\Models\User::find(1);
|
|
||||||
$I->haveHttpHeader('Accept', 'application/json');
|
|
||||||
$I->amBearerAuthenticated($I->getToken($this->user));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function indexUsers(ApiTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Get a list of users');
|
|
||||||
|
|
||||||
// call
|
|
||||||
$I->sendGET('/users?limit=10&sort=created_at');
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse(), true);
|
|
||||||
// sample verify
|
|
||||||
$user = App\Models\User::orderByDesc('created_at')
|
|
||||||
->withCount('assets as assets_count', 'licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count')
|
|
||||||
->take(10)->get()->shuffle()->first();
|
|
||||||
$I->seeResponseContainsJson($I->removeTimestamps((new UsersTransformer)->transformUser($user)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function createUser(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Create a new user');
|
|
||||||
|
|
||||||
$temp_user = \App\Models\User::factory()->make([
|
|
||||||
'name' => 'Test User Name',
|
|
||||||
]);
|
|
||||||
Group::factory()->count(2)->create();
|
|
||||||
$groups = Group::pluck('id');
|
|
||||||
// setup
|
|
||||||
$data = [
|
|
||||||
'activated' => $temp_user->activated,
|
|
||||||
'address' => $temp_user->address,
|
|
||||||
'city' => $temp_user->city,
|
|
||||||
'company_id' => $temp_user->company_id,
|
|
||||||
'country' => $temp_user->country,
|
|
||||||
'department_id' => $temp_user->department_id,
|
|
||||||
'email' => $temp_user->email,
|
|
||||||
'employee_num' => $temp_user->employee_num,
|
|
||||||
'first_name' => $temp_user->first_name,
|
|
||||||
'jobtitle' => $temp_user->jobtitle,
|
|
||||||
'last_name' => $temp_user->last_name,
|
|
||||||
'locale' => $temp_user->locale,
|
|
||||||
'location_id' => $temp_user->location_id,
|
|
||||||
'notes' => $temp_user->notes,
|
|
||||||
'manager_id' => $temp_user->manager_id,
|
|
||||||
'password' => $temp_user->password,
|
|
||||||
'password_confirmation' => $temp_user->password,
|
|
||||||
'phone' => $temp_user->phone,
|
|
||||||
'state' => $temp_user->state,
|
|
||||||
'username' => $temp_user->username,
|
|
||||||
'zip' => $temp_user->zip,
|
|
||||||
'groups' => $groups,
|
|
||||||
];
|
|
||||||
|
|
||||||
// create
|
|
||||||
$I->sendPOST('/users', $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$user = User::where('username', $temp_user->username)->first();
|
|
||||||
$I->assertEquals($groups, $user->groups()->pluck('id'));
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put is routed to the same method in the controller
|
|
||||||
// DO we actually need to test both?
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function updateUserWithPatch(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Update an user with PATCH');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$user = \App\Models\User::factory()->create([
|
|
||||||
'first_name' => 'Original User Name',
|
|
||||||
'company_id' => 2,
|
|
||||||
'location_id' => 3,
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\User::class, $user);
|
|
||||||
|
|
||||||
$temp_user = \App\Models\User::factory()->make([
|
|
||||||
'company_id' => 3,
|
|
||||||
'first_name' => 'updated user name',
|
|
||||||
'location_id' => 1,
|
|
||||||
]);
|
|
||||||
|
|
||||||
Group::factory()->count(2)->create();
|
|
||||||
$groups = Group::pluck('id');
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'activated' => $temp_user->activated,
|
|
||||||
'address' => $temp_user->address,
|
|
||||||
'city' => $temp_user->city,
|
|
||||||
'company_id' => $temp_user->company_id,
|
|
||||||
'country' => $temp_user->country,
|
|
||||||
'department_id' => $temp_user->department_id,
|
|
||||||
'email' => $temp_user->email,
|
|
||||||
'employee_num' => $temp_user->employee_num,
|
|
||||||
'first_name' => $temp_user->first_name,
|
|
||||||
'groups' => $groups,
|
|
||||||
'jobtitle' => $temp_user->jobtitle,
|
|
||||||
'last_name' => $temp_user->last_name,
|
|
||||||
'locale' => $temp_user->locale,
|
|
||||||
'location_id' => $temp_user->location_id,
|
|
||||||
'notes' => $temp_user->notes,
|
|
||||||
'manager_id' => $temp_user->manager_id,
|
|
||||||
'password' => $temp_user->password,
|
|
||||||
'phone' => $temp_user->phone,
|
|
||||||
'state' => $temp_user->state,
|
|
||||||
'username' => $temp_user->username,
|
|
||||||
'zip' => $temp_user->zip,
|
|
||||||
];
|
|
||||||
|
|
||||||
$I->assertNotEquals($user->first_name, $data['first_name']);
|
|
||||||
|
|
||||||
// update
|
|
||||||
$I->sendPATCH('/users/'.$user->id, $data);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/users/message.success.update'), $response->messages);
|
|
||||||
$I->assertEquals($user->id, $response->payload->id); // user id does not change
|
|
||||||
$I->assertEquals($temp_user->company_id, $response->payload->company->id); // company_id updated
|
|
||||||
$I->assertEquals($temp_user->first_name, $response->payload->first_name); // user name updated
|
|
||||||
$I->assertEquals($temp_user->location_id, $response->payload->location->id); // user location_id updated
|
|
||||||
$newUser = User::where('username', $temp_user->username)->first();
|
|
||||||
$I->assertEquals($groups, $newUser->groups()->pluck('id'));
|
|
||||||
$temp_user->created_at = Carbon::parse($response->payload->created_at->datetime);
|
|
||||||
$temp_user->updated_at = Carbon::parse($response->payload->updated_at->datetime);
|
|
||||||
$temp_user->id = $user->id;
|
|
||||||
// verify
|
|
||||||
$I->sendGET('/users/'.$user->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseContainsJson((new UsersTransformer)->transformUser($temp_user));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function deleteUserTest(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Delete an user');
|
|
||||||
|
|
||||||
// create
|
|
||||||
$user = \App\Models\User::factory()->create([
|
|
||||||
'first_name' => 'Soon to be deleted',
|
|
||||||
]);
|
|
||||||
$I->assertInstanceOf(\App\Models\User::class, $user);
|
|
||||||
|
|
||||||
// delete
|
|
||||||
$I->sendDELETE('/users/'.$user->id);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
// dd($response);
|
|
||||||
$I->assertEquals('success', $response->status);
|
|
||||||
$I->assertEquals(trans('admin/users/message.success.delete'), $response->messages);
|
|
||||||
|
|
||||||
// verify, expect a 200
|
|
||||||
$I->sendGET('/users/'.$user->id);
|
|
||||||
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @test */
|
|
||||||
public function fetchUserAssetsTest(ApiTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Fetch assets for a user');
|
|
||||||
|
|
||||||
$user = User::has('assets')->first();
|
|
||||||
$asset = $user->assets->shuffle()->first();
|
|
||||||
$I->sendGET("/users/{$user->id}/assets");
|
|
||||||
$response = json_decode($I->grabResponse());
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeResponseIsJson();
|
|
||||||
|
|
||||||
// Just test a random one.
|
|
||||||
$I->seeResponseContainsJson([
|
|
||||||
'asset_tag' => $asset->asset_tag,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// Here you can initialize variables that will be available to your tests
|
|
|
@ -1,19 +0,0 @@
|
||||||
# Codeception Test Suite Configuration
|
|
||||||
#
|
|
||||||
# Suite for functional (integration) tests
|
|
||||||
# Emulate web requests and make application process them
|
|
||||||
# Include one of framework modules (Symfony2, Yii2, Laravel5) to use it
|
|
||||||
|
|
||||||
class_name: FunctionalTester
|
|
||||||
modules:
|
|
||||||
enabled:
|
|
||||||
# add framework module here
|
|
||||||
- \Helper\Functional
|
|
||||||
- Laravel5:
|
|
||||||
environment_file: .env.tests
|
|
||||||
cleanup: true
|
|
||||||
- REST:
|
|
||||||
depends: Laravel5
|
|
||||||
groups:
|
|
||||||
func1: tests/functional/func-part-1.txt
|
|
||||||
func2: tests/functional/func-part-2.txt
|
|
|
@ -1,84 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class AccessoriesCest
|
|
||||||
{
|
|
||||||
public function _before(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'admin');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
$I->seeAuthentication();
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function loadsFormWithoutErrors(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('ensure that the create accessories form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage('/accessories/create');
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->dontSee('Create Accessory', '.page-header');
|
|
||||||
$I->see('Create Accessory', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsEmptyValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with blank elements');
|
|
||||||
$I->amOnPage('/accessories/create');
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name field is required.', '.alert-msg');
|
|
||||||
$I->see('The category id field is required.', '.alert-msg');
|
|
||||||
$I->see('The qty field is required.', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsShortValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with short name');
|
|
||||||
$I->amOnPage('/accessories/create');
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->fillField('name', 't2');
|
|
||||||
$I->fillField('qty', '-15');
|
|
||||||
$I->fillField('min_amt', '-15');
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name must be at least 3 characters', '.alert-msg');
|
|
||||||
$I->see('The category id field is required', '.alert-msg');
|
|
||||||
$I->see('The qty must be at least 1', '.alert-msg');
|
|
||||||
$I->see('The min amt must be at least 0', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$accessory = \App\Models\Accessory::factory()->appleBtKeyboard()->make();
|
|
||||||
$values = [
|
|
||||||
'category_id' => $accessory->category_id,
|
|
||||||
'location_id' => $accessory->location_id,
|
|
||||||
'manufacturer_id' => $accessory->manufacturer_id,
|
|
||||||
'min_amt' => $accessory->min_amt,
|
|
||||||
'name' => 'Test Accessory',
|
|
||||||
'order_number' => $accessory->order_number,
|
|
||||||
'purchase_date' => '2016-01-01',
|
|
||||||
'qty' => $accessory->qty,
|
|
||||||
];
|
|
||||||
|
|
||||||
$I->wantTo('Test Validation Succeeds');
|
|
||||||
$I->amOnPage('/accessories/create');
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
|
|
||||||
$I->submitForm('form#create-form', $values);
|
|
||||||
$I->seeRecord('accessories', $values);
|
|
||||||
|
|
||||||
$I->dontSee('<span class="');
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Ensure I can delete an accessory');
|
|
||||||
$I->sendDelete(route('accessories.destroy', $I->getAccessoryId()), ['_token' => csrf_token()]);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class AssetModelsCest
|
|
||||||
{
|
|
||||||
public function _before(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'admin');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function tryToTest(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Asset Model Creation');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage(route('models.create'));
|
|
||||||
$I->seeInTitle('Create Asset Model');
|
|
||||||
$I->see('Create Asset Model', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsEmptyValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with blank elements');
|
|
||||||
$I->amOnPage(route('models.create'));
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name field is required.', '.alert-msg');
|
|
||||||
$I->see('The manufacturer id field is required.', '.alert-msg');
|
|
||||||
$I->see('The category id field is required.', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$model = \App\Models\AssetModel::factory()->mbp13Model()->make(['name'=>'Test Model']);
|
|
||||||
$values = [
|
|
||||||
'category_id' => $model->category_id,
|
|
||||||
'depreciation_id' => $model->depreciation_id,
|
|
||||||
'eol' => $model->eol,
|
|
||||||
'manufacturer_id' => $model->manufacturer_id,
|
|
||||||
'model_number' => $model->model_number,
|
|
||||||
'name' => $model->name,
|
|
||||||
'notes' => $model->notes,
|
|
||||||
];
|
|
||||||
|
|
||||||
$I->wantTo('Test Validation Succeeds');
|
|
||||||
$I->amOnPage(route('models.create'));
|
|
||||||
|
|
||||||
$I->submitForm('form#create-form', $values);
|
|
||||||
$I->seeRecord('models', $values);
|
|
||||||
$I->dontSee('<span class="');
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Ensure I can delete an asset model');
|
|
||||||
$model = \App\Models\AssetModel::factory()->mbp13Model()->create(['name' => 'Test Model']);
|
|
||||||
$I->sendDelete(route('models.destroy', $model->id), ['_token' => csrf_token()]);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,94 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class AssetsCest
|
|
||||||
{
|
|
||||||
public function _before(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'admin');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function tryToTest(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('ensure that the create assets form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage(route('hardware.create'));
|
|
||||||
$I->dontSee('Create Asset', '.page-header');
|
|
||||||
$I->see('Create Asset', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsEmptyValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with blank elements');
|
|
||||||
$I->amOnPage(route('hardware.create'));
|
|
||||||
// Settings factory can enable auto prefixes, which generate a random asset id. Lets clear it out for the sake of this test.
|
|
||||||
$I->fillField('#asset_tag', '');
|
|
||||||
$I->click('Save');
|
|
||||||
$I->see('The asset tag field is required.', '.alert-msg');
|
|
||||||
$I->see('The model id field is required.', '.alert-msg');
|
|
||||||
$I->see('The status id field is required.', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passesCreateAndCheckout(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$asset = \App\Models\Asset::factory()->laptopMbp()->make([
|
|
||||||
'asset_tag'=>'test tag',
|
|
||||||
'name'=> 'test asset',
|
|
||||||
'company_id'=>1,
|
|
||||||
'warranty_months'=>15,
|
|
||||||
]);
|
|
||||||
$userId = $I->getUserId();
|
|
||||||
$values = [
|
|
||||||
'asset_tags[1]' => $asset->asset_tag,
|
|
||||||
'assigned_user' => $userId,
|
|
||||||
'company_id' => $asset->company_id,
|
|
||||||
'model_id' => $asset->model_id,
|
|
||||||
'name' => $asset->name,
|
|
||||||
'notes' => $asset->notes,
|
|
||||||
'order_number' => $asset->order_number,
|
|
||||||
'purchase_cost' => $asset->purchase_cost,
|
|
||||||
'purchase_date' => '2016-01-01',
|
|
||||||
'requestable' => $asset->requestable,
|
|
||||||
'rtd_location_id' => $asset->rtd_location_id,
|
|
||||||
'serials[1]' => $asset->serial,
|
|
||||||
'status_id' => $asset->status_id,
|
|
||||||
'supplier_id' => $asset->supplier_id,
|
|
||||||
'warranty_months' => $asset->warranty_months,
|
|
||||||
];
|
|
||||||
|
|
||||||
$seenValues = [
|
|
||||||
'asset_tag' => $asset->asset_tag,
|
|
||||||
'assigned_to' => $userId,
|
|
||||||
'assigned_type' => \App\Models\User::class,
|
|
||||||
'company_id' => $asset->company_id,
|
|
||||||
'model_id' => $asset->model_id,
|
|
||||||
'name' => $asset->name,
|
|
||||||
'notes' => $asset->notes,
|
|
||||||
'order_number' => $asset->order_number,
|
|
||||||
'purchase_cost' => $asset->purchase_cost,
|
|
||||||
'purchase_date' => '2016-01-01',
|
|
||||||
'requestable' => $asset->requestable,
|
|
||||||
'rtd_location_id' => $asset->rtd_location_id,
|
|
||||||
'serial' => $asset->serial,
|
|
||||||
'status_id' => $asset->status_id,
|
|
||||||
'supplier_id' => $asset->supplier_id,
|
|
||||||
'warranty_months' => $asset->warranty_months,
|
|
||||||
];
|
|
||||||
|
|
||||||
$I->wantTo('Test Validation Succeeds');
|
|
||||||
$I->amOnPage(route('hardware.create'));
|
|
||||||
$I->submitForm('form#create-form', $values);
|
|
||||||
$I->seeRecord('assets', $seenValues);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Ensure I can delete an asset');
|
|
||||||
$I->sendDelete(route('hardware.destroy', $I->getAssetId()), ['_token' => csrf_token()]);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class CategoriesCest
|
|
||||||
{
|
|
||||||
public function _before(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'admin');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function _after(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function tryToTest(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Category Creation');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage(route('categories.create'));
|
|
||||||
$I->seeInTitle('Create Category');
|
|
||||||
$I->see('Create Category', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsEmptyValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with blank elements');
|
|
||||||
$I->amOnPage(route('categories.create'));
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name field is required.', '.alert-msg');
|
|
||||||
$I->see('The category type field is required.', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$category = \App\Models\Category::factory()->assetLaptopCategory()->make([
|
|
||||||
'name' => 'Test Category',
|
|
||||||
]);
|
|
||||||
$values = [
|
|
||||||
'category_type' => $category->category_type,
|
|
||||||
'checkin_email' => $category->checkin_email,
|
|
||||||
'eula_text' => $category->eula_text,
|
|
||||||
'name' => $category->name,
|
|
||||||
'require_acceptance' => $category->require_acceptance,
|
|
||||||
];
|
|
||||||
$I->wantTo('Test Validation Succeeds');
|
|
||||||
$I->amOnPage(route('categories.create'));
|
|
||||||
$I->submitForm('form#create-form', $values);
|
|
||||||
$I->seeRecord('categories', $values);
|
|
||||||
$I->dontSee('<span class="');
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Ensure I can delete a category');
|
|
||||||
$category = \App\Models\Category::factory()->assetLaptopCategory()->create([
|
|
||||||
'name'=>'Deletable Test Category',
|
|
||||||
]);
|
|
||||||
$I->sendDelete(route('categories.destroy', $category->id), ['_token' => csrf_token()]);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class CompaniesCest
|
|
||||||
{
|
|
||||||
public function _before(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'admin');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function tryToTest(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Company Creation');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage(route('companies.create'));
|
|
||||||
$I->seeInTitle('Create Company');
|
|
||||||
$I->see('Create Company', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsEmptyValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with blank elements');
|
|
||||||
$I->amOnPage(route('companies.create'));
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name field is required.', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$company = \App\Models\Company::factory()->make();
|
|
||||||
$values = [
|
|
||||||
'name' => $company->name,
|
|
||||||
];
|
|
||||||
$I->wantTo('Test Validation Succeeds');
|
|
||||||
$I->amOnPage(route('companies.create'));
|
|
||||||
$I->fillField('name', 'TestCompany');
|
|
||||||
$I->submitForm('form#create-form', $values);
|
|
||||||
$I->seeRecord('companies', $values);
|
|
||||||
$I->dontSee('<span class="');
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,79 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class ComponentsCest
|
|
||||||
{
|
|
||||||
public function _before(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'admin');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function tryToTest(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('ensure that the create components form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage(route('components.create'));
|
|
||||||
$I->dontSee('Create Component', '.page-header');
|
|
||||||
$I->see('Create Component', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsEmptyValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with blank elements');
|
|
||||||
$I->amOnPage(route('components.create'));
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name field is required.', '.alert-msg');
|
|
||||||
$I->see('The category id field is required.', '.alert-msg');
|
|
||||||
$I->see('The qty field is required.', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsShortValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with short name');
|
|
||||||
$I->amOnPage(route('components.create'));
|
|
||||||
$I->fillField('name', 't2');
|
|
||||||
$I->fillField('qty', '-15');
|
|
||||||
$I->fillField('min_amt', '-15');
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name must be at least 3 characters', '.alert-msg');
|
|
||||||
$I->see('The qty must be at least 1', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$component = \App\Models\Component::factory()->ramCrucial4()->make([
|
|
||||||
'name' => 'Test Component',
|
|
||||||
'serial' => '3523-235325-1350235',
|
|
||||||
]);
|
|
||||||
$values = [
|
|
||||||
'category_id' => $component->category_id,
|
|
||||||
'company_id' => $component->company_id,
|
|
||||||
'location_id' => $component->location_id,
|
|
||||||
'min_amt' => $component->min_amt,
|
|
||||||
'name' => $component->name,
|
|
||||||
'order_number' => $component->order_number,
|
|
||||||
'purchase_cost' => $component->purchase_cost,
|
|
||||||
'purchase_date' => '2016-01-01',
|
|
||||||
'qty' => $component->qty,
|
|
||||||
'serial' => $component->serial,
|
|
||||||
];
|
|
||||||
$I->wantTo('Test Validation Succeeds');
|
|
||||||
$I->amOnPage(route('components.create'));
|
|
||||||
$I->submitForm('form#create-form', $values);
|
|
||||||
$I->seeRecord('components', $values);
|
|
||||||
$I->dontSee('<span class="');
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Ensure I can delete a component');
|
|
||||||
$I->sendDelete(route('components.destroy', $I->getComponentId()), ['_token' => csrf_token()]);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,81 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class ConsumablesCest
|
|
||||||
{
|
|
||||||
public function _before(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'admin');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function tryToTest(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('ensure that the create consumables form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage(route('consumables.create'));
|
|
||||||
$I->dontSee('Create Consumable', '.page-header');
|
|
||||||
$I->see('Create Consumable', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsEmptyValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with blank elements');
|
|
||||||
$I->amOnPage(route('consumables.create'));
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name field is required.', '.alert-msg');
|
|
||||||
$I->see('The category id field is required.', '.alert-msg');
|
|
||||||
$I->see('The qty field is required.', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsShortValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with short name');
|
|
||||||
$I->amOnPage(route('consumables.create'));
|
|
||||||
$I->fillField('name', 't2');
|
|
||||||
$I->fillField('qty', '-15');
|
|
||||||
$I->fillField('min_amt', '-15');
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name must be at least 3 characters', '.alert-msg');
|
|
||||||
$I->see('The qty must be at least 0', '.alert-msg');
|
|
||||||
$I->see('The min amt must be at least 0', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$consumable = \App\Models\Consumable::factory()->cardstock()->make([
|
|
||||||
'name' => 'Test Consumable',
|
|
||||||
'model_number' => 23520,
|
|
||||||
]);
|
|
||||||
// dd($consumable);
|
|
||||||
$values = [
|
|
||||||
'category_id' => $consumable->category_id,
|
|
||||||
'company_id' => $consumable->company_id,
|
|
||||||
'item_no' => $consumable->item_no,
|
|
||||||
'manufacturer_id' => $consumable->manufacturer_id,
|
|
||||||
'min_amt' => $consumable->min_amt,
|
|
||||||
'model_number' => $consumable->model_number,
|
|
||||||
'name' => $consumable->name,
|
|
||||||
'order_number' => $consumable->order_number,
|
|
||||||
'purchase_cost' => $consumable->purchase_cost,
|
|
||||||
'purchase_date' => '2016-01-01',
|
|
||||||
'qty' => $consumable->qty,
|
|
||||||
];
|
|
||||||
$I->wantTo('Test Validation Succeeds');
|
|
||||||
$I->amOnPage(route('consumables.create'));
|
|
||||||
$I->submitForm('form#create-form', $values);
|
|
||||||
$I->seeRecord('consumables', $values);
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Ensure I can delete a consumable');
|
|
||||||
$I->sendDelete(route('consumables.destroy', $I->getConsumableId()), ['_token' => csrf_token()]);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class DepreciationsCest
|
|
||||||
{
|
|
||||||
public function _before(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'admin');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function tryToTest(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Depreciation Creation');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage(route('depreciations.create'));
|
|
||||||
$I->seeInTitle('Create Depreciation');
|
|
||||||
$I->dontSee('Create Depreciation', '.page-header');
|
|
||||||
$I->see('Create Depreciation', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsEmptyValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with blank elements');
|
|
||||||
$I->amOnPage(route('depreciations.create'));
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name field is required.', '.alert-msg');
|
|
||||||
$I->see('The months field is required.', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsShortValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with short name');
|
|
||||||
$I->amOnPage(route('depreciations.create'));
|
|
||||||
$I->fillField('name', 't2');
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name must be at least 3 characters', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$depreciation = \App\Models\Depreciation::factory()->computer()->make([
|
|
||||||
'name'=>'Test Depreciation',
|
|
||||||
]);
|
|
||||||
$values = [
|
|
||||||
'name' => $depreciation->name,
|
|
||||||
'months' => $depreciation->months,
|
|
||||||
];
|
|
||||||
$I->wantTo('Test Validation Succeeds');
|
|
||||||
$I->amOnPage(route('depreciations.create'));
|
|
||||||
$I->submitForm('form#create-form', $values);
|
|
||||||
$I->seeRecord('depreciations', $values);
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Ensure I can delete a depreciation');
|
|
||||||
$I->sendDelete(route('depreciations.destroy', $I->getDepreciationId()), ['_token' => csrf_token()]);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Models\Group;
|
|
||||||
|
|
||||||
class GroupsCest
|
|
||||||
{
|
|
||||||
public function _before(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'admin');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function loadsFormWithoutErrors(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('ensure that the create groups form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage(route('groups.create'));
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->dontSee('Create New Group', '.page-header');
|
|
||||||
$I->see('Create New Group', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsEmptyValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with blank elements');
|
|
||||||
$I->amOnPage(route('groups.create'));
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name field is required.', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsShortValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with short name');
|
|
||||||
$I->amOnPage(route('groups.create'));
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->fillField('name', 't');
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name must be at least 2 characters', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Succeeds');
|
|
||||||
$I->amOnPage(route('groups.create'));
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->fillField('name', 'TestGroup');
|
|
||||||
$I->click('Save');
|
|
||||||
$I->dontSee('<span class="');
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$I->wantTo('Ensure I can delete a group');
|
|
||||||
// create a group
|
|
||||||
$I->amOnPage(route('groups.create'));
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->fillField('name', 'TestGroup');
|
|
||||||
$I->click('Save');
|
|
||||||
$I->dontSee('<span class="');
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
|
|
||||||
$I->sendDelete(route('groups.destroy', Group::whereName('TestGroup')->doesntHave('users')->first()->id));
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,88 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Models\License;
|
|
||||||
|
|
||||||
class LicensesCest
|
|
||||||
{
|
|
||||||
public function _before(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'admin');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function tryToTest(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('ensure that the create licenses form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage(route('licenses.create'));
|
|
||||||
$I->dontSee('Create License', '.page-header');
|
|
||||||
$I->see('Create License', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsEmptyValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with blank elements');
|
|
||||||
$I->amOnPage(route('licenses.create'));
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name field is required.', '.alert-msg');
|
|
||||||
$I->see('The seats field is required.', '.alert-msg');
|
|
||||||
$I->see('The category id field is required.', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsShortValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with short name');
|
|
||||||
$I->amOnPage(route('licenses.create'));
|
|
||||||
$I->fillField('name', 't2');
|
|
||||||
$I->fillField('seats', '-15');
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name must be at least 3 characters', '.alert-msg');
|
|
||||||
$I->see('The seats must be at least 1', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$license = \App\Models\License::factory()->photoshop()->make([
|
|
||||||
'name' => 'Test License',
|
|
||||||
'company_id' => 3,
|
|
||||||
]);
|
|
||||||
$values = [
|
|
||||||
'company_id' => $license->company_id,
|
|
||||||
'expiration_date' => '2018-01-01',
|
|
||||||
'license_email' => $license->license_email,
|
|
||||||
'license_name' => $license->license_name,
|
|
||||||
'maintained' => true,
|
|
||||||
'manufacturer_id' => $license->manufacturer_id,
|
|
||||||
'category_id' => $license->category_id,
|
|
||||||
'name' => $license->name,
|
|
||||||
'notes' => $license->notes,
|
|
||||||
'order_number' => $license->order_number,
|
|
||||||
'purchase_cost' => $license->purchase_cost,
|
|
||||||
'purchase_date' => '2016-01-01',
|
|
||||||
'purchase_order' => $license->purchase_order,
|
|
||||||
'reassignable' => true,
|
|
||||||
'seats' => $license->seats,
|
|
||||||
'serial' => $license->serial,
|
|
||||||
'termination_date' => '2020-01-01',
|
|
||||||
];
|
|
||||||
|
|
||||||
$I->wantTo('Test Validation Succeeds');
|
|
||||||
$I->amOnPage(route('licenses.create'));
|
|
||||||
$I->submitForm('form#create-form', $values);
|
|
||||||
$I->seeRecord('licenses', $values);
|
|
||||||
$I->dontSee('<span class="');
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Ensure I can delete a license');
|
|
||||||
$I->sendDelete(route('licenses.destroy', License::doesntHave('assignedUsers')->first()->id), ['_token' => csrf_token()]);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Models\Location;
|
|
||||||
|
|
||||||
class LocationsCest
|
|
||||||
{
|
|
||||||
public function _before(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
// logging in
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'admin');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function tryToTest(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
/* Create Form */
|
|
||||||
$I->wantTo('Test Location Creation');
|
|
||||||
$I->lookForwardTo('Finding no Failures');
|
|
||||||
$I->amOnPage(route('locations.create'));
|
|
||||||
$I->dontSee('Create Location', '.page-header');
|
|
||||||
$I->see('Create Location', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsEmptyValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with blank elements');
|
|
||||||
$I->amOnPage(route('locations.create'));
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name field is required.', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsShortValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with short values');
|
|
||||||
$I->amOnPage(route('locations.create'));
|
|
||||||
$I->fillField('name', 't');
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name must be at least 2 characters', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$location = \App\Models\Location::factory()->make();
|
|
||||||
$values = [
|
|
||||||
'name' => $location->name,
|
|
||||||
'parent_id' => $I->getLocationId(),
|
|
||||||
'currency' => $location->currency,
|
|
||||||
'address' => $location->address,
|
|
||||||
'address2' => $location->address2,
|
|
||||||
'city' => $location->city,
|
|
||||||
'state' => $location->state,
|
|
||||||
'country' => $location->country,
|
|
||||||
'zip' => $location->zip,
|
|
||||||
];
|
|
||||||
$I->wantTo('Test Validation Succeeds');
|
|
||||||
$I->amOnPage(route('locations.create'));
|
|
||||||
$I->submitForm('form#create-form', $values);
|
|
||||||
$I->seeRecord('locations', $values);
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Ensure I can delete a location');
|
|
||||||
$location = \App\Models\Location::factory()->create();
|
|
||||||
$I->sendDelete(route('locations.destroy', $location->id), ['_token' => csrf_token()]);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Models\Manufacturer;
|
|
||||||
|
|
||||||
class ManufacturersCest
|
|
||||||
{
|
|
||||||
public function _before(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'admin');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function tryToTest(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Manufacturer Creation');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage(route('manufacturers.create'));
|
|
||||||
$I->seeInTitle('Create Manufacturer');
|
|
||||||
$I->see('Create Manufacturer', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsEmptyValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with blank elements');
|
|
||||||
$I->amOnPage(route('manufacturers.create'));
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name field is required.', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsShortValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with short name');
|
|
||||||
$I->amOnPage(route('manufacturers.create'));
|
|
||||||
$I->fillField('name', 't');
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name must be at least 2 characters', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$manufacturer = \App\Models\Manufacturer::factory()->microsoft()->make([
|
|
||||||
'name' => 'Test Manufacturer',
|
|
||||||
]);
|
|
||||||
$values = [
|
|
||||||
'name' => $manufacturer->name,
|
|
||||||
];
|
|
||||||
$I->wantTo('Test Validation Succeeds');
|
|
||||||
$I->amOnPage(route('manufacturers.create'));
|
|
||||||
$I->submitForm('form#create-form', $values);
|
|
||||||
$I->seeRecord('manufacturers', $values);
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Ensure I can delete a manufacturer');
|
|
||||||
$manufacturerId = \App\Models\Manufacturer::factory()->microsoft()->create(['name' => 'Deletable Test Manufacturer'])->id;
|
|
||||||
$I->sendDelete(route('manufacturers.destroy', $manufacturerId), ['_token' => csrf_token()]);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Models\Statuslabel;
|
|
||||||
|
|
||||||
class StatusLabelsCest
|
|
||||||
{
|
|
||||||
public function _before(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'admin');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function tryToTest(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('ensure that the create statuslabels form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage(route('statuslabels.create'));
|
|
||||||
$I->dontSee('Create Status Label', '.page-header');
|
|
||||||
$I->see('Create Status Label', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsEmptyValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with blank elements');
|
|
||||||
$I->amOnPage(route('statuslabels.create'));
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name field is required.', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$status = \App\Models\Statuslabel::factory()->pending()->make();
|
|
||||||
$submitValues = [
|
|
||||||
'name' => 'Testing Status',
|
|
||||||
'statuslabel_types' => 'pending',
|
|
||||||
'color' => '#b46262',
|
|
||||||
'notes' => $status->notes,
|
|
||||||
'show_in_nav' => true,
|
|
||||||
];
|
|
||||||
|
|
||||||
$recordValues = [
|
|
||||||
'name' => 'Testing Status',
|
|
||||||
'pending' => $status->pending,
|
|
||||||
'deployable' => $status->archived,
|
|
||||||
'archived' => $status->deployable,
|
|
||||||
'color' => '#b46262',
|
|
||||||
'notes' => $status->notes,
|
|
||||||
'show_in_nav' => true,
|
|
||||||
];
|
|
||||||
$I->wantTo('Test Validation Succeeds');
|
|
||||||
$I->amOnPage(route('statuslabels.create'));
|
|
||||||
$I->submitForm('form#create-form', $submitValues);
|
|
||||||
$I->seeRecord('status_labels', $recordValues);
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Ensure I can delete a Status Label');
|
|
||||||
$I->sendDelete(route('statuslabels.destroy', Statuslabel::doesntHave('assets')->first()->id), ['_token' => csrf_token()]);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class SuppliersCest
|
|
||||||
{
|
|
||||||
public function _before(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'admin');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function tryToTest(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('ensure that the create settings/suppliers form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage(route('suppliers.create'));
|
|
||||||
$I->dontSee('Create Supplier', '.page-header');
|
|
||||||
$I->see('Create Supplier', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsEmptyValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with blank elements');
|
|
||||||
$I->amOnPage(route('suppliers.create'));
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The name field is required.', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$supplier = \App\Models\Supplier::factory()->make();
|
|
||||||
|
|
||||||
$values = [
|
|
||||||
'name' => $supplier->name,
|
|
||||||
'address' => $supplier->address,
|
|
||||||
'address2' => $supplier->address2,
|
|
||||||
'city' => $supplier->city,
|
|
||||||
'state' => $supplier->state,
|
|
||||||
'zip' => $supplier->zip,
|
|
||||||
'country' => $supplier->country,
|
|
||||||
'contact' => $supplier->contact,
|
|
||||||
'phone' => $supplier->phone,
|
|
||||||
'fax' => $supplier->fax,
|
|
||||||
'email' => $supplier->email,
|
|
||||||
'url' => $supplier->url,
|
|
||||||
'notes' => $supplier->notes,
|
|
||||||
];
|
|
||||||
$I->wantTo('Test Validation Succeeds');
|
|
||||||
$I->amOnPage(route('suppliers.create'));
|
|
||||||
$I->submitForm('form#create-form', $values);
|
|
||||||
$I->seeRecord('suppliers', $values);
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Ensure I can delete a supplier');
|
|
||||||
$supplier = \App\Models\Supplier::factory()->create();
|
|
||||||
$I->sendDelete(route('suppliers.destroy', $supplier->id), ['_token' => csrf_token()]);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,98 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
|
|
||||||
class UsersCest
|
|
||||||
{
|
|
||||||
public function _before(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->amOnPage('/login');
|
|
||||||
$I->fillField('username', 'admin');
|
|
||||||
$I->fillField('password', 'password');
|
|
||||||
$I->click('Login');
|
|
||||||
}
|
|
||||||
|
|
||||||
// tests
|
|
||||||
public function tryToTest(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('ensure that the create users form loads without errors');
|
|
||||||
$I->lookForwardTo('seeing it load without errors');
|
|
||||||
$I->amOnPage(route('users.create'));
|
|
||||||
$I->dontSee('Create User', '.page-header');
|
|
||||||
$I->see('Create User', 'h1.pull-left');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsEmptyValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with blank elements');
|
|
||||||
$I->amOnPage(route('users.create'));
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The first name field is required.', '.alert-msg');
|
|
||||||
$I->see('The username field is required unless ldap import is in 1.', '.alert-msg');
|
|
||||||
$I->see('The password field is required.', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function failsShortValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$I->wantTo('Test Validation Fails with short name');
|
|
||||||
$I->amOnPage(route('users.create'));
|
|
||||||
$I->fillField('first_name', 't2');
|
|
||||||
$I->fillField('last_name', 't2');
|
|
||||||
$I->fillField('username', 'a');
|
|
||||||
$I->fillField('password', '12345');
|
|
||||||
$I->click('Save');
|
|
||||||
$I->seeElement('.alert-danger');
|
|
||||||
$I->see('The password must be at least 8 characters', '.alert-msg');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function passesCorrectValidation(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$user = \App\Models\User::factory()->make();
|
|
||||||
$submitValues = [
|
|
||||||
'first_name' => $user->first_name,
|
|
||||||
'last_name' => $user->last_name,
|
|
||||||
'username' => $user->username,
|
|
||||||
'password' => $user->password,
|
|
||||||
'password_confirmation' => $user->password,
|
|
||||||
'email' => $user->email,
|
|
||||||
'company_id' => $user->company_id,
|
|
||||||
'locale' => $user->locale,
|
|
||||||
'employee_num' => $user->employee_num,
|
|
||||||
'jobtitle' => $user->jobtitle,
|
|
||||||
'manager_id' => $user->manager_id,
|
|
||||||
'location_id' => $user->location_id,
|
|
||||||
'phone' => $user->phone,
|
|
||||||
'activated' => true,
|
|
||||||
'notes' => $user->notes,
|
|
||||||
];
|
|
||||||
$storedValues = [
|
|
||||||
'first_name' => $user->first_name,
|
|
||||||
'last_name' => $user->last_name,
|
|
||||||
'username' => $user->username,
|
|
||||||
'email' => $user->email,
|
|
||||||
'company_id' => $user->company_id,
|
|
||||||
'locale' => $user->locale,
|
|
||||||
'employee_num' => $user->employee_num,
|
|
||||||
'jobtitle' => $user->jobtitle,
|
|
||||||
'manager_id' => $user->manager_id,
|
|
||||||
'location_id' => $user->location_id,
|
|
||||||
'phone' => $user->phone,
|
|
||||||
'activated' => true,
|
|
||||||
'notes' => $user->notes,
|
|
||||||
];
|
|
||||||
$I->amOnPage(route('users.create'));
|
|
||||||
$I->wantTo('Test Validation Succeeds');
|
|
||||||
$I->submitForm('form#userForm', $submitValues);
|
|
||||||
$I->seeRecord('users', $storedValues);
|
|
||||||
$I->seeElement('.alert-success');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I)
|
|
||||||
{
|
|
||||||
$user = \App\Models\User::factory()->create();
|
|
||||||
$I->wantTo('Ensure I can delete a user');
|
|
||||||
$I->sendDelete(route('users.destroy', $user->id), ['_token' => csrf_token()]);
|
|
||||||
$I->seeResponseCodeIs(200);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// Here you can initialize variables that will be available to your tests
|
|
|
@ -1,8 +0,0 @@
|
||||||
tests/functional/AccessoriesCest.php
|
|
||||||
tests/functional/AssetModelsCest.php
|
|
||||||
tests/functional/AssetsCest.php
|
|
||||||
tests/functional/CategoriesCest.php
|
|
||||||
tests/functional/CompaniesCest.php
|
|
||||||
tests/functional/ComponentsCest.php
|
|
||||||
tests/functional/ConsumablesCest.php
|
|
||||||
tests/functional/DepreciationsCest.php
|
|
|
@ -1,7 +0,0 @@
|
||||||
tests/functional/GroupsCest.php
|
|
||||||
tests/functional/LicensesCest.php
|
|
||||||
tests/functional/LocationsCest.php
|
|
||||||
tests/functional/ManufacturersCest.php
|
|
||||||
tests/functional/StatusLabelsCest.php
|
|
||||||
tests/functional/SuppliersCest.php
|
|
||||||
tests/functional/UsersCest.php
|
|
|
@ -1,10 +0,0 @@
|
||||||
# Codeception Test Suite Configuration
|
|
||||||
|
|
||||||
# suite for unit (internal) tests.
|
|
||||||
class_name: UnitTester
|
|
||||||
modules:
|
|
||||||
enabled:
|
|
||||||
- \Helper\Unit
|
|
||||||
- Asserts
|
|
||||||
- Laravel5:
|
|
||||||
environment_file: .env.unit-tests
|
|
Loading…
Reference in a new issue