-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Amitesh
authored and
Amitesh
committed
Aug 11, 2020
1 parent
2fd5a27
commit 0e90e1f
Showing
8 changed files
with
190 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
|
||
namespace Tests\Feature; | ||
|
||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Illuminate\Foundation\Testing\WithFaker; | ||
use Tests\TestCase; | ||
use App\Model\ServerDetail; | ||
|
||
class ShowServerDetailsControllerTest extends TestCase | ||
{ | ||
/** | ||
* A basic feature test example. | ||
* | ||
* @return void | ||
*/ | ||
public function testExample() | ||
{ | ||
$response = $this->get('/'); | ||
|
||
$response->assertStatus(200); | ||
} | ||
/** | ||
* fetch Data | ||
**/ | ||
public function testshowData() | ||
{ | ||
|
||
factory(ServerDetail::class)->create([ | ||
'id' => 1, | ||
'model' => 'model1', | ||
'ram' => 'ram1', | ||
'hardisk' => 'hardisk1', | ||
'location' => 'India1', | ||
'price' => '$100', | ||
'hardisk_capacity_mb' => 1000000, | ||
'ram_capacity_mb' => 100000, | ||
"created_at" => "2020-08-10T21:35:46.000000Z", | ||
"updated_at" => "2020-08-10T21:35:46.000000Z" | ||
]); | ||
|
||
factory(ServerDetail::class)->create([ | ||
'id' => 2, | ||
'model' => 'model2', | ||
'ram' => 'ram2', | ||
'hardisk' => 'hardisk2', | ||
'location' => 'India2', | ||
'price' => '$101', | ||
'hardisk_capacity_mb' => 2000000, | ||
'ram_capacity_mb' => 200000, | ||
"created_at" => "2020-08-10T21:35:46.000000Z", | ||
"updated_at" => "2020-08-10T21:35:46.000000Z" | ||
]); | ||
|
||
$response = $this->json('GET', '/api/v1/search') | ||
->assertStatus(200) | ||
|
||
//print_r($response->data); die; | ||
->assertExactJson([ 'data' => | ||
[ | ||
[ 'id' => 1, | ||
'model' => 'model1', | ||
'ram' => 'ram1', | ||
'hardisk' => 'hardisk1', | ||
'location' => 'India1', | ||
'price' => '$100', | ||
'hardisk_capacity_mb' => 1000000, | ||
'ram_capacity_mb' => 100000, | ||
"created_at" => "2020-08-10T21:35:46.000000Z", | ||
"updated_at" => "2020-08-10T21:35:46.000000Z" | ||
], | ||
[ | ||
'id' => 2, | ||
'model' => 'model2', | ||
'ram' => 'ram2', | ||
'hardisk' => 'hardisk2', | ||
'location' => 'India2', | ||
'price' => '$101', | ||
'hardisk_capacity_mb' => 2000000, | ||
'ram_capacity_mb' => 200000, | ||
"created_at" => "2020-08-10T21:35:46.000000Z", | ||
"updated_at" => "2020-08-10T21:35:46.000000Z" | ||
] | ||
] | ||
]) | ||
->assertJsonStructure( | ||
[ | ||
'data' => [ | ||
'*' => [ | ||
'model', | ||
'ram', | ||
'hardisk', | ||
'location', | ||
'price', | ||
'hardisk_capacity_mb', | ||
'ram_capacity_mb', | ||
'created_at', | ||
'updated_at' | ||
] | ||
] | ||
] | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace Tests\Unit; | ||
|
||
use Tests\TestCase; | ||
use Illuminate\Http\UploadedFile; | ||
use Maatwebsite\Excel\Facades\Excel; | ||
use App\Model\ServerDetail; | ||
use App\Repositories\ServerDetailRepository; | ||
|
||
|
||
class ServerDetailRepositoryTest extends TestCase | ||
{ | ||
/** | ||
* A basic unit test example. | ||
* | ||
* @return void | ||
*/ | ||
public function testExample() | ||
{ | ||
$this->assertTrue(true); | ||
} | ||
|
||
/** | ||
* Test Hardisk conversion to mb from string. | ||
* | ||
* @return void | ||
*/ | ||
|
||
public function testCapacityHardiskMB(){ | ||
|
||
$repository = new \App\Repositories\ServerDetailRepository(); | ||
$response = $repository->capacityHardiskMB('2x500GBSATA2'); | ||
|
||
$this->assertEquals('1000000', $response); | ||
|
||
} | ||
|
||
/** | ||
* Test RAM conversion to mb from string input. | ||
* | ||
* @return void | ||
*/ | ||
public function testCapacityRamMB() | ||
{ | ||
$repository = new \App\Repositories\ServerDetailRepository(); | ||
$response = $repository->capacityRamMB('16GBDDR3'); | ||
$this->assertEquals('16000', $response); | ||
|
||
} | ||
} |