-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
fe682a7
commit 1d2b785
Showing
3 changed files
with
97 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\Study; | ||
use Illuminate\Console\Command; | ||
|
||
class UpdateSupervisorUpload extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'gaelo:update-supervisor-upload {studyName : the study name to update}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'update allow supervisor upload for a study'; | ||
|
||
private Study $study; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle(Study $study) | ||
{ | ||
$this->study = $study; | ||
$studyName = $this->argument('studyName'); | ||
$studyEntity = $this->study->findOrFail($studyName); | ||
|
||
if ($this->confirm('Warning : you are about to ' . ($studyEntity->allow_supervisor_upload_dicom ? 'disallow' : 'allow') . ' supervisor upload of dicom, are you sure to continue?')) { | ||
$studyEntity->allow_supervisor_upload_dicom = !$studyEntity->allow_supervisor_upload_dicom; | ||
$studyEntity->save(); | ||
$this->info('Updated'); | ||
} else { | ||
$this->info('Aborted'); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
GaelO2/tests/Feature/TestUpdateSupervisorUploadCommand/TestUpdateSupervisorUploadCommand.php
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,53 @@ | ||
<?php | ||
|
||
namespace Tests\Feature\TestUpdateSupervisorUploadCommand; | ||
|
||
use App\Models\Study; | ||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Tests\TestCase; | ||
|
||
class UpdateSupervisorUploadCommandTest extends TestCase | ||
{ | ||
|
||
use RefreshDatabase; | ||
private Study $study; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->artisan('db:seed'); | ||
$this->study = Study::factory()->create(); | ||
} | ||
|
||
public function testShouldProposeActivateUploadForSupervisor() | ||
{ | ||
$studyName = $this->study->name; | ||
$this->artisan('gaelo:update-supervisor-upload ' . $studyName)->expectsConfirmation('Warning : you are about to allow supervisor upload of dicom, are you sure to continue?', 'yes') | ||
->expectsOutput('Updated'); | ||
$updatedStudy = Study::find($studyName); | ||
$this->assertTrue($updatedStudy->allow_supervisor_upload_dicom); | ||
} | ||
|
||
|
||
public function testShouldProposeDeactivateUploadForSupervisor() | ||
{ | ||
$this->study->allow_supervisor_upload_dicom = true; | ||
$this->study->save(); | ||
$studyName = $this->study->name; | ||
$this->artisan('gaelo:update-supervisor-upload ' . $studyName)->expectsConfirmation('Warning : you are about to disallow supervisor upload of dicom, are you sure to continue?', 'yes') | ||
->expectsOutput('Updated'); | ||
$updatedStudy = Study::find($studyName); | ||
$this->assertFalse($updatedStudy->allow_supervisor_upload_dicom); | ||
} | ||
|
||
public function testShouldAbortIfNoConfirmation() | ||
{ | ||
$this->study->allow_supervisor_upload_dicom = true; | ||
$this->study->save(); | ||
$studyName = $this->study->name; | ||
$this->artisan('gaelo:update-supervisor-upload ' . $studyName)->expectsConfirmation('Warning : you are about to disallow supervisor upload of dicom, are you sure to continue?', 'no') | ||
->expectsOutput('Aborted'); | ||
$updatedStudy = Study::find($studyName); | ||
$this->assertTrue($updatedStudy->allow_supervisor_upload_dicom); | ||
} | ||
} |