-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
236 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module.exports = { | ||
'env': { | ||
'browser': true, | ||
'es6': true, | ||
}, | ||
'parserOptions': { | ||
'ecmaVersion': 2018, | ||
'sourceType': 'module', | ||
}, | ||
'plugins': [ | ||
'import', | ||
], | ||
'extends': [ | ||
'@nepada', | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0"?> | ||
<ruleset> | ||
<config name="installed_paths" value="../../nepada/coding-standard/src"/><!-- relative path from PHPCS source location --> | ||
|
||
<arg value="ps"/><!-- show progress of the run, show sniff names --> | ||
<arg name="cache" value=".phpcs-cache"/> | ||
|
||
<arg name="extensions" value="php,phpt"/> | ||
<file>src</file> | ||
<file>tests</file> | ||
|
||
<rule ref="Nepada"> | ||
</rule> | ||
|
||
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName"> | ||
<properties> | ||
<property name="rootNamespaces" type="array"> | ||
<element key="src" value="Nepada"/> | ||
<element key="tests" value="NepadaTests"/> | ||
</property> | ||
<property name="extensions" type="array"> | ||
<element value="php"/> | ||
<element value="phpt"/> | ||
</property> | ||
</properties> | ||
</rule> | ||
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"> | ||
<properties> | ||
<property name="ignoredAnnotationNames" type="array"> | ||
<element value="@testCase"/> | ||
<element value="@dataProvider"/> | ||
</property> | ||
</properties> | ||
</rule> | ||
|
||
<!-- special settings for tests and bootstrap --> | ||
<exclude-pattern>*/tests/temp/*</exclude-pattern> | ||
<rule ref="PSR1.Files.SideEffects"> | ||
<exclude-pattern>*.phpt</exclude-pattern> | ||
<exclude-pattern>*/bootstrap.php</exclude-pattern> | ||
</rule> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
language: php | ||
php: | ||
- 7.4 | ||
|
||
env: | ||
- COMPOSER_ARGS="" | ||
- COMPOSER_ARGS="--prefer-stable" | ||
- COMPOSER_ARGS="--prefer-stable --prefer-lowest" | ||
|
||
jobs: | ||
include: | ||
- name: JS test + Code Standard Checker | ||
language: node_js | ||
node_js: lts/* | ||
install: | ||
- travis_retry npm install | ||
script: | ||
- npm run lint | ||
- npm run build | ||
- stage: Code Standard Checker | ||
php: 7.4 | ||
script: | ||
- vendor/bin/phpcs | ||
- stage: Code Coverage | ||
php: 7.4 | ||
script: | ||
- vendor/bin/tester -p phpdbg tests -s --coverage ./coverage.xml --coverage-src ./src | ||
after_script: | ||
- travis_retry wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.0.0/php-coveralls.phar | ||
- php php-coveralls.phar --verbose --config tests/coveralls.yml | ||
allow_failures: | ||
- stage: Code Coverage | ||
|
||
install: | ||
- travis_retry composer update --no-interaction --prefer-dist $COMPOSER_ARGS | ||
|
||
script: | ||
- vendor/bin/parallel-lint -e php,phpt --exclude tests/temp src tests | ||
- vendor/bin/tester -s -p php -c tests/php.ini tests | ||
- vendor/bin/phpstan.phar analyse | ||
- vendor/bin/phpstan.phar analyse -c phpstan.tests.neon.dist | ||
|
||
after_failure: | ||
- for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done | ||
|
||
sudo: false | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
- $HOME/.npm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
'presets': [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
'targets': { | ||
'node': 'current', | ||
}, | ||
}, | ||
], | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
includes: | ||
- vendor/phpstan/phpstan-strict-rules/rules.neon | ||
- vendor/pepakriz/phpstan-exception-rules/extension.neon | ||
- vendor/phpstan/phpstan-nette/extension.neon | ||
- vendor/phpstan/phpstan-nette/rules.neon | ||
- tests/phpstan/disallowed-calls-rules.neon | ||
|
||
parameters: | ||
level: max | ||
paths: | ||
- src | ||
|
||
exceptionRules: | ||
uncheckedExceptions: | ||
- LogicException | ||
- Nette\InvalidStateException |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
includes: | ||
- vendor/phpstan/phpstan-strict-rules/rules.neon | ||
- vendor/phpstan/phpstan-nette/extension.neon | ||
- vendor/phpstan/phpstan-nette/rules.neon | ||
- vendor/nepada/phpstan-nette-tester/extension.neon | ||
- vendor/phpstan/phpstan-mockery/extension.neon | ||
- tests/phpstan/disallowed-calls-rules.neon | ||
|
||
parameters: | ||
level: max | ||
paths: | ||
- tests | ||
|
||
fileExtensions: | ||
- php | ||
- phpt | ||
|
||
autoload_directories: | ||
- tests | ||
|
||
excludes_analyse: | ||
- tests/bootstrap.php | ||
- tests/temp/* | ||
|
||
ignoreErrors: | ||
# - '~Call to static method Tester\\Assert::(type|count|same|notSame)\(\) with .* and .* will always evaluate to true\.~' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/temp | ||
/*.log | ||
output/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace NepadaTests; | ||
|
||
use Mockery; | ||
use Tester; | ||
|
||
abstract class TestCase extends Tester\TestCase | ||
{ | ||
|
||
public function run(): void | ||
{ | ||
if ($_ENV['IS_PHPSTAN'] ?? false) { | ||
return; | ||
} | ||
|
||
parent::run(); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
Mockery::close(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
// detect PHPStan | ||
if (getenv('IS_PHPSTAN') !== false) { | ||
$_ENV['IS_PHPSTAN'] = in_array(strtolower(getenv('IS_PHPSTAN')), ['1', 'true', 'yes', 'on'], true); | ||
} else { | ||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); | ||
$_ENV['IS_PHPSTAN'] = (bool) preg_match('~[/\\\\]phpstan(?:\.phar)?$~', end($trace)['file'] ?? ''); | ||
} | ||
|
||
|
||
// configure environment | ||
if (! $_ENV['IS_PHPSTAN']) { | ||
Tester\Environment::setup(); | ||
date_default_timezone_set('Europe/Prague'); | ||
} | ||
|
||
|
||
// create temporary directory | ||
define('TEMP_DIR', __DIR__ . '/temp/' . (isset($_SERVER['argv']) ? md5(serialize($_SERVER['argv'])) : getmypid())); | ||
if (! $_ENV['IS_PHPSTAN']) { | ||
@mkdir(dirname(TEMP_DIR)); // @ - directory may already exist | ||
Tester\Helpers::purge(TEMP_DIR); | ||
ini_set('session.save_path', TEMP_DIR); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# for php-coveralls | ||
service_name: travis-ci | ||
coverage_clover: coverage.xml | ||
json_path: coverage.json |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
services: | ||
- | ||
type: Spaze\PHPStan\Rules\Disallowed\FunctionCalls | ||
tags: | ||
- phpstan.rules.rule | ||
arguments: | ||
forbiddenCalls: | ||
- | ||
function: 'var_dump()' | ||
- | ||
function: 'print_r()' |