Skip to content

Commit

Permalink
Add nette tester support
Browse files Browse the repository at this point in the history
  • Loading branch information
MatusGoljerSalesChamp committed May 22, 2017
1 parent a4d5f5d commit 20252ee
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 2 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ To run the server inside docker, run

docker-compose up -d

## Nette Tester

[Nette Tester](https://github.com/nette/tester/) is a lightweight alternative to [PHPUnit](https://phpunit.de/).

Place your tests under `./tests/` followed by PSR-4 compatible directory structure, so a class `App\Controllers\Hello` goes into `./tests/App/Controllers/Hello.phpt`.

Remember to `require_once __DIR__ .'/../bootstrap.php'` (add appropriate number of `../` to point to `./tests/bootstrap.php`) to enable autoloading of your classes.

Tests should be under `Tests\` namespace followed by the namespace of the class being tested, so the test class `App\Controllers\HelloTest` goes under `Tests\App\Controllers` namespace.

Run

composer tester

to run the testsuite.

If you need additional extensions to load during tests, add them to `./tests/php.ini` (`json` is included by default).

## PHPStan - PHP Static analysis

[PHPStan](https://github.com/phpstan/phpstan) is a static code analysis tool. It is already set up in the repo, to run the report use
Expand Down
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"php": ">=7.0.0",
"slim/slim": "^3.1",
"monolog/monolog": "^1.17",
"nette/neon": "^2.4"
"nette/neon": "^2.4",
"nette/tester": "^1.7"
},
"require-dev": {
"phpstan/phpstan": "^0.7.0",
Expand All @@ -21,12 +22,18 @@
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"config": {
"process-timeout" : 0
},
"scripts": {
"start": "php -S 0.0.0.0:8080 -t public public/index.php",
"phpstan": "phpstan analyze -l 7 -c tests/phpstan.neon src",
"tester": "tester -p php -c tests/php.ini tests",
"phpcs": "phpcs src"
}
}
58 changes: 57 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require_once __DIR__ . '/../src/bootstrap.php';
1 change: 1 addition & 0 deletions tests/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=json.so

0 comments on commit 20252ee

Please sign in to comment.