Skip to content

Commit

Permalink
Add testing docs. (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Apr 1, 2023
1 parent 08a0973 commit 3c26252
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 42 deletions.
43 changes: 1 addition & 42 deletions README.md
Expand Up @@ -46,48 +46,7 @@ For config connection to Mysql, MariaDb database check [Connecting MySQL/MariaDb

## Testing

### Unit testing

The package is tested with [PHPUnit](https://phpunit.de/). To run tests:

```shell
./vendor/bin/phpunit
```

### Mutation testing

The package tests are checked with [Infection](https://infection.github.io/) mutation framework. To run it:

```shell
./vendor/bin/infection
```

### Static analysis

The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis:

```shell
./vendor/bin/psalm
```

### Rector

Use [Rector](https://github.com/rectorphp/rector) to make codebase follow some specific rules or
use either newest or any specific version of PHP:

```shell
./vendor/bin/rector
```

### Composer require checker

This package uses [composer-require-checker](https://github.com/maglnet/ComposerRequireChecker) to check if all dependencies are correctly defined in `composer.json`.

To run the checker, execute the following command:

```shell
./vendor/bin/composer-require-checker
```
[Check the documentation](/docs/en/testing.md) to learn about testing.

## Support the project

Expand Down
17 changes: 17 additions & 0 deletions docker-compose-mariadb.yml
@@ -0,0 +1,17 @@
version: '3'

services:
mariadb:
image: mariadb:10.11
restart: always
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
MYSQL_PASSWORD: ''
MYSQL_ROOT_PASSWORD: ''
MYSQL_DATABASE: 'yiitest'
ports:
# <Port exposed> : < MySQL Port running inside container>
- '3306:3306'
expose:
# Opens port 3306 on the container
- '3306'
17 changes: 17 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,17 @@
version: '3'

services:
mysql:
image: mysql:8
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
# user and password are set in the yml file
MYSQL_PASSWORD: ''
MYSQL_ROOT_PASSWORD: ''
MYSQL_DATABASE: 'yiitest'
ports:
# <Port exposed> : < MySQL Port running inside container>
- '3306:3306'
expose:
# Opens port 3306 on the container
- '3306'
72 changes: 72 additions & 0 deletions docs/en/testing.md
@@ -0,0 +1,72 @@
# Testing

## Docker image

For greater ease it is recommended to use docker containers, for this you can use the [docker-compose.yml](https://docs.docker.com/compose/compose-file/) file that is in the docs folder.

1. [MySQL 8](/docker-compose.yml)
2. [MariaDB 10.11](/docker-compose-mariadb.yml)

For running the docker containers you can use the following command:

MySQL 8.0.

```shell
docker compose up -d
```

MariaDB 10.11.

```shell
docker compose -f docker-compose-mariadb.yml up -d
```

## Unit testing

The package is tested with [PHPUnit](https://phpunit.de/).

The following steps are required to run the tests:

1. Run the docker container for the dbms.
2. Install the dependencies of the project with composer.
3. Run the tests.

```shell
vendor/bin/phpunit
```

### Mutation testing

The package tests are checked with [Infection](https://infection.github.io/) mutation framework with
[Infection Static Analysis Plugin](https://github.com/Roave/infection-static-analysis-plugin). To run it:

```shell
./vendor/bin/roave-infection-static-analysis-plugin
```

## Static analysis

The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis:

```shell
./vendor/bin/psalm
```

## Rector

Use [Rector](https://github.com/rectorphp/rector) to make codebase follow some specific rules or
use either newest or any specific version of PHP:

```shell
./vendor/bin/rector
```

## Composer require checker

This package uses [composer-require-checker](https://github.com/maglnet/ComposerRequireChecker) to check if all dependencies are correctly defined in `composer.json`.

To run the checker, execute the following command:

```shell
./vendor/bin/composer-require-checker
```

0 comments on commit 3c26252

Please sign in to comment.