Skip to content

Commit

Permalink
Added contributing guide with real db engine testing samples
Browse files Browse the repository at this point in the history
  • Loading branch information
fulopattila122 committed Jul 10, 2024
1 parent 0361fdd commit f430ce8
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 51 deletions.
65 changes: 65 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Contributing to Vanilo Framework

## Running Tests

By default, tests are ran against an SQLite database.

If you'd like to run against a real DB engine, the fastest way to do so is to spin up a container for the given
DB engine, and configure a local `phpunit.xml` accordingly

### MySQL 5.7

To spin up a temporary MySQL 5.7 DB use the following command:

```bash
docker run --name vanilo_test_mysql57 -e MYSQL_ROOT_PASSWORD=mypass123 -d -p 3307:3306 mysql:5.7
```

> You can choose any other container name, password or port instead of the ones in the example above
Then copy `phpunit.xml.dist` to `phpunit.xml` and add the following values before the closing `</phpunit>` tag:

```xml
<php>
<env name="APP_KEY" value="base64:gm0Aq0Xod/x8Rn2nhZLioYx55ojBcnjzaD4+GQ8M8mM="/>
<env name="APP_ENV" value="testing"/>
<env name="APP_DEBUG" value="true"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TEST_DB_ENGINE" value="mysql"/>
<env name="TEST_DB_PORT" value="3307"/>
<env name="TEST_DB_PASSWORD" value="mypass123"/>
</php>
```

### Postgres

To spin up a temporary Postgres Database use the following command:

```bash
docker run --name postgres_test -e POSTGRES_PASSWORD=pgpass123 -d -p 5452:5432 postgres
```

> You can choose any other container name, password or port instead of the ones in the example above
Then copy `phpunit.xml.dist` to `phpunit.xml` and add the following values before the closing `</phpunit>` tag:

```xml
<php>
<env name="APP_KEY" value="base64:gm0Aq0Xod/x8Rn2nhZLioYx55ojBcnjzaD4+GQ8M8mM="/>
<env name="APP_ENV" value="testing"/>
<env name="APP_DEBUG" value="true"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="TEST_DB_ENGINE" value="pgsql"/>
<env name="TEST_DB_PORT" value="5452"/>
<env name="TEST_DB_PASSWORD" value="pgpass123"/>
</php>
```

105 changes: 54 additions & 51 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,53 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Contract Tests">
<directory>src/Contracts/Tests</directory>
</testsuite>
<testsuite name="Support Tests">
<directory>src/Support/Tests</directory>
</testsuite>
<testsuite name="Product Tests">
<directory>src/Product/Tests</directory>
</testsuite>
<testsuite name="Master Product Tests">
<directory>src/MasterProduct/Tests</directory>
</testsuite>
<testsuite name="Properties Tests">
<directory>src/Properties/Tests</directory>
</testsuite>
<testsuite name="Category Tests">
<directory>src/Category/Tests</directory>
</testsuite>
<testsuite name="Links Tests">
<directory>src/Links/Tests</directory>
</testsuite>
<testsuite name="Channel Tests">
<directory>src/Channel/Tests</directory>
</testsuite>
<testsuite name="Cart Tests">
<directory>src/Cart/Tests</directory>
</testsuite>
<testsuite name="Checkout Tests">
<directory>src/Checkout/Tests</directory>
</testsuite>
<testsuite name="Order Tests">
<directory>src/Order/Tests</directory>
</testsuite>
<testsuite name="Payment Tests">
<directory>src/Payment/Tests</directory>
</testsuite>
<testsuite name="Shipment Tests">
<directory>src/Shipment/Tests</directory>
</testsuite>
<testsuite name="Adjustments Tests">
<directory>src/Adjustments/Tests</directory>
</testsuite>
<testsuite name="Taxes Tests">
<directory>src/Taxes/Tests</directory>
</testsuite>
<testsuite name="Foundation Tests">
<directory>src/Foundation/Tests</directory>
</testsuite>
</testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php"
backupGlobals="false" colors="true" processIsolation="false" stopOnDefect="true"
cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Contract Tests">
<directory>src/Contracts/Tests</directory>
</testsuite>
<testsuite name="Support Tests">
<directory>src/Support/Tests</directory>
</testsuite>
<testsuite name="Product Tests">
<directory>src/Product/Tests</directory>
</testsuite>
<testsuite name="Master Product Tests">
<directory>src/MasterProduct/Tests</directory>
</testsuite>
<testsuite name="Properties Tests">
<directory>src/Properties/Tests</directory>
</testsuite>
<testsuite name="Category Tests">
<directory>src/Category/Tests</directory>
</testsuite>
<testsuite name="Links Tests">
<directory>src/Links/Tests</directory>
</testsuite>
<testsuite name="Channel Tests">
<directory>src/Channel/Tests</directory>
</testsuite>
<testsuite name="Cart Tests">
<directory>src/Cart/Tests</directory>
</testsuite>
<testsuite name="Checkout Tests">
<directory>src/Checkout/Tests</directory>
</testsuite>
<testsuite name="Order Tests">
<directory>src/Order/Tests</directory>
</testsuite>
<testsuite name="Payment Tests">
<directory>src/Payment/Tests</directory>
</testsuite>
<testsuite name="Shipment Tests">
<directory>src/Shipment/Tests</directory>
</testsuite>
<testsuite name="Adjustments Tests">
<directory>src/Adjustments/Tests</directory>
</testsuite>
<testsuite name="Taxes Tests">
<directory>src/Taxes/Tests</directory>
</testsuite>
<testsuite name="Foundation Tests">
<directory>src/Foundation/Tests</directory>
</testsuite>
</testsuites>
</phpunit>

0 comments on commit f430ce8

Please sign in to comment.