Skip to content

Commit

Permalink
#92 [FIX] problem test unit for FastRouteCore
Browse files Browse the repository at this point in the history
  • Loading branch information
bfoujols committed May 14, 2024
1 parent e204088 commit c838be0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ APP_NAME=edu-framework
## >> Config préfixe des conteneurs Docker

## << Config application
APP_ENV=dev
## pour activer le mode dev, il faut mettre APP_ENV=dev
APP_ENV=prod
## >> Config application
16 changes: 9 additions & 7 deletions tests/Controller/FastRouteCoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Controller;

use Dotenv\Dotenv;
use PHPUnit\Framework\TestCase;
use Studoo\EduFramework\Core\ConfigCore;
use Studoo\EduFramework\Core\Controller\FastRouteCore;
Expand All @@ -15,6 +16,7 @@ public function setUp(): void
(new ConfigCore([
'twig_path' => __DIR__ . '/../../app/Template'
]));

TwigCore::setEnvironment();
$en = TwigCore::getEnvironment();
}
Expand All @@ -26,7 +28,7 @@ public function testGetDispatcher()

$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/';
$this->assertEquals('df50808e9806dd3e0cceed154c35303d92a90ad6', sha1($route->getRoute()));
$this->assertEquals('d7045e6af8910d38af6c42f0b610e51c644e5ec1', sha1($route->getRoute()));
}

public function testGetDispatcherWithExceptionNotFound()
Expand All @@ -36,7 +38,7 @@ public function testGetDispatcherWithExceptionNotFound()

$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/test';
$this->assertEquals('2280909eada820cab67a82fbdf5dfeba4024aa13', sha1($route->getRoute()));
$this->assertEquals('1ab50275de77fa6215e882b0833350c32cfcd7a2', sha1($route->getRoute()));
}

public function testGetDispatcherWithExceptionMethodNotAllowed()
Expand All @@ -46,7 +48,7 @@ public function testGetDispatcherWithExceptionMethodNotAllowed()

$_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REQUEST_URI'] = '/';
$this->assertEquals('ca8755da6c4454c8d769b2eeaedcb6ef689b583c', sha1($route->getRoute()));
$this->assertEquals('ed2ad24f02864b53319ab611d414ceac5c322751', sha1($route->getRoute()));
}

public function testGetDispatcherWithExceptionMethodNotAllowedAndNotFound()
Expand All @@ -56,7 +58,7 @@ public function testGetDispatcherWithExceptionMethodNotAllowedAndNotFound()

$_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REQUEST_URI'] = '/test';
$this->assertEquals('ca9cc12e0274e65bdda697a8b662f0713c5a3650', sha1($route->getRoute()));
$this->assertEquals('1ab50275de77fa6215e882b0833350c32cfcd7a2', sha1($route->getRoute()));
}

public function testLoadRoutesMatchSuccess()
Expand All @@ -66,7 +68,7 @@ public function testLoadRoutesMatchSuccess()

$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/';
$this->assertEquals('df50808e9806dd3e0cceed154c35303d92a90ad6', sha1($route->getRoute()));
$this->assertEquals('d7045e6af8910d38af6c42f0b610e51c644e5ec1', sha1($route->getRoute()));
}

public function testLoadRoutesMatchSuccessWithExceptionNotFound()
Expand All @@ -76,7 +78,7 @@ public function testLoadRoutesMatchSuccessWithExceptionNotFound()

$_SERVER['REQUEST_METHOD'] = 'GET';
$_SERVER['REQUEST_URI'] = '/test';
$this->assertEquals('2280909eada820cab67a82fbdf5dfeba4024aa13', sha1($route->getRoute()));
$this->assertEquals('1ab50275de77fa6215e882b0833350c32cfcd7a2', sha1($route->getRoute()));
}

public function testLoadRoutesMatchSuccessWithExceptionMethodNotAllowedAndNotFound()
Expand All @@ -86,6 +88,6 @@ public function testLoadRoutesMatchSuccessWithExceptionMethodNotAllowedAndNotFou

$_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REQUEST_URI'] = '/';
$this->assertEquals('ca8755da6c4454c8d769b2eeaedcb6ef689b583c', sha1($route->getRoute()));
$this->assertEquals('ed2ad24f02864b53319ab611d414ceac5c322751', sha1($route->getRoute()));
}
}

0 comments on commit c838be0

Please sign in to comment.