Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
3d41394
Updating this to support php8.x
fr3nch13 Feb 15, 2023
ce5d5be
Multiple changes, see description.
fr3nch13 Feb 16, 2023
5ddb91e
Update ci.yml
fr3nch13 Feb 16, 2023
9d70e50
Update ci.yml
fr3nch13 Feb 16, 2023
45df3e2
Update ci.yml
fr3nch13 Feb 16, 2023
16da1d6
Update README.md
fr3nch13 Feb 16, 2023
b7dc570
Updating annotations to be compatibly with phpunit 9.x
fr3nch13 Feb 16, 2023
aa33e8f
Tests passing locally.
fr3nch13 Feb 16, 2023
f9a7ea9
Bug fix for php 8.2.2
fr3nch13 Feb 16, 2023
f1244bd
Update ci.yml
fr3nch13 Feb 16, 2023
b884833
Updating package requirements and github actions.
fr3nch13 Feb 16, 2023
f75c5cd
CS Updates
fr3nch13 Feb 16, 2023
7465f10
Update ci.yml
fr3nch13 Feb 16, 2023
ba29d1e
See if this will work for php 5.x
fr3nch13 Feb 16, 2023
8177f1c
Closer to being compatible with 5.x -> 8.x
fr3nch13 Feb 16, 2023
c2079f7
It didn't like the '_' prefix.
fr3nch13 Feb 16, 2023
bae6a08
Trying to be compatible with more phpunit versions.
fr3nch13 Feb 16, 2023
e9ddfb3
Update LoaderTest.php
fr3nch13 Feb 16, 2023
8ae90f8
Update LoaderTest.php
fr3nch13 Feb 16, 2023
c43cb9c
Forgot to remove that.
fr3nch13 Feb 16, 2023
f8e80be
Update ci.yml
fr3nch13 Feb 16, 2023
fc6159d
Trying to get coverage to work
fr3nch13 Feb 16, 2023
f64de7e
Minor updates to the testing.
fr3nch13 Feb 16, 2023
6a320f9
Maybe a caching issue?
fr3nch13 Feb 16, 2023
c058600
See if it's failing elsewhere.
fr3nch13 Feb 16, 2023
a4ac20b
Should fix issue with variables already set.
fr3nch13 Feb 16, 2023
1546faa
Try this for phpunit 8
fr3nch13 Feb 16, 2023
d8e74c4
Update phpunit.xml
fr3nch13 Feb 16, 2023
a6af278
From the original config.
fr3nch13 Feb 16, 2023
f4d6156
Will fail, but testing something.
fr3nch13 Feb 16, 2023
585dbc9
See if we can use php-specific configs.
fr3nch13 Feb 16, 2023
d299310
Adding coverage
fr3nch13 Feb 16, 2023
4960665
Adding for specific phpunit testing.
fr3nch13 Feb 16, 2023
9a7ce78
Fix config warning for 7.x
fr3nch13 Feb 16, 2023
93e4d8b
So codecov can find the coverage report.
fr3nch13 Feb 16, 2023
87b2030
Allow codecov
fr3nch13 Feb 16, 2023
071b8c0
Merge branch 'master' into issue-52
fr3nch13 Feb 17, 2023
e8ed8e5
Seems like no real changes.
fr3nch13 Feb 17, 2023
8091e60
Revert "Seems like no real changes."
fr3nch13 Feb 17, 2023
a58894e
Revert "Merge branch 'master' into issue-52"
fr3nch13 Feb 17, 2023
cb75cfc
Don't loose support for php 5.
fr3nch13 Feb 17, 2023
17f6640
Merge pull request #1 from 302dev/issue-52
fr3nch13 Feb 17, 2023
e189781
Delete phpunit.8.xml.bak
fr3nch13 Feb 17, 2023
01db3ac
Update README.markdown
fr3nch13 Feb 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: CI

on:
pull_request:
branches:
- '*'
push:
branches:
- '*'

permissions:
contents: read

jobs:
coding-standard:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php-version: ['5.5', '5.6', '7.1', '7.2', '7.4', '8.0', '8.1', '8.2']
name: Coding Standard ${{ matrix.php-version }}

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: none

- name: Composer install
run: composer install

- name: Run PHP CodeSniffer
run: composer run-script cs-check

test:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php-version: ['5.5', '5.6', '7.1', '7.2', '7.4', '8.0', '8.1', '8.2']
name: Test PHP ${{ matrix.php-version }}

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: none

- name: Composer install
run: composer install

- name: Run PHPUnit
run: composer run-script test-${{ matrix.php-version }}

coverage-php:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php-version: ['5.5', '5.6', '7.2', '7.4', '8.0', '8.1', '8.2'] # removed 7.1 as it seems to have an issue with no code coverage driver.
name: Coverage PHP ${{ matrix.php-version }}

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: pcov

- name: Composer install
run: composer install

- name: Run PHPUnit
run: composer run-script coverage-${{ matrix.php-version }}

- name: Upload to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./tmp/coverage.xml
verbose: true
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
.DS_Store
build
composer.lock
tmp
tmp/*
!tmp/.gitkeep
vendor
.phpunit.result.cache
/.phpunit.cache
coverage.xml
unitreport.xml
.vscode
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Build Status](https://img.shields.io/travis/josegonzalez/php-dotenv/master.svg?branch=master&style=flat-square)](https://travis-ci.org/josegonzalez/php-dotenv)
[![Coverage Status](https://img.shields.io/coveralls/josegonzalez/php-dotenv.svg?branch=master&style=flat-square)](https://coveralls.io/r/josegonzalez/php-dotenv?branch=master)
[![Coverage Status](https://img.shields.io/codecov/c/github/josegonzalez/dotenv.svg?style=flat-square)](https://codecov.io/github/josegonzalez/dotenv)
[![Total Downloads](https://img.shields.io/packagist/dt/josegonzalez/dotenv.svg?style=flat-square)](https://packagist.org/packages/josegonzalez/dotenv)
[![Latest Stable Version](https://img.shields.io/packagist/v/josegonzalez/dotenv.svg?style=flat-square)](https://packagist.org/packages/josegonzalez/dotenv)

Expand All @@ -19,14 +19,14 @@ A `.env` file parsing and loading library for PHP.

_[Using [Composer](http://getcomposer.org/)]_

Run `composer require josegonzalez/dotenv:dev-master`
Run `composer require josegonzalez/dotenv:`

Or add the plugin to your project's `composer.json` - something like this:

```javascript
{
"require": {
"josegonzalez/dotenv": "dev-master"
"josegonzalez/dotenv": "3.3.0"
}
}
```
Expand Down
42 changes: 39 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,49 @@
"m1/env": "2.*"
},
"require-dev": {
"squizlabs/php_codesniffer": "2.*",
"satooshi/php-coveralls": "1.*",
"php-mock/php-mock-phpunit": "^1.1"
"squizlabs/php_codesniffer": "~2.9||~3.7",
"php-coveralls/php-coveralls": "~2.0",
"php-mock/php-mock-phpunit": "~1.1||~2.0"
},
"autoload": {
"psr-0": {
"josegonzalez\\Dotenv": ["src", "tests"]
}
},
"scripts": {
"ci": [
"@cs-check",
"@test",
"@coverage-clover"
],
"test-5.5": "@test-5",
"test-5.6": "@test-5",
"test-7.0": "@test-7",
"test-7.1": "@test-7",
"test-7.2": "@test-7",
"test-7.4": "@test-7",
"test-8.0": "@test-8",
"test-8.1": "@test-8",
"test-8.2": "@test-8",
"coverage-5.5": "@coverage-5",
"coverage-5.6": "@coverage-5",
"coverage-7.0": "@coverage-7",
"coverage-7.1": "@coverage-7",
"coverage-7.2": "@coverage-7",
"coverage-7.4": "@coverage-7",
"coverage-8.0": "@coverage-8",
"coverage-8.1": "@coverage-8",
"coverage-8.2": "@coverage-8",
"cs-check": "php -d memory_limit=-1 ./vendor/bin/phpcs --standard=psr2 --exclude=Generic.Files.LineLength ./src ./tests",
"cs-checkstyle": "php -d memory_limit=-1 ./vendor/bin/phpcs --standard=psr2 --report=checkstyle ./src ./tests",
"cs-fix": "php -d memory_limit=-1 ./vendor/bin/phpcbf --standard=psr2 ./src ./tests",
"test": "@test-8",
"test-5": "php -d memory_limit=-1 ./vendor/bin/phpunit -c phpunit.5.xml --colors=always --log-junit unitreport.xml --testdox",
"test-7": "php -d memory_limit=-1 ./vendor/bin/phpunit -c phpunit.7.xml --colors=always --log-junit unitreport.xml --testdox",
"test-8": "php -d memory_limit=-1 ./vendor/bin/phpunit -c phpunit.8.xml --colors=always --log-junit unitreport.xml --testdox",
"coverage-5": "php -d memory_limit=-1 -d xdebug.mode=coverage ./vendor/bin/phpunit -c phpunit.5.xml --coverage-text --coverage-clover=./tmp/coverage.xml --testdox",
"coverage-7": "php -d memory_limit=-1 -d xdebug.mode=coverage ./vendor/bin/phpunit -c phpunit.7.xml --coverage-text --coverage-clover=./tmp/coverage.xml --testdox",
"coverage-8": "php -d memory_limit=-1 -d xdebug.mode=coverage ./vendor/bin/phpunit -c phpunit.8.xml --coverage-text --coverage-clover=./tmp/coverage.xml --testdox",
"coveralls": "php -d memory_limit=-1 ./vendor/bin/vendor/bin/coveralls -v"
}
}
1 change: 0 additions & 1 deletion phpunit.xml → phpunit.5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/bootstrap.php"
>
<testsuites>
Expand Down
25 changes: 25 additions & 0 deletions phpunit.7.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="./tests/bootstrap.php"
>
<testsuites>
<testsuite name="Dotenv Test Suite">
<directory suffix=".php">tests/josegonzalez/Dotenv</directory>
</testsuite>
</testsuites>
<filter>
<!-- this is required, even if empty, until
https://github.com/sebastianbergmann/phpunit/issues/1872
is resolved -->
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
</phpunit>
13 changes: 13 additions & 0 deletions phpunit.8.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" bootstrap="tests/bootstrap.php" executionOrder="depends,defects" forceCoversAnnotation="true" beStrictAboutCoversAnnotation="true" beStrictAboutOutputDuringTests="true" beStrictAboutTodoAnnotatedTests="true" convertDeprecationsToExceptions="true" failOnRisky="false" failOnWarning="true" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" verbose="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Dotenv Test Suite">
<directory suffix=".php">tests/josegonzalez/Dotenv</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 2 additions & 0 deletions src/josegonzalez/Dotenv/Expect.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

class Expect
{
protected $environment = array();

protected $raise = true;

public function __construct($environment, $raise = true)
Expand Down
3 changes: 2 additions & 1 deletion src/josegonzalez/Dotenv/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class Loader

protected $environment = null;

protected $exceptions = array();

protected $filepaths = null;

protected $filters = array();
Expand All @@ -32,7 +34,6 @@ class Loader
public function __construct($filepaths = null)
{
$this->setFilepaths($filepaths);
return $this;
}

public static function load($options = null)
Expand Down
34 changes: 30 additions & 4 deletions tests/josegonzalez/Dotenv/ExpectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,29 @@
namespace josegonzalez\Dotenv;

use josegonzalez\Dotenv\Expect;
use \PHPUnit_Framework_TestCase;
use \PHPUnit\Framework\TestCase as PHPUnit_Framework_TestCase;

class ExpectTest extends PHPUnit_Framework_TestCase
{
protected $env = array();

public function setUp()
protected $server = array();

/**
* Hopefully this will allow php > 7.1 to run.
* Phpunit >= 8.0 uses setUp(): void which this needs to match, but will break php 5.x
*/
public function compatibleSetUp()
{
$this->env = $_ENV;
$this->server = $_SERVER;
}

public function tearDown()
/**
* Hopefully this will allow php > 7.1 to run.
* Phpunit >= 8.0 uses tearDown(): void which this needs to match, but will break php 5.x
*/
public function compatibleTearDown()
{
$_ENV = $this->env;
$_SERVER = $this->server;
Expand All @@ -29,37 +40,52 @@ public function tearDown()
*/
public function testExpect()
{
$this->compatibleSetUp();
$expect = new Expect($this->server);
$this->assertTrue($expect('USER'));
$this->assertTrue($expect(array('USER', 'HOME')));

$expect = new Expect($this->server, false);
$this->assertFalse($expect('FOO'));
$this->assertFalse($expect(array('USER', 'FOO')));
$this->compatibleTearDown();
}

/**
* @covers \josegonzalez\Dotenv\Expect::__construct
* @covers \josegonzalez\Dotenv\Expect::__invoke
* @covers \josegonzalez\Dotenv\Expect::raise
* @expectedException LogicException
* @expectedExceptionMessage No arguments were passed to expect()
*/
public function testExpectLogicException()
{
$this->compatibleSetUp();
if (method_exists($this, 'expectException')) {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('No arguments were passed to expect()');
}
$expect = new Expect($this->server);
$expect();
$this->compatibleTearDown();
}

/**
* @covers \josegonzalez\Dotenv\Expect::__construct
* @covers \josegonzalez\Dotenv\Expect::__invoke
* @covers \josegonzalez\Dotenv\Expect::raise
* @expectedException RuntimeException
* @expectedExceptionMessage Required ENV vars missing: ['INVALID']
*/
public function testExpectRuntimeException()
{
$this->compatibleSetUp();
if (method_exists($this, 'expectException')) {
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage("Required ENV vars missing: ['INVALID']");
}
$expect = new Expect($this->server);
$expect('INVALID');
$this->compatibleTearDown();
}

}
Loading