Jonathanm10 /
declutter
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Tests\Feature; |
||||
| 4 | |||||
| 5 | use App\Ad; |
||||
| 6 | use App\Platform; |
||||
| 7 | use App\Platforms\Petitesannonces; |
||||
| 8 | use Illuminate\Foundation\Testing\DatabaseTransactions; |
||||
| 9 | use Tests\TestCase; |
||||
| 10 | |||||
| 11 | class PetitesannoncesTest extends TestCase |
||||
| 12 | { |
||||
| 13 | use DatabaseTransactions; |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 14 | |||||
| 15 | public function testImageTooBig() |
||||
| 16 | { |
||||
| 17 | $ad = Ad::create([ |
||||
| 18 | 'title' => 'Testing ads title ' . uniqid(), |
||||
| 19 | 'description' => 'The legal term public domain refers to works whose exclusive intellectual property rights have expired,[1] have been forfeited,[2] have been expressly waived, or are inapplicable.[3] For example, the works of Shakespeare and Beethoven, and most early silent films are in the public ', |
||||
| 20 | 'img_url' => 'https://upload.wikimedia.org/wikipedia/commons/3/3d/LARGE_elevation.jpg', // 14 mo image |
||||
| 21 | 'price' => 34.34, |
||||
| 22 | ]); |
||||
| 23 | |||||
| 24 | $petitesannonces = new Petitesannonces(); |
||||
| 25 | $platform = Platform::find(2); |
||||
| 26 | |||||
| 27 | try { |
||||
| 28 | $petitesannonces->publish($ad, $platform); |
||||
|
0 ignored issues
–
show
$platform of type Illuminate\Database\Eloquent\Builder is incompatible with the type App\Platform expected by parameter $platform of App\Platforms\Petitesannonces::publish().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 29 | $this->fail('Exception should have been raised'); |
||||
| 30 | } catch (\Exception $e) { |
||||
| 31 | $this->assertEquals("La taille de l'image ne doit pas excéder 8 Mo", $e->getMessage()); |
||||
| 32 | } |
||||
| 33 | } |
||||
| 34 | |||||
| 35 | public function testDescriptionTooShort() |
||||
| 36 | { |
||||
| 37 | $ad = Ad::create([ |
||||
| 38 | 'title' => 'Testing ads title ' . uniqid(), |
||||
| 39 | 'description' => 'The legal term public domain refers to works whose exclusive intellectual property', |
||||
| 40 | 'img_url' => 'https://upload.wikimedia.org/wikipedia/commons/e/e4/Small-city-symbol.svg', |
||||
| 41 | 'price' => 34.34, |
||||
| 42 | ]); |
||||
| 43 | |||||
| 44 | $petitesannonces = new Petitesannonces(); |
||||
| 45 | $platform = Platform::find(2); |
||||
| 46 | |||||
| 47 | try { |
||||
| 48 | $petitesannonces->publish($ad, $platform); |
||||
|
0 ignored issues
–
show
$platform of type Illuminate\Database\Eloquent\Builder is incompatible with the type App\Platform expected by parameter $platform of App\Platforms\Petitesannonces::publish().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 49 | $this->fail('Exception should have been raised'); |
||||
| 50 | } catch (\Exception $e) { |
||||
| 51 | $this->assertEquals( |
||||
| 52 | "La description doit contenir au moins 20 mots différents de plus de deux lettres. Ce texte contient 11 mots.", |
||||
| 53 | $e->getMessage() |
||||
| 54 | ); |
||||
| 55 | } |
||||
| 56 | } |
||||
| 57 | |||||
| 58 | public function testTitleTooShort() |
||||
| 59 | { |
||||
| 60 | $ad = Ad::create([ |
||||
| 61 | 'title' => 'Testing ad ' . uniqid(), |
||||
| 62 | 'description' => 'The legal term public domain refers to works whose exclusive intellectual property rights have expired,[1] have been forfeited,[2] have been expressly waived, or are inapplicable.[3] For example, the works of Shakespeare and Beethoven, and most early silent films are in the public ', |
||||
| 63 | 'img_url' => 'https://upload.wikimedia.org/wikipedia/commons/e/e4/Small-city-symbol.svg', |
||||
| 64 | 'price' => 34.34, |
||||
| 65 | ]); |
||||
| 66 | |||||
| 67 | $petitesannonces = new Petitesannonces(); |
||||
| 68 | $platform = Platform::find(2); |
||||
| 69 | |||||
| 70 | try { |
||||
| 71 | $petitesannonces->publish($ad, $platform); |
||||
|
0 ignored issues
–
show
$platform of type Illuminate\Database\Eloquent\Builder is incompatible with the type App\Platform expected by parameter $platform of App\Platforms\Petitesannonces::publish().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 72 | $this->fail('Exception should have been raised'); |
||||
| 73 | } catch (\Exception $e) { |
||||
| 74 | $this->assertEquals( |
||||
| 75 | "Le titre doit contenir au moins 3 mots différents de plus de deux lettres. Ce texte contient 2 mots.", |
||||
| 76 | $e->getMessage() |
||||
| 77 | ); |
||||
| 78 | } |
||||
| 79 | } |
||||
| 80 | } |
||||
| 81 |