Skip to content

Commit 06e5384

Browse files
committed
QA: Coveralls, Travis, Codestyle, Simple test
1 parent 0c0ce65 commit 06e5384

File tree

10 files changed

+175
-3
lines changed

10 files changed

+175
-3
lines changed

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# Top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
11+
# JS / PHP
12+
[*.{js,php,phpt}]
13+
charset = utf-8
14+
indent_style = tab
15+
indent_size = 4
16+
17+
# Composer
18+
[{composer.json}]
19+
indent_style = space
20+
indent_size = 2

.travis.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
language: php
2+
3+
php:
4+
- 5.6
5+
- 7.0
6+
- 7.1
7+
- hhvm
8+
9+
matrix:
10+
fast_finish: true
11+
12+
allow_failures:
13+
- php: hhvm
14+
15+
include:
16+
- php: 5.6
17+
env: COMPOSER_FLAG=--prefer-lowest
18+
- php: 5.6
19+
env: COMPOSER_FLAG=--prefer-stable
20+
- php: 7.0
21+
env: COMPOSER_FLAG=--prefer-lowest
22+
- php: 7.0
23+
env: COMPOSER_FLAG=--prefer-stable
24+
- php: 7.1
25+
env: COMPOSER_FLAG=--prefer-lowest
26+
- php: 7.1
27+
env: COMPOSER_FLAG=--prefer-stable
28+
29+
before_script:
30+
# Composer
31+
- travis_retry composer install --no-interaction
32+
# Coverage
33+
- if [[ "$TRAVIS_PHP_VERSION" == "7.1" && "$COMPOSER_FLAG" == "" ]]; then COVERAGE=1; fi
34+
35+
script:
36+
# Quality Assurance
37+
- travis_retry composer qa
38+
39+
# Nette\Tester
40+
- composer run-script tester
41+
42+
# Nette\Tester + CodeCoverage
43+
- if [ "$COVERAGE" != "" ]; then composer tester-coverage; fi
44+
45+
after_script:
46+
# Coverage (Coveralls)
47+
- if [ "$COVERAGE" != "" ]; then wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar; fi
48+
- if [ "$COVERAGE" != "" ]; then php coveralls.phar --verbose --config tests/.coveralls.yml; fi
49+
50+
after_failure:
51+
# Print *.actual content
52+
- for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done
53+
54+
sudo: false
55+
56+
cache:
57+
directories:
58+
- $HOME/.composer/cache

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ gedmo:
8080
</br>
8181
<a href="https://github.com/f3l1x">Milan Felix Šulc</a>
8282
</td>
83+
<td align="center">
84+
<a href="https://github.com/benijo">
85+
<img width="150" height="150" src="https://avatars3.githubusercontent.com/u/6731626?v=3&s=150">
86+
</a>
87+
</br>
88+
<a href="https://github.com/benijo">Josef Benjač</a>
89+
</td>
8390
</tr>
8491
<tbody>
8592
</table>

composer.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,25 @@
1515
"gedmo/doctrine-extensions": "~2.4.0"
1616
},
1717
"require-dev": {
18-
"nette/tester": "~1.7.0",
19-
"kdyby/doctrine": ">=3.0.0"
18+
"kdyby/doctrine": ">=3.0.0",
19+
"ninjify/qa": "~0.4.0",
20+
"ninjify/nunjuck": "~0.1.4"
2021
},
2122
"autoload": {
2223
"psr-4": {
23-
"Nettrine\\Extensions\\DI\\": "src/"
24+
"Nettrine\\Extensions\\": "src/"
2425
}
26+
},
27+
"scripts": {
28+
"qa": [
29+
"linter src tests",
30+
"codesniffer src tests"
31+
],
32+
"tester": [
33+
"tester -s -p php --colors 1 -c tests/php-unix.ini tests/cases"
34+
],
35+
"tester-coverage": [
36+
"tester -s -p php --colors 1 -c tests/php-unix.ini -d extension=xdebug.so --coverage ./coverage.xml --coverage-src ./src tests/cases"
37+
]
2538
}
2639
}

src/DoctrineExtensionsExtension.php renamed to src/DI/DoctrineExtensionsExtension.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ final class DoctrineExtensionsExtension extends CompilerExtension implements IEn
4949

5050
/**
5151
* Register services
52+
*
53+
* @return void
5254
*/
5355
public function loadConfiguration()
5456
{

tests/.coveralls.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# for php-coveralls
2+
service_name: travis-ci
3+
coverage_clover: coverage.xml
4+
json_path: coverage.json

tests/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Folders - recursive
2+
*.expected
3+
*.actual
4+
5+
# Folders
6+
/tmp
7+
8+
# Files
9+
/*.log
10+
/*.html

tests/bootstrap.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
use Ninjify\Nunjuck\Environment;
4+
5+
if (@!include __DIR__ . '/../vendor/autoload.php') {
6+
echo 'Install Nette Tester using `composer update --dev`';
7+
exit(1);
8+
}
9+
10+
// Configure environment
11+
Environment::setup(__DIR__);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
/**
4+
* Test: DI\DoctrineExtensionsExtension
5+
*/
6+
7+
use Nette\DI\Compiler;
8+
use Nette\DI\Container;
9+
use Nette\DI\ContainerLoader;
10+
use Nettrine\Extensions\DI\DoctrineExtensionsExtension;
11+
use Tester\Assert;
12+
use Tester\FileMock;
13+
14+
require_once __DIR__ . '/../../bootstrap.php';
15+
16+
test(function () {
17+
$loader = new ContainerLoader(TEMP_DIR, TRUE);
18+
$class = $loader->load(function (Compiler $compiler) {
19+
$compiler->addExtension('extensions', new DoctrineExtensionsExtension());
20+
$compiler->loadConfig(FileMock::create('
21+
extensions:
22+
annotations:
23+
loggable: false
24+
sluggable: false
25+
softDeleteable: false
26+
treeable: false
27+
blameable: false
28+
timestampable: false
29+
translatable: false
30+
uploadable: false
31+
sortable: false
32+
ipTraceable: false
33+
', 'neon'));
34+
}, '1a');
35+
36+
/** @var Container $container */
37+
$container = new $class;
38+
Assert::type(Container::class, $container);
39+
});

tests/php-unix.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[PHP]
2+
;extension_dir = "./ext"
3+
extension=tokenizer.so
4+
;extension=json.so
5+
;extension=mcrypt.so
6+
7+
[Zend]
8+
;zend_extension="./ext/zend_extension"

0 commit comments

Comments
 (0)