Integration Baniere dans le backend
This commit is contained in:
@@ -59,6 +59,14 @@ class AdminImagesTest extends TestCase
|
||||
$this->actingAs($editor)->get('/admin/images')->assertOk()->assertSee('logo-cabm-2.png');
|
||||
}
|
||||
|
||||
public function test_extension_deduite_du_contenu_et_non_du_nom_envoye(): void
|
||||
{
|
||||
$this->actingAs($this->user('editor'))->post('/admin/images', ['image' => $this->png('photo.gif')])->assertSessionHasNoErrors();
|
||||
|
||||
$this->assertFileExists($this->dir.'/photo.png');
|
||||
$this->assertFileDoesNotExist($this->dir.'/photo.gif');
|
||||
}
|
||||
|
||||
public function test_refuse_un_faux_png_et_le_svg(): void
|
||||
{
|
||||
$tmp = tempnam(sys_get_temp_dir(), 'x');
|
||||
@@ -85,4 +93,23 @@ class AdminImagesTest extends TestCase
|
||||
$this->actingAs($admin)->delete('/admin/images/logo.png')->assertSessionHasNoErrors();
|
||||
$this->assertFileDoesNotExist($this->dir.'/logo.png');
|
||||
}
|
||||
|
||||
public function test_image_utilisee_par_une_campagne_ou_une_autre_collectivite_non_supprimable(): void
|
||||
{
|
||||
file_put_contents($this->dir.'/banniere.png', base64_decode(self::PNG));
|
||||
$admin = $this->user('admin');
|
||||
$other = Tenant::create(['name' => 'Commune', 'entra_tenant_id' => '99999999-9999-9999-9999-999999999999']);
|
||||
$campaign = \App\Models\Campaign::create(['tenant_id' => $other->id, 'name' => 'Ailleurs', 'image_path' => 'banniere.png',
|
||||
'alt_text' => 'x', 'starts_at' => now(), 'ends_at' => now()->addDay()]);
|
||||
|
||||
$this->actingAs($admin)->delete('/admin/images/banniere.png')->assertSessionHasErrors('image');
|
||||
$this->assertFileExists($this->dir.'/banniere.png');
|
||||
|
||||
$campaign->update(['tenant_id' => $this->tenant->id]);
|
||||
$this->actingAs($admin)->delete('/admin/images/banniere.png')->assertSessionHasErrors('image');
|
||||
|
||||
$campaign->delete();
|
||||
$this->actingAs($admin)->delete('/admin/images/banniere.png')->assertSessionHasNoErrors();
|
||||
$this->assertFileDoesNotExist($this->dir.'/banniere.png');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user