-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix wiring of object manager. Move maps asset path to env var. Write …
…first integration test. Add phpunit.xml.dist so tests can execute.
- Loading branch information
1 parent
099aed3
commit dd40988
Showing
12 changed files
with
123 additions
and
69 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
doctrine_migrations: | ||
dir_name: '%kernel.project_dir%/src/Migrations' | ||
dir_name: '%kernel.project_dir%/Migrations' | ||
# namespace is arbitrary but should be different from App\Migrations | ||
# as migrations classes should NOT be autoloaded | ||
namespace: DoctrineMigrations |
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,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.5/phpunit.xsd" | ||
bootstrap="tests_unit/autoload.php" | ||
forceCoversAnnotation="true" | ||
beStrictAboutCoversAnnotation="true" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
defaultTestSuite="unit" | ||
verbose="true"> | ||
<testsuite name="unit"> | ||
<directory suffix="Test.php">tests_unit</directory> | ||
</testsuite> | ||
<testsuite name="integration"> | ||
<directory suffix="Test.php">tests_integration</directory> | ||
</testsuite> | ||
|
||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">src</directory> | ||
</whitelist> | ||
</filter> | ||
|
||
<php> | ||
<ini name="error_reporting" value="-1" /> | ||
<env name="KERNEL_CLASS" value="App\Kernel" /> | ||
<env name="APP_ENV" value="test" /> | ||
<env name="APP_DEBUG" value="1" /> | ||
<env name="SHELL_VERBOSITY" value="-1" /> | ||
</php> | ||
</phpunit> |
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,32 @@ | ||
<?php | ||
namespace App\IntegrationTests\Api\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
|
||
class LobbyControllerTest extends WebTestCase | ||
{ | ||
public function testGameCreation() | ||
{ | ||
$client = self::createClient(); | ||
|
||
$client->request("POST", "/game"); | ||
|
||
$gameData = json_decode($client->getResponse()->getContent(), true); | ||
|
||
$this->assertArrayIsValidGame($gameData); | ||
} | ||
|
||
private function assertArrayIsValidGame(array $gameData): void | ||
{ | ||
$this->assertArrayHasKey("id", $gameData); | ||
$this->assertArrayHasKey("playerNumber", $gameData); | ||
$this->assertArrayHasKey("turnNumber", $gameData); | ||
$this->assertArrayHasKey("map", $gameData); | ||
$this->assertArrayHasKey("tiles", $gameData["map"] ?? []); | ||
$this->assertArrayHasKey("width", $gameData["map"] ?? []); | ||
$this->assertGreaterThanOrEqual($gameData["map"]["width"] ?? PHP_INT_MAX, count($gameData["map"]["tiles"] ?? [])); | ||
$this->assertArrayHasKey(0, $gameData["map"]["tiles"] ?? []); | ||
$this->assertArrayHasKey("type", $gameData["map"]["tiles"][0] ?? []); | ||
$this->assertArrayHasKey("owner", $gameData["map"]["tiles"][0] ?? []); | ||
} | ||
} |
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,12 @@ | ||
<?php | ||
|
||
use Symfony\Component\Dotenv\Dotenv; | ||
|
||
require __DIR__.'/../vendor/autoload.php'; | ||
|
||
if (!isset($_SERVER['APP_ENV'])) { | ||
if (!class_exists(Dotenv::class)) { | ||
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.'); | ||
} | ||
(new Dotenv())->load(__DIR__.'/../.env'); | ||
} |