@@ -29,12 +29,12 @@ |
||
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | - * Password mulator |
|
| 33 | - * |
|
| 34 | - * Encrypt password while storing. |
|
| 35 | - * @param $value |
|
| 36 | - * @return void |
|
| 37 | - */ |
|
| 32 | + * Password mulator |
|
| 33 | + * |
|
| 34 | + * Encrypt password while storing. |
|
| 35 | + * @param $value |
|
| 36 | + * @return void |
|
| 37 | + */ |
|
| 38 | 38 | public function setPasswordAttribute($value) |
| 39 | 39 | { |
| 40 | 40 | $this->attributes['password'] = bcrypt( $value ); |
@@ -16,102 +16,102 @@ |
||
| 16 | 16 | |
| 17 | 17 | class ExportTest extends TestCase |
| 18 | 18 | { |
| 19 | - use RefreshDatabase; |
|
| 19 | + use RefreshDatabase; |
|
| 20 | 20 | |
| 21 | - protected $export; |
|
| 21 | + protected $export; |
|
| 22 | 22 | |
| 23 | - protected function getPackageProviders($app) |
|
| 24 | - { |
|
| 25 | - return ['Ladybirdweb\ImportExport\ImportExportServiceProvider']; |
|
| 26 | - } |
|
| 23 | + protected function getPackageProviders($app) |
|
| 24 | + { |
|
| 25 | + return ['Ladybirdweb\ImportExport\ImportExportServiceProvider']; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | 28 | protected function getEnvironmentSetUp($app) |
| 29 | 29 | { |
| 30 | 30 | $app['config']->set('database.default', 'testing'); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - protected function setUp () |
|
| 34 | - { |
|
| 35 | - parent::setUp(); |
|
| 33 | + protected function setUp () |
|
| 34 | + { |
|
| 35 | + parent::setUp(); |
|
| 36 | 36 | |
| 37 | - $this->artisan('migrate', ['--database' => 'testing']); |
|
| 37 | + $this->artisan('migrate', ['--database' => 'testing']); |
|
| 38 | 38 | |
| 39 | - Route::middleware('web')->group(function() { |
|
| 39 | + Route::middleware('web')->group(function() { |
|
| 40 | 40 | |
| 41 | - Route::get('/ticket/export/{id}', [ 'as' => 'ticket.export.progress', 'uses' => 'Ladybirdweb\ImportExport\Export@showExportStatus']); |
|
| 41 | + Route::get('/ticket/export/{id}', [ 'as' => 'ticket.export.progress', 'uses' => 'Ladybirdweb\ImportExport\Export@showExportStatus']); |
|
| 42 | 42 | |
| 43 | - Route::get( '/export/{id}/download', [ 'as' => 'ladybirdweb.export.download', 'uses' => 'Ladybirdweb\ImportExport\Export@downloadExportedFile']); |
|
| 43 | + Route::get( '/export/{id}/download', [ 'as' => 'ladybirdweb.export.download', 'uses' => 'Ladybirdweb\ImportExport\Export@downloadExportedFile']); |
|
| 44 | 44 | |
| 45 | - }); |
|
| 45 | + }); |
|
| 46 | 46 | |
| 47 | - Storage::putFileAs('exports', new File( __DIR__ . '/storage/test/test.csv' ), 'test.xls'); |
|
| 47 | + Storage::putFileAs('exports', new File( __DIR__ . '/storage/test/test.csv' ), 'test.xls'); |
|
| 48 | 48 | |
| 49 | - $this->export = ModelExport::create([ |
|
| 50 | - 'file' => 'test.xls', |
|
| 51 | - 'query' => User::select([ 'name', 'email', 'created_at' ])->getModel(), |
|
| 52 | - 'type' => 'xls' |
|
| 53 | - ]); |
|
| 54 | - } |
|
| 49 | + $this->export = ModelExport::create([ |
|
| 50 | + 'file' => 'test.xls', |
|
| 51 | + 'query' => User::select([ 'name', 'email', 'created_at' ])->getModel(), |
|
| 52 | + 'type' => 'xls' |
|
| 53 | + ]); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * @test |
|
| 58 | - */ |
|
| 59 | - public function data_export_initiated_and_dispatched() |
|
| 60 | - { |
|
| 61 | - Queue::fake(); |
|
| 56 | + /** |
|
| 57 | + * @test |
|
| 58 | + */ |
|
| 59 | + public function data_export_initiated_and_dispatched() |
|
| 60 | + { |
|
| 61 | + Queue::fake(); |
|
| 62 | 62 | |
| 63 | - $export = Export::export( User::select([ 'name', 'email', 'created_at' ]), 'xls' ); |
|
| 63 | + $export = Export::export( User::select([ 'name', 'email', 'created_at' ]), 'xls' ); |
|
| 64 | 64 | |
| 65 | - $this->assertInstanceOf( ModelExport::class, $export ); |
|
| 65 | + $this->assertInstanceOf( ModelExport::class, $export ); |
|
| 66 | 66 | |
| 67 | - Queue::assertPushedOn('exporting', ExportJob::class); |
|
| 68 | - } |
|
| 67 | + Queue::assertPushedOn('exporting', ExportJob::class); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * @test |
|
| 72 | - */ |
|
| 73 | - public function see_export_progress_page() |
|
| 74 | - { |
|
| 75 | - $response = $this->get('/ticket/export/' . $this->export->id); |
|
| 70 | + /** |
|
| 71 | + * @test |
|
| 72 | + */ |
|
| 73 | + public function see_export_progress_page() |
|
| 74 | + { |
|
| 75 | + $response = $this->get('/ticket/export/' . $this->export->id); |
|
| 76 | 76 | |
| 77 | - $response->assertStatus(200); |
|
| 77 | + $response->assertStatus(200); |
|
| 78 | 78 | |
| 79 | - $response->assertSee('Export'); |
|
| 80 | - } |
|
| 79 | + $response->assertSee('Export'); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * @test |
|
| 84 | - */ |
|
| 85 | - public function check_export_progress_ajax() |
|
| 86 | - { |
|
| 87 | - $response = $this->json( 'GET', '/export/' . $this->export->id . '/progress'); |
|
| 82 | + /** |
|
| 83 | + * @test |
|
| 84 | + */ |
|
| 85 | + public function check_export_progress_ajax() |
|
| 86 | + { |
|
| 87 | + $response = $this->json( 'GET', '/export/' . $this->export->id . '/progress'); |
|
| 88 | 88 | |
| 89 | - $response->assertStatus(200); |
|
| 89 | + $response->assertStatus(200); |
|
| 90 | 90 | |
| 91 | - $response->assertJsonFragment( ['status' => 200] ); |
|
| 91 | + $response->assertJsonFragment( ['status' => 200] ); |
|
| 92 | 92 | |
| 93 | - $response->assertJsonFragment( ['progress'] ); |
|
| 94 | - } |
|
| 93 | + $response->assertJsonFragment( ['progress'] ); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * @test |
|
| 98 | - */ |
|
| 99 | - public function try_download_exported_file() |
|
| 100 | - { |
|
| 101 | - $response = $this->get('/export/' . $this->export->id . '/download'); |
|
| 96 | + /** |
|
| 97 | + * @test |
|
| 98 | + */ |
|
| 99 | + public function try_download_exported_file() |
|
| 100 | + { |
|
| 101 | + $response = $this->get('/export/' . $this->export->id . '/download'); |
|
| 102 | 102 | |
| 103 | - $response->assertHeader( 'content-disposition', 'attachment; filename="test.xls"'); |
|
| 103 | + $response->assertHeader( 'content-disposition', 'attachment; filename="test.xls"'); |
|
| 104 | 104 | |
| 105 | - $response->assertStatus(200); |
|
| 106 | - } |
|
| 105 | + $response->assertStatus(200); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * @test |
|
| 110 | - */ |
|
| 111 | - public function fail_download_exported_file() |
|
| 112 | - { |
|
| 113 | - $response = $this->get('/export/987654321/download'); |
|
| 108 | + /** |
|
| 109 | + * @test |
|
| 110 | + */ |
|
| 111 | + public function fail_download_exported_file() |
|
| 112 | + { |
|
| 113 | + $response = $this->get('/export/987654321/download'); |
|
| 114 | 114 | |
| 115 | - $response->assertStatus(404); |
|
| 116 | - } |
|
| 115 | + $response->assertStatus(404); |
|
| 116 | + } |
|
| 117 | 117 | } |