GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AdTest::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 3
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace Tests\Browser;
4
5
use App\Ad;
6
use Tests\DuskTestCase;
7
use Laravel\Dusk\Browser;
8
9
class AdTest extends DuskTestCase
10
{
11
    protected $uniqueId;
12
    protected $testingValues;
13
14
    public function __construct(?string $name = null, array $data = [], string $dataName = '')
15
    {
16
        parent::__construct($name, $data, $dataName);
17
        $this->uniqueId = uniqid();
18
        $this->testingValues = [
19
            'title' => 'Testing title ' . $this->uniqueId,
20
            'description' => 'Testing description',
21
            'img_url' => 'https://www.testingurl.com/testingimage.jpg',
22
            'price' => 35.45,
23
        ];
24
    }
25
26
    /**
27
     * @return void
28
     * @throws \Throwable
29
     */
30
    public function testAddNewAd()
31
    {
32
        $this->browse(function (Browser $browser) {
33
            $browser->visit('/ads')
34
                ->clickLink('Ajouter')
35
                ->type('title', 'Testing title ' . $this->uniqueId)
36
                ->type('description', 'Testing description')
37
                ->type('img_url', 'https://www.testingurl.com')
38
                ->type('price', 35.45)
39
                ->press('Ajouter')
40
                ->assertSee('Testing title ' . $this->uniqueId);
41
        });
42
43
        if ($ad = Ad::whereTitle('Testing title ' . $this->uniqueId)->first()) {
44
            $ad->delete();
45
        }
46
    }
47
48
    /**
49
     * @return void
50
     * @throws \Throwable
51
     */
52
    public function testSuccessfulEditAd()
53
    {
54
        $ad = Ad::create($this->testingValues);
55
56
        $this->browse(function (Browser $browser) use ($ad) {
57
            $browser->visit('/ads/' . $ad->id)
58
                ->type('price', 343.34)
59
                ->press('Éditer')
60
                ->assertSee('343.34');
61
        });
62
63
        if ($ad = Ad::whereTitle('Testing title ' . $this->uniqueId)->first()) {
64
            $ad->delete();
65
        }
66
    }
67
68
    /**
69
     * @return void
70
     * @throws \Throwable
71
     */
72
    public function testUnsuccessfulEditAd()
73
    {
74
        $ad = Ad::create($this->testingValues);
75
76
        $this->browse(function (Browser $browser) use ($ad) {
77
            $browser->visit('/ads/' . $ad->id)
78
                ->type('price', 'abc')
79
                ->press('Éditer')
80
                ->assertSee('Le champ price doit contenir un nombre');
81
        });
82
83
        if ($ad = Ad::whereTitle('Testing title ' . $this->uniqueId)->first()) {
84
            $ad->delete();
85
        }
86
    }
87
88
    /**
89
     * @return void
90
     * @throws \Throwable
91
     */
92
    public function testDeleteAd()
93
    {
94
        $ad = Ad::create($this->testingValues);
95
96
        $this->browse(function (Browser $browser) use ($ad) {
97
            $browser->visit('/ads/' . $ad->id . '/delete')
98
                ->assertDontSee('Testing title ' . $this->uniqueId);
99
        });
100
101
        if ($ad = Ad::whereTitle('Testing title ' . $this->uniqueId)->first()) {
102
            $ad->delete();
103
        }
104
    }
105
}
106