Skip to content

Commit

Permalink
Corrige les chemins incompatibles avec Windows dans les tests
Browse files Browse the repository at this point in the history
  • Loading branch information
polosson committed Apr 22, 2021
1 parent 9130ecf commit 98e27f6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions server/src/App/Services/Auth/JWT.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function logout(): bool

private function fetchToken(Request $request): string
{
// - Tente de récupèrer le token dans les headers HTTP.
// - Tente de récupérer le token dans les headers HTTP.
$headerName = $this->settings['httpAuthHeader'];
$header = $request->getHeaderLine(sprintf('HTTP_%s', strtoupper(snake_case($headerName))));
if (!empty($header)) {
Expand All @@ -58,15 +58,15 @@ private function fetchToken(Request $request): string
}

if (!Auth::isApiRequest($request)) {
// - Sinon tente de récupèrer le token dans les cookies.
// - Sinon tente de récupérer le token dans les cookies.
$cookieName = $this->settings['auth']['cookie'];
$cookieParams = $request->getCookieParams();
if (isset($cookieParams[$cookieName])) {
if (preg_match('/Bearer\s+(.*)$/i', $cookieParams[$cookieName], $matches)) {
return $matches[1];
}
return $cookieParams[$cookieName];
};
}
}

throw new \RuntimeException("Token introuvable.");
Expand Down
10 changes: 6 additions & 4 deletions server/tests/Fixtures/RobertFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

class RobertFixtures
{
const DUMP_DIR = __DIR__ . '/tmp/';
const DATA_DUMP_FILE = __DIR__ . '/tmp/data.sql';
const SCHEMA_DUMP_FILE = __DIR__ . '/tmp/schema.sql';
const DUMP_DIR = __DIR__ . DS . 'tmp' . DS;
const DATA_DUMP_FILE = __DIR__ . DS . 'tmp' . DS . 'data.sql';
const SCHEMA_DUMP_FILE = __DIR__ . DS . 'tmp' . DS . 'schema.sql';

public static function getConnection(): \PDO
{
Expand Down Expand Up @@ -50,7 +50,9 @@ public static function runMigrations(): void
echo "Running migrations for tests...\n";

$output = [];
exec('src/vendor/bin/phinx --configuration=src/database/phinx.php --environment=test migrate', $output);
$phinxPath = 'src' . DS . 'vendor' . DS . 'bin' . DS . 'phinx';
$configPath = 'src' . DS . 'database' . DS . 'phinx.php';
exec($phinxPath . ' --configuration=' . $configPath . ' --environment=test migrate', $output);

echo implode("\n", $output) . "\n\n";
}
Expand Down
4 changes: 2 additions & 2 deletions server/tests/models/DocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testGetFilePathAttribute()
{
$document = $this->model::find(1);
$this->assertEquals(
DATA_FOLDER . '/materials/1/User-manual.pdf',
DATA_FOLDER . DS . 'materials'. DS .'1'. DS .'User-manual.pdf',
$document->file_path
);
}
Expand Down Expand Up @@ -90,7 +90,7 @@ public function testGetFilePath()
{
$result = $this->model::getFilePath(1, 'file.pdf');
$this->assertEquals(
DATA_FOLDER . '/materials/1/file.pdf',
DATA_FOLDER . DS . 'materials' . DS . '1' . DS . 'file.pdf',
$result
);
}
Expand Down

0 comments on commit 98e27f6

Please sign in to comment.