Skip to content

Commit 82eb764

Browse files
committed
Tests: Add unit tests structure
1 parent a290119 commit 82eb764

9 files changed

+1817
-32
lines changed

Diff for: .gitattributes

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
/assets export-ignore
99
/.gitattributes export-ignore
1010
/.gitignore export-ignore
11+
/.phpcs.xml.dist export-ignore
1112
/.travis.yml export-ignore
1213
/CHANGELOG.md export-ignore
1314
/CODE_OF_CONDUCT.md export-ignore
14-
/.phpcs.xml.dist export-ignore
15+
/phpunit.xml.dist export-ignore
1516
/README.md export-ignore
1617
/readme.txt export-ignore

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
vendor/
22
/.phpcs.xml
33
/phpcs.xml
4+
/phpunit.xml

Diff for: .phpcs.xml.dist

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
<arg name="report" value="summary"/>
1010
<arg name="report" value="source"/>
1111
<rule ref="ObjectCalisthenics"/>
12-
<rule ref="PHPCompatibility" />
12+
<rule ref="PHPCompatibility">
13+
<exclude-pattern>tests</exclude-pattern>
14+
</rule>
1315
<config name="testVersion" value="7.0-"/>
1416
<rule ref="WordPress">
1517
<exclude name="WordPress.VIP"/>

Diff for: .travis.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ php:
1616
matrix:
1717
fast_finish: true
1818
include:
19-
# Run PHP CodeSniffer and XMLLint against just PHP 7.0 job.
20-
- php: 7.0
19+
# Run PHP CodeSniffer and XMLLint against just PHP 7.1 job, even
20+
# though the PHPCompatibility config checks against 7.0.
21+
- php: 7.1
2122
env: SNIFF=1 LINT=1
2223
addons:
2324
apt:
@@ -46,3 +47,6 @@ script:
4647
# Check coding standards. Run through composer script, to allow
4748
# PHP 5.2 compatibility check of main plugin file.
4849
- if [[ "$SNIFF" == "1" ]]; then composer phpcs; fi
50+
51+
# Run tests.
52+
- ./vendor/bin/phpunit --testsuite unit

Diff for: composer.json

+13-1
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,28 @@
2828
},
2929
"require-dev": {
3030
"php": "^7.1",
31+
"brain/monkey": "^2.1",
3132
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3",
3233
"object-calisthenics/phpcs-calisthenics-rules": "^3",
34+
"phpunit/phpunit": "^6.4",
3335
"squizlabs/php_codesniffer": "3.1",
3436
"wimg/php-compatibility": "dev-master",
3537
"wp-coding-standards/wpcs": "dev-develop"
3638
},
39+
"autoload": {
40+
"psr-4": {
41+
"Gamajo\\GenesisJsNoJs\\": "src/"
42+
}
43+
},
44+
"autoload-dev": {
45+
"psr-4": {
46+
"Gamajo\\GenesisJsNoJs\\Tests\\": "tests/"
47+
}
48+
},
3749
"scripts": {
3850
"install-codestandards": [
3951
"Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run"
4052
],
41-
"phpcs": "phpcs && phpcs ./genesis-js-no-js.php -sp --standard=PHPCompatibility --runtime-set testVersion 5.2"
53+
"phpcs": "phpcs && phpcs ./genesis-js-no-js.php -sp --standard=PHPCompatibility --runtime-set testVersion 5.2 && phpcs ./tests -sp --standard=PHPCompatibility --runtime-set testVersion 7.1"
4254
}
4355
}

0 commit comments

Comments
 (0)