Skip to content

Commit 0b17f1e

Browse files
committed
Development version 0.1
1 parent 31bf94a commit 0b17f1e

31 files changed

+4140
-0
lines changed

.coveralls.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
service_name: travis-ci
2+
coverage_clover: build/logs/clover.xml
3+
json_path: build/logs/coveralls-upload.json

.dev-lib

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PHPCS_IGNORE='vendor/*,wp-includes/rest-api/auth/jwt/*,tests/wp-tests/*'

.editorconfig

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# WordPress Coding Standards
2+
# https://make.wordpress.org/core/handbook/coding-standards/
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
indent_style = tab
12+
13+
[{package.json,*.yml}]
14+
indent_style = space
15+
indent_size = 2
16+
17+
[{*.txt,wp-config-sample.php}]
18+
end_of_line = crlf

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/*.min.js
2+
**/node_modules/**
3+
**/vendor/**

.eslintrc

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
{
2+
"env": {
3+
"browser": true
4+
},
5+
"globals": {
6+
"_": false,
7+
"Backbone": false,
8+
"jQuery": false,
9+
"wp": false
10+
},
11+
"rules": {
12+
"accessor-pairs": [2],
13+
"block-scoped-var": [2],
14+
"callback-return": [2],
15+
"complexity": [2, 8],
16+
"consistent-return": [2],
17+
"consistent-this": [2, "self"],
18+
"constructor-super": [2],
19+
"default-case": [2],
20+
"eqeqeq": [2],
21+
"func-style": [0],
22+
"global-require": [2],
23+
"guard-for-in": [0],
24+
"handle-callback-err": [2, "^err(or)?$"],
25+
"id-length": [0],
26+
"id-match": [0],
27+
"indent": ["error", "tab"],
28+
"init-declarations": [0],
29+
"max-depth": [2, 3],
30+
"max-nested-callbacks": [2, 3],
31+
"max-params": [2, 4],
32+
"max-statements": [0],
33+
"new-parens": [0],
34+
"no-alert": [0],
35+
"no-array-constructor": [0],
36+
"no-bitwise": [0],
37+
"no-caller": [2],
38+
"no-case-declarations": [2],
39+
"no-catch-shadow": [2],
40+
"no-class-assign": [2],
41+
"no-cond-assign": [2],
42+
"no-console": [0],
43+
"no-const-assign": [2],
44+
"no-constant-condition": [0],
45+
"no-continue": [0],
46+
"no-control-regex": [2],
47+
"no-debugger": [2],
48+
"no-delete-var": [2],
49+
"no-div-regex": [0],
50+
"no-dupe-args": [2],
51+
"no-dupe-class-members": [2],
52+
"no-dupe-keys": [2],
53+
"no-duplicate-case": [2],
54+
"no-else-return": [0],
55+
"no-empty-character-class": [2],
56+
"no-empty-pattern": [2],
57+
"no-empty": [2],
58+
"no-eq-null": [2],
59+
"no-eval": [2],
60+
"no-ex-assign": [2],
61+
"no-extend-native": [0],
62+
"no-extra-bind": [2],
63+
"no-extra-boolean-cast": [2],
64+
"no-extra-parens": [2],
65+
"no-extra-semi": [2],
66+
"no-fallthrough": [2],
67+
"no-floating-decimal": [2],
68+
"no-func-assign": [2],
69+
"no-implicit-coercion": [2],
70+
"no-implicit-globals": [0],
71+
"no-implied-eval": [2],
72+
"no-inline-comments": [0],
73+
"no-inner-declarations": [2],
74+
"no-invalid-regexp": [2],
75+
"no-invalid-this": [0],
76+
"no-irregular-whitespace": [2],
77+
"no-iterator": [2],
78+
"no-label-var": [2],
79+
"no-labels": [0],
80+
"no-lone-blocks": [2],
81+
"no-lonely-if": [2],
82+
"no-loop-func": [2],
83+
"no-magic-numbers": [2, { "ignoreArrayIndexes": true, "ignore": [ -1, 0 ] }],
84+
"no-mixed-requires": [0],
85+
"no-multi-str": [2],
86+
"no-native-reassign": [2],
87+
"no-negated-condition": [0],
88+
"no-negated-in-lhs": [2],
89+
"no-nested-ternary": [0],
90+
"no-new-func": [0],
91+
"no-new-object": [2],
92+
"no-new-require": [0],
93+
"no-new-wrappers": [2],
94+
"no-new": [2],
95+
"no-obj-calls": [2],
96+
"no-octal-escape": [2],
97+
"no-octal": [2],
98+
"no-param-reassign": [2],
99+
"no-path-concat": [2],
100+
"no-plusplus": [0],
101+
"no-process-env": [2],
102+
"no-process-exit": [0],
103+
"no-proto": [2],
104+
"no-redeclare": [2],
105+
"no-regex-spaces": [0],
106+
"no-restricted-imports": [0],
107+
"no-restricted-syntax": [0],
108+
"no-return-assign": [2],
109+
"no-script-url": [0],
110+
"no-self-compare": [2],
111+
"no-sequences": [2],
112+
"no-shadow-restricted-names": [2],
113+
"no-shadow": [2],
114+
"no-sparse-arrays": [2],
115+
"no-sync": [0],
116+
"no-ternary": [0],
117+
"no-trailing-spaces": [2],
118+
"no-this-before-super": [2],
119+
"no-throw-literal": [2],
120+
"no-undef-init": [0],
121+
"no-undef": [2],
122+
"no-undefined": [0],
123+
"no-unneeded-ternary": [2],
124+
"no-unreachable": [2],
125+
"no-unused-expressions": [2],
126+
"no-unused-vars": [2],
127+
"no-use-before-define": [0],
128+
"no-useless-call": [2],
129+
"no-useless-concat": [2],
130+
"no-var": [0],
131+
"no-void": [0],
132+
"no-with": [2],
133+
"object-shorthand": [0],
134+
"one-var": [ 2, "always" ],
135+
"operator-assignment": [2, "always"],
136+
"prefer-arrow-callback": [0],
137+
"prefer-const": [0],
138+
"prefer-reflect": [0],
139+
"prefer-rest-params": [0],
140+
"prefer-spread": [0],
141+
"prefer-template": [0],
142+
"quotes": [0],
143+
"radix": [2, "always"],
144+
"require-yield": [0],
145+
"sort-imports": [0],
146+
"sort-vars": [0],
147+
"strict": [2, "function"],
148+
"use-isnan": [2],
149+
"valid-typeof": [2],
150+
"valid-jsdoc": [2],
151+
"vars-on-top": [0],
152+
"wrap-iife": [2, "inside"],
153+
"wrap-regex": [0],
154+
"yoda": [0]
155+
}
156+
}

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.DS_Store
2+
3+
# PHPUnit
4+
/coverage
5+
/tests/wp-tests
6+
7+
# Composer
8+
/vendor
9+
composer.lock

.jscsrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"preset": "wordpress",
3+
"excludeFiles": [
4+
"**/*.min.js",
5+
"**/*.jsx",
6+
"**/node_modules/**",
7+
"**/vendor/**"
8+
]
9+
}

.jshintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/*.min.js
2+
**/node_modules/**
3+
**/vendor/**

.jshintrc

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"boss": true,
3+
"curly": true,
4+
"eqeqeq": true,
5+
"eqnull": true,
6+
"es3": true,
7+
"expr": true,
8+
"immed": true,
9+
"noarg": true,
10+
"nonbsp": true,
11+
"onevar": true,
12+
"quotmark": "single",
13+
"trailing": true,
14+
"undef": true,
15+
"unused": true,
16+
17+
"browser": true,
18+
19+
"globals": {
20+
"_": false,
21+
"Backbone": false,
22+
"jQuery": false,
23+
"JSON": false,
24+
"wp": false
25+
}
26+
}

.phpcs.ruleset.xml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="JWT Auth">
3+
<description>Custom ruleset for the JWT Auth plugin.</description>
4+
5+
<!-- For help in understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
6+
<!-- For help in using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
7+
8+
<!-- What to scan -->
9+
<file>.</file>
10+
<!-- Ignoring Files and Folders:
11+
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders -->
12+
<exclude-pattern>/vendor/*</exclude-pattern>
13+
<exclude-pattern>/wp-includes/rest-api/auth/jwt/*</exclude-pattern>
14+
<exclude-pattern>/tests/wp-tests/*</exclude-pattern>
15+
16+
<!-- How to scan -->
17+
<arg value="sp"/> <!-- Show sniff and progress -->
18+
<arg name="colors"/> <!-- Show results with colors -->
19+
<arg name="basepath" value="."/> <!-- Strip the file paths down to the relevant bit -->
20+
<arg name="parallel" value="8"/> <!-- Enables parallel processing when available for faster results. -->
21+
<arg name="extensions" value="php"/> <!-- Limit to PHP files -->
22+
23+
<!-- Rules: Check PHP version compatibility - see
24+
https://github.com/PHPCompatibility/PHPCompatibilityWP -->
25+
<rule ref="PHPCompatibilityWP"/>
26+
27+
<!-- For help in understanding this testVersion:
28+
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
29+
<config name="testVersion" value="5.3-"/>
30+
31+
<!-- Rules: WordPress Coding Standards - see
32+
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
33+
<rule ref="WordPress-Core"/>
34+
<rule ref="WordPress-Docs"/>
35+
<rule ref="WordPress-Extra"/>
36+
37+
<!-- For help in understanding these custom sniff properties:
38+
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
39+
<config name="minimum_supported_wp_version" value="4.4"/>
40+
41+
<rule ref="WordPress.WP.I18n">
42+
<properties>
43+
<property name="text_domain" type="array">
44+
<element value="jwt-auth"/>
45+
<element value="default"/>
46+
</property>
47+
</properties>
48+
</rule>
49+
50+
<!-- Don't complain about the access of super global var $_SERVER. -->
51+
<rule ref="WordPress">
52+
<exclude name="WordPress.VIP.SuperGlobalInputUsage.AccessDetected"/>
53+
</rule>
54+
</ruleset>

.travis.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Tell Travis CI we're using PHP
2+
language: php
3+
4+
# Opt to use Travis container-based environment.
5+
sudo: false
6+
7+
# Newer versions like trusty don't have PHP 5.2 or 5.3
8+
# https://blog.travis-ci.com/2017-07-11-trusty-as-default-linux-is-coming
9+
dist: precise
10+
11+
notifications:
12+
email:
13+
on_success: never
14+
on_failure: change
15+
16+
cache:
17+
directories:
18+
- node_modules
19+
- vendor
20+
- $HOME/phpunit-bin
21+
22+
php:
23+
- 5.3
24+
- 5.6
25+
- 7.0
26+
- 7.2
27+
28+
env:
29+
- WP_VERSION=latest WP_MULTISITE=0
30+
- WP_VERSION=latest WP_MULTISITE=1
31+
- WP_VERSION=trunk WP_MULTISITE=0
32+
- WP_VERSION=trunk WP_MULTISITE=1
33+
34+
install:
35+
- composer install
36+
- export DEV_LIB_PATH=vendor/xwp/wp-dev-lib/scripts
37+
- source "$DEV_LIB_PATH/travis.install.sh"
38+
39+
script:
40+
- source "$DEV_LIB_PATH/travis.script.sh"
41+
42+
after_script:
43+
- source "$DEV_LIB_PATH/travis.after_script.sh"

bin/install-tests.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
WP_VERSION=$1
4+
WP_TESTS_DIR=$2
5+
6+
function download {
7+
if command -v curl >/dev/null 2>&1; then
8+
curl -L -s "$1" > "$2"
9+
elif command -v wget >/dev/null 2>&1; then
10+
wget -n -O "$2" "$1"
11+
else
12+
echo ''
13+
return 1
14+
fi
15+
}
16+
17+
if [[ ${WP_VERSION} =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then
18+
WP_TESTS_TAG="tags/${WP_VERSION}"
19+
elif [[ ${WP_VERSION} == 'nightly' || ${WP_VERSION} == 'trunk' ]]; then
20+
WP_TESTS_TAG="trunk"
21+
else
22+
# http serves a single offer, whereas https serves multiple. we only want one
23+
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
24+
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
25+
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
26+
if [[ -z "$LATEST_VERSION" ]]; then
27+
echo "Latest WordPress version could not be found."
28+
exit 1
29+
fi
30+
WP_TESTS_TAG="tags/$LATEST_VERSION"
31+
fi
32+
33+
echo "Installing WordPress PHPUnit Test Suite into '${WP_TESTS_DIR}' ..."
34+
35+
rm -rf ${WP_TESTS_DIR}
36+
svn co -q https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/ ${WP_TESTS_DIR}

bin/phpunit.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# Usage: ./tests/bin.sh xdebug_on /srv/www/wordpress-default/public_html/wp-content/plugins/jwt-auth
3+
# Runs the PHPUnit tests with html coverage output in the VVV wordpress-default site.
4+
5+
set -e
6+
7+
xdebug=$1
8+
if [ -z "$xdebug" ]; then
9+
xdebug="xdebug_off"
10+
fi
11+
12+
path=$2
13+
if [ -z "$path" ]; then
14+
path="/srv/www/wordpress-default/public_html/wp-content/plugins/jwt-auth"
15+
fi
16+
17+
if [ $xdebug = "xdebug_on" ]; then
18+
COVERAGE="--coverage-html $path/coverage";
19+
fi
20+
21+
vagrant ssh -c "$xdebug && cd $path && WP_TESTS_DIR=tests/wp-tests/phpunit phpunit $COVERAGE"

0 commit comments

Comments
 (0)