Skip to content

Commit e98dd74

Browse files
authored
Code Coverage (#21)
* Coverage added * phpunit whitelist * XDebug enabled * Add badge * Move entrypoint to main.php * codecov commit status
1 parent 6808a64 commit e98dd74

File tree

6 files changed

+38
-16
lines changed

6 files changed

+38
-16
lines changed

.codecov.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
comment:
2+
layout: "diff, flags, files"
3+
behavior: new
4+
require_changes: false

.travis.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ matrix:
4040

4141
before_script:
4242
- export PATH="$HOME/.composer/vendor/bin:$PATH"
43-
- |
44-
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
45-
phpenv config-rm xdebug.ini
46-
else
47-
echo "xdebug.ini does not exist"
48-
fi
43+
#- |
44+
# if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
45+
# phpenv config-rm xdebug.ini
46+
# else
47+
# echo "xdebug.ini does not exist"
48+
# fi
4949
- |
5050
if [[ ! -z "$WP_VERSION" ]] ; then
5151
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
@@ -60,10 +60,13 @@ before_script:
6060
script:
6161
- |
6262
if [[ ! -z "$WP_VERSION" ]] ; then
63-
phpunit
63+
phpunit --coverage-clover clover.xml
6464
WP_MULTISITE=1 phpunit
6565
fi
6666
- |
6767
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
6868
phpcs
6969
fi
70+
71+
after_success:
72+
- bash <(curl -s https://codecov.io/bash)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Plugin allows to use post's custom fields values in permalink structure by adding %field_fieldname%, for posts, pages and custom post types.
44

55
[![Build Status](https://travis-ci.org/athlan/wordpress-custom-fields-permalink-plugin.svg?branch=master)](https://travis-ci.org/athlan/wordpress-custom-fields-permalink-plugin)
6+
[![codecov](https://codecov.io/gh/athlan/wordpress-custom-fields-permalink-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/athlan/wordpress-custom-fields-permalink-plugin)
67

78
---
89

includes/main.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* Register hooks in WordPress
4+
*
5+
* @package WordPress_Custom_Fields_Permalink
6+
*/
7+
8+
// Require main class.
9+
require 'class-customfieldspermalink.php';
10+
11+
add_filter( 'pre_post_link', array( 'CustomFieldsPermalink', 'link_post' ), 100, 3 );
12+
add_filter( 'post_type_link', array( 'CustomFieldsPermalink', 'link_post_type' ), 100, 4 );
13+
add_filter( 'rewrite_rules_array', array( 'CustomFieldsPermalink', 'rewrite_rules_array_filter' ) );
14+
add_filter( 'query_vars', array( 'CustomFieldsPermalink', 'register_extra_query_vars' ), 10, 1 );
15+
add_filter( 'request', array( 'CustomFieldsPermalink', 'process_request' ), 10, 1 );
16+
add_filter( 'pre_handle_404', array( 'CustomFieldsPermalink', 'pre_handle_404' ), 10, 2 );

phpunit.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@
1212
<directory prefix="" suffix=".php">./test/suites/</directory>
1313
</testsuite>
1414
</testsuites>
15+
<filter>
16+
<whitelist processUncoveredFilesFromWhitelist="true">
17+
<directory suffix=".php">./includes/</directory>
18+
</whitelist>
19+
</filter>
1520
</phpunit>

wordpress-custom-fields-permalink-plugin.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,5 @@
1313
* Author URI: http://athlan.pl/
1414
*/
1515

16-
// Require main class.
17-
require 'includes/class-customfieldspermalink.php';
18-
19-
add_filter( 'pre_post_link', array( 'CustomFieldsPermalink', 'link_post' ), 100, 3 );
20-
add_filter( 'post_type_link', array( 'CustomFieldsPermalink', 'link_post_type' ), 100, 4 );
21-
add_filter( 'rewrite_rules_array', array( 'CustomFieldsPermalink', 'rewrite_rules_array_filter' ) );
22-
add_filter( 'query_vars', array( 'CustomFieldsPermalink', 'register_extra_query_vars' ), 10, 1 );
23-
add_filter( 'request', array( 'CustomFieldsPermalink', 'process_request' ), 10, 1 );
24-
add_filter( 'pre_handle_404', array( 'CustomFieldsPermalink', 'pre_handle_404' ), 10, 2 );
16+
// Require main entry point.
17+
require 'includes/main.php';

0 commit comments

Comments
 (0)