-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from Tjoosten/dotenv
DotEnv for better configuration
- Loading branch information
Showing
11 changed files
with
179 additions
and
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
--- Database credentials | ||
--- | ||
apiHost=localhost | ||
apiUser=irail | ||
apiTable=apilog | ||
apiPassword=passwd | ||
apiDatabase=irail | ||
|
||
--- | ||
--- Database columns | ||
--- | ||
|
||
column1=id | ||
column2=time | ||
column3=useragent | ||
column4=fromstation | ||
column5=tostation | ||
column6=errors | ||
column7=ip | ||
column8=server | ||
|
||
--- | ||
--- API servername | ||
--- | ||
|
||
// API server name | ||
apiServerName=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 |
---|---|---|
|
@@ -7,3 +7,4 @@ api/push.php | |
.vagrant | ||
.idea/ | ||
/vendor/ | ||
.env |
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
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,14 +1,22 @@ | ||
{ | ||
"name": "irail/irail", | ||
"description": "The iRail API", | ||
"license": "AGPLv3", | ||
"authors": [ | ||
{ | ||
"name": "Pieter Colpaert", | ||
"email": "pieter.colpaert@okfn.org" | ||
} | ||
], | ||
"require": { | ||
|
||
"name": "irail/irail", | ||
"description": "The iRail API", | ||
"license": "AGPLv3", | ||
"authors": [ | ||
{ | ||
"name": "Pieter Colpaert", | ||
"email": "pieter.colpaert@okfn.org" | ||
} | ||
} | ||
], | ||
"require": { | ||
"vlucas/phpdotenv": "^2.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "4.7.*" | ||
}, | ||
"scripts": { | ||
"post-install-cmd": [ | ||
"php -r \"copy('.env.example', '.env');\"" | ||
] | ||
} | ||
} |
This file was deleted.
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="./tests/bootstrap.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnError="false" | ||
stopOnFailure="false" | ||
syntaxCheck="true" | ||
strict="true" | ||
verbose="true" | ||
> | ||
<testsuites> | ||
<testsuite name="PHP Dotenv Test Suite"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">./src</directory> | ||
</whitelist> | ||
</filter> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
error_reporting(-1); | ||
date_default_timezone_set('UTC'); | ||
/* | ||
* Path trickery ensures test suite will always run, standalone or within | ||
* another composer package. Designed to find composer autoloader and require | ||
*/ | ||
$vendorPos = strpos(__DIR__, 'vendor/vlucas/phpdotenv'); | ||
if ($vendorPos !== false) { | ||
// Package has been cloned within another composer package, resolve path to autoloader | ||
$vendorDir = substr(__DIR__, 0, $vendorPos).'vendor/'; | ||
$loader = require $vendorDir.'autoload.php'; | ||
} else { | ||
// Package itself (cloned standalone) | ||
$loader = require __DIR__.'/../vendor/autoload.php'; | ||
} |
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,29 @@ | ||
<?php | ||
use Dotenv\Dotenv; | ||
class configurationTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testDotEnvVars() | ||
{ | ||
$dotenv = new Dotenv(dirname(__DIR__)); | ||
$dotenv->load(); | ||
|
||
// API Database credentials | ||
$this->assertEquals($_ENV['apiHost'], 'localhost'); | ||
$this->assertEquals($_ENV['apiUser'], 'irail'); | ||
$this->assertEquals($_ENV['apiTable'], 'apilog'); | ||
$this->assertEquals($_ENV['apiPassword'], 'passwd'); | ||
|
||
// API database Columns | ||
$this->assertEquals($_ENV['column1'], 'id'); | ||
$this->assertEquals($_ENV['column2'], 'time'); | ||
$this->assertEquals($_ENV['column3'], 'useragent'); | ||
$this->assertEquals($_ENV['column4'], 'fromstation'); | ||
$this->assertEquals($_ENV['column5'], 'tostation'); | ||
$this->assertEquals($_ENV['column6'], 'errors'); | ||
$this->assertEquals($_ENV['column7'], 'ip'); | ||
$this->assertEquals($_ENV['column8'], 'server'); | ||
|
||
// API nameserver | ||
$this->assertEquals($_ENV['apiServerName'], 0); | ||
} | ||
} |