Skip to content

Commit

Permalink
Add setup guide for contributing and .env for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
drtheuns committed Jan 14, 2020
1 parent aa721d6 commit 0d7c5cd
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 6 deletions.
34 changes: 34 additions & 0 deletions SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Setup

This document is meant for setting up this project locally for contributors, not
for those seeking to use the package. For information on how to set up the
project, refer to [the "Getting started" page](https://drtheuns.github.io/apitizer_php/index).

## Steps

1. Clone the repo

```
git clone [email protected]:drtheuns/apitizer_php && cd apitizer_php
```

2. Load dependencies

```
composer install
```

3. Setup testing

Create a new file, `.env`, in the project root and put your database credentials
in there:

```
DB_CONNECTION=pgsql
DB_DATABASE=apitizer_php_testing
DB_USERNAME=postgres
DB_PASSWORD=postgres
```

You can now start testing by using the `composer test` alias, or by directly
calling `./vendor/bin/phpunit`.
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@
"Apitizer\\ServiceProvider"
]
}
},
"scripts": {
"test": "./vendor/bin/phpunit",
"coverage": "./vendor/bin/phpunit --coverage-html coverage"
}
}
7 changes: 1 addition & 6 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
bootstrap="tests/autoload.php"
executionOrder="depends,defects"
forceCoversAnnotation="false"
beStrictAboutCoversAnnotation="true"
Expand All @@ -26,10 +26,5 @@
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>

<env name="DB_CONNECTION" value="pgsql"/>
<env name="DB_DATABASE" value="apitizer_php_testing"/>
<env name="DB_USERNAME" value="postgres" />
<env name="DB_PASSWORD" value="postgres" />
</php>
</phpunit>
15 changes: 15 additions & 0 deletions tests/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use Dotenv\Dotenv;

require __DIR__.'/../vendor/autoload.php';

if (file_exists(__DIR__.'/../.env')) {
$dotenv = Dotenv::create(__DIR__.'/../');
$dotenv->load();
} else {
echo "You need to set up a .env file in order to begin testing\n";
echo "Refer to the SETUP.md for more information\n";

exit(1);
}

0 comments on commit 0d7c5cd

Please sign in to comment.