Skip to content

Commit

Permalink
Fix tests - double chargement de la config
Browse files Browse the repository at this point in the history
  • Loading branch information
AnaelMobilia committed Dec 8, 2024
1 parent 9c13d4c commit a42f472
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions __tests/DisplayPicsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ class DisplayPicsTest extends TestCase
#[RunInSeparateProcess]
public function testImageInexistante(): void
{
require 'config/config.php';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['REQUEST_URI'] = 'files/fichierInexistant.jpg';

ob_start();
require 'displayPics.php';
ob_end_clean();

/* @var $monObjet RessourceObject */
$this->assertEquals(
_IMAGE_404_,
Expand All @@ -52,11 +55,14 @@ public function testImageInexistante(): void
#[RunInSeparateProcess]
public function testMiniatureInexistante(): void
{
require 'config/config.php';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['REQUEST_URI'] = 'files/thumbs/fichierInexistant.jpg';

ob_start();
require 'displayPics.php';
ob_end_clean();

/* @var $monObjet RessourceObject */
$this->assertEquals(
_IMAGE_404_,
Expand All @@ -71,11 +77,14 @@ public function testMiniatureInexistante(): void
#[RunInSeparateProcess]
public function testRepertoireInexistant(): void
{
require 'config/config.php';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['REQUEST_URI'] = 'files/repertoireInexistant/fichierInexistant.jpg';

ob_start();
require 'displayPics.php';
ob_end_clean();

/* @var $monObjet RessourceObject */
$this->assertEquals(
_IMAGE_404_,
Expand All @@ -90,8 +99,10 @@ public function testRepertoireInexistant(): void
#[RunInSeparateProcess]
public function testImageBloquee(): void
{
require 'config/config.php';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['REQUEST_URI'] = 'files/image_10.png';

ob_start();
require 'displayPics.php';
ob_end_clean();
Expand All @@ -110,11 +121,14 @@ public function testImageBloquee(): void
#[RunInSeparateProcess]
public function testImageSignalee(): void
{
require 'config/config.php';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['REQUEST_URI'] = 'files/image_18.png';

ob_start();
require 'displayPics.php';
ob_end_clean();

/* @var $monObjet RessourceObject */
$this->assertEquals(
_IMAGE_BAN_,
Expand Down
4 changes: 3 additions & 1 deletion displayPics.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
/*
* Affichage d'une image & mise à jour des stats
*/
require 'config/config.php';
if (!defined('_PHPUNIT_')) {
require 'config/config.php';
}

// URL demandée
$url = $_SERVER['REQUEST_URI'];
Expand Down

0 comments on commit a42f472

Please sign in to comment.