Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Pull Request — fix-uploaders (#5518)
by Cristian
25:53 queued 10:55
created

UploadersConfigurationTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 25
c 1
b 0
f 1
dl 0
loc 51
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A defineRoutes() 0 3 1
A test_it_can_access_the_uploaders_create_page() 0 4 1
A setUp() 0 6 1
A test_it_can_store_uploaded_files_using_our_file_name_generator() 0 27 2
1
<?php
2
3
namespace Backpack\CRUD\Tests\Feature;
4
5
use Backpack\CRUD\Tests\config\CrudPanel\BaseDBCrudPanel;
6
use Backpack\CRUD\Tests\config\HasUploadedFiles;
7
use Backpack\CRUD\Tests\config\Http\Controllers\UploaderConfigurationCrudController;
8
use Backpack\CRUD\Tests\config\Models\Uploader;
9
use Backpack\CRUD\Tests\config\Models\User;
10
use Illuminate\Support\Facades\Storage;
11
12
/**
13
 * @covers Backpack\CRUD\app\Library\Uploaders\Uploader
14
 * @covers Backpack\CRUD\app\Library\Uploaders\SingleFile
15
 * @covers Backpack\CRUD\app\Library\Uploaders\MultipleFiles
16
 * @covers Backpack\CRUD\app\Library\Uploaders\Support\RegisterUploadEvents
17
 * @covers Backpack\CRUD\app\Library\Uploaders\Support\UploadersRepository
18
 * @covers Backpack\CRUD\app\Library\Uploaders\Support\FileNameGenerator
19
 */
20
class UploadersConfigurationTest extends BaseDBCrudPanel
21
{
22
    use HasUploadedFiles;
23
    protected string $testBaseUrl;
24
25
    protected function defineRoutes($router)
26
    {
27
        $router->crud(config('backpack.base.route_prefix').'/uploader-configuration', UploaderConfigurationCrudController::class);
28
    }
29
30
    protected function setUp(): void
31
    {
32
        parent::setUp();
33
        $this->testBaseUrl = config('backpack.base.route_prefix').'/uploader-configuration';
34
        Storage::fake('uploaders');
35
        $this->actingAs(User::find(1));
36
    }
37
38
    public function test_it_can_access_the_uploaders_create_page()
39
    {
40
        $response = $this->get($this->testBaseUrl.'/create');
41
        $response->assertStatus(200);
42
    }
43
44
    public function test_it_can_store_uploaded_files_using_our_file_name_generator()
45
    {
46
        $response = $this->post($this->testBaseUrl, [
47
            'upload' => $this->getUploadedFile('avatar1.jpg'),
48
            'upload_multiple' => $this->getUploadedFiles(['avatar2.jpg', 'avatar3.jpg']),
49
        ]);
50
51
        $response->assertStatus(302);
52
53
        $response->assertRedirect($this->testBaseUrl);
54
55
        $this->assertDatabaseCount('uploaders', 1);
56
57
        $files = Storage::disk('uploaders')->allFiles();
58
59
        $this->assertEquals(3, count($files));
60
61
        foreach ($files as $file) {
62
            $this->assertMatchesRegularExpression('/avatar\d{1}-[a-zA-Z0-9]{4}\.jpg/', $file);
63
        }
64
65
        // get the entry from database and also make sure the file names are stored correctly
66
        $entry = Uploader::first();
67
        $this->assertNotNull($entry);
68
        $this->assertMatchesRegularExpression('/avatar\d{1}-[a-zA-Z0-9]{4}\.jpg/', $entry->upload);
0 ignored issues
show
Bug introduced by
The property upload does not seem to exist on Illuminate\Database\Eloq...gHasThroughRelationship.
Loading history...
69
        $this->assertMatchesRegularExpression('/avatar\d{1}-[a-zA-Z0-9]{4}\.jpg/', $entry->upload_multiple[0]);
0 ignored issues
show
Bug introduced by
The property upload_multiple does not seem to exist on Illuminate\Database\Eloq...gHasThroughRelationship.
Loading history...
70
        $this->assertMatchesRegularExpression('/avatar\d{1}-[a-zA-Z0-9]{4}\.jpg/', $entry->upload_multiple[1]);
71
    }
72
}
73