Added env function, added GitLab CI code coverage config

main
Igor Scheller 7 years ago
parent c5c0a602aa
commit 449e2cdd00

@ -0,0 +1,47 @@
image: php
cache:
paths:
- .composer
services:
- mysql:5.6
variables:
MYSQL_DATABASE: engelsystem
MYSQL_USER: engel
MYSQL_PASSWORD: engelsystem
COMPOSER_HOME: .composer
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
before_script:
# Install required Packages
- apt-get update -yqq
- apt-get install -yqq git unzip mysql-client
- docker-php-ext-install pdo pdo_mysql gettext
# Install xdebug
- pecl install xdebug
- docker-php-ext-enable xdebug
# MySQL DB
- mysql -h mysql -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" < db/install.sql
- mysql -h mysql -u "$MYSQL_USER" -p"$MYSQL_PASSWORD" "$MYSQL_DATABASE" < db/update.sql
# Install Composer
- curl -sS https://getcomposer.org/installer | php -- --no-ansi --install-dir /usr/local/bin/ --filename composer
- /usr/local/bin/composer --no-ansi install
.test_template: &test_definition
artifacts:
name: "${CI_JOB_NAME}_${CI_PROJECT_ID}_${PHP_VERSION}"
expire_in: 1 week
paths:
- ./coverage/
coverage: '/^\s*Lines:\s*(\d+(?:\.\d+)?%)/'
script: vendor/bin/phpunit --colors=never --coverage-text --coverage-html ./coverage/
test:7.0:
image: php:7.0
<<: *test_definition
test:7.1:
image: php:7.1
<<: *test_definition

@ -5,10 +5,10 @@
return [ return [
// MySQL-Connection Settings // MySQL-Connection Settings
'database' => [ 'database' => [
'host' => 'localhost', 'host' => env('MYSQL_HOST', (env('CI', false) ? 'mysql' : 'localhost')),
'user' => 'root', 'user' => env('MYSQL_USER', 'root'),
'pw' => '', 'pw' => env('MYSQL_PASSWORD', ''),
'db' => 'engelsystem', 'db' => env('MYSQL_DATABASE', 'engelsystem'),
], ],
// For accessing stats // For accessing stats

@ -64,6 +64,21 @@ function config_path($path = '')
return app('path.config') . (empty($path) ? '' : DIRECTORY_SEPARATOR . $path); return app('path.config') . (empty($path) ? '' : DIRECTORY_SEPARATOR . $path);
} }
/**
* @param string $key
* @param mixed $default
* @return mixed
*/
function env($key, $default = null)
{
$value = getenv($key);
if ($value === false) {
return $default;
}
return $value;
}
/** /**
* @param string $key * @param string $key
* @param mixed $default * @param mixed $default

@ -53,6 +53,20 @@ class HelpersTest extends TestCase
$this->assertEquals(['user' => 'FooBar'], config('mail')); $this->assertEquals(['user' => 'FooBar'], config('mail'));
} }
/**
* @covers \env
*/
public function testEnv()
{
putenv('envTestVar=someContent');
$env = env('envTestVar');
$this->assertEquals('someContent', $env);
$env = env('someRandomEnvVarThatShouldNeverExist', 'someDefaultValue');
$this->assertEquals('someDefaultValue', $env);
}
/** /**
* @covers \request * @covers \request
*/ */

Loading…
Cancel
Save