-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
538 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains Phagrancy\Http\Response\InternalServerError | ||
*/ | ||
|
||
namespace Phagrancy\Http\Response; | ||
|
||
/** | ||
* HTTP 500/Internal Server Error | ||
* | ||
* @package Phagrancy\Http\Response | ||
*/ | ||
class InternalServerError | ||
extends Json | ||
{ | ||
public function __construct(string $message) | ||
{ | ||
parent::__construct(['error' => 500, 'message' => $message], 500); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Contains Phagrancy\PackerTest | ||
*/ | ||
|
||
namespace packer; | ||
|
||
use Phagrancy\TestCase\Integration; | ||
use Symfony\Component\Process\ExecutableFinder; | ||
use Symfony\Component\Process\Process; | ||
|
||
/** | ||
* Tests against packer itself | ||
*/ | ||
class PackerTest | ||
extends Integration | ||
{ | ||
protected static $bin; | ||
protected static $path; | ||
protected static $process; | ||
protected static $useDockerCompose; | ||
|
||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$bin = (new ExecutableFinder())->find('packer'); | ||
if (empty(self::$bin)) { | ||
self::fail("Missing packer binary"); | ||
} | ||
|
||
self::$useDockerCompose = getenv('PHAGRANCY_TEST_USE_DOCKER_COMPOSE'); | ||
if (self::$useDockerCompose) { | ||
self::$process = Process::fromShellCommandline("docker compose up -d"); | ||
self::$process->setWorkingDirectory(__DIR__); | ||
self::$process->mustRun(); | ||
sleep(5); | ||
} | ||
} | ||
|
||
public static function tearDownAfterClass(): void | ||
{ | ||
if (self::$useDockerCompose) { | ||
$down = Process::fromShellCommandline('docker compose down'); | ||
$down->setWorkingDirectory(__DIR__); | ||
$down->mustRun(); | ||
} | ||
} | ||
|
||
private function runPacker($file) | ||
{ | ||
$build = Process::fromShellCommandline("packer build {$file}.json"); | ||
$build->setWorkingDirectory(__DIR__); | ||
$build->mustRun(); | ||
|
||
$curl = Process::fromShellCommandline('curl -s http://127.0.0.1:8080/test/test'); | ||
$curl->mustRun(); | ||
|
||
$response = json_decode($curl->getOutput()); | ||
|
||
$versions = []; | ||
foreach ($response->versions as $version) { | ||
$versions[] = $version->version; | ||
} | ||
|
||
return $versions; | ||
} | ||
|
||
public function provideVersions() | ||
{ | ||
return [ | ||
['v1', '1.2.3-alpha'], | ||
['v1d', '1.2.3-alpha-direct'], | ||
['v2', '2.0-beta'], | ||
['v2d', '2.0-beta-direct'], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideVersions | ||
*/ | ||
public function testPacker($version, $expectedVersion) | ||
{ | ||
self::assertContains($expectedVersion, $this->runPacker($version)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
services: | ||
app: | ||
image: serversideup/php:8.0-fpm-nginx | ||
container_name: phagrancy-app | ||
ports: | ||
- "8080:8080" | ||
- "8443:8443" | ||
volumes: | ||
- "${PWD}/../../:/var/www/html" | ||
environment: | ||
# serversideup/php | ||
PHP_OPCACHE_ENABLE: 0 | ||
NGINX_WEBROOT: "/var/www/html/web" | ||
# PHAGRANCY | ||
PHAGRANCY_API_TOKEN: "token" | ||
PHAGRANCY_STORAGE_PATH: "/tmp" |
Oops, something went wrong.