Skip to content

Commit ea26a50

Browse files
committed
Refactor to move the code to a src folder and add structure for tests
1 parent a859516 commit ea26a50

File tree

435 files changed

+9802
-4217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

435 files changed

+9802
-4217
lines changed

.env.testing

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
WP_ROOT_FOLDER="/Users/anderson/Volumes/wordpress_tests"
2+
TEST_SITE_WP_ADMIN_PATH="/wp-admin"
3+
TEST_SITE_DB_NAME="wp_test_site"
4+
TEST_SITE_DB_HOST="127.0.0.1:32881"
5+
TEST_SITE_DB_USER="root"
6+
TEST_SITE_DB_PASSWORD="root"
7+
TEST_SITE_TABLE_PREFIX="wp_"
8+
TEST_DB_NAME="wp_test_integration"
9+
TEST_DB_HOST="127.0.0.1:32881"
10+
TEST_DB_USER="root"
11+
TEST_DB_PASSWORD="root"
12+
TEST_TABLE_PREFIX="wp_"
13+
TEST_SITE_WP_URL="http://localhost:32880"
14+
TEST_SITE_WP_DOMAIN="localhost"
15+
TEST_SITE_ADMIN_EMAIL="[email protected]"
16+
TEST_SITE_ADMIN_USERNAME="admin"
17+
TEST_SITE_ADMIN_PASSWORD="admin"
18+
PUBLISHPRESS_API_URL="https://publishpress.com"

.env.testing.dist

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
WP_ROOT_FOLDER="/Users/anderson/Volumes/wordpress_tests"
2+
TEST_SITE_WP_ADMIN_PATH="/wp-admin"
3+
TEST_SITE_DB_NAME="wp_test_site"
4+
TEST_SITE_DB_HOST="127.0.0.1:32881"
5+
TEST_SITE_DB_USER="root"
6+
TEST_SITE_DB_PASSWORD="root"
7+
TEST_SITE_TABLE_PREFIX="wp_"
8+
TEST_DB_NAME="wp_test_integration"
9+
TEST_DB_HOST="127.0.0.1:32881"
10+
TEST_DB_USER="root"
11+
TEST_DB_PASSWORD="root"
12+
TEST_TABLE_PREFIX="wp_"
13+
TEST_SITE_WP_URL="http://localhost:32880"
14+
TEST_SITE_WP_DOMAIN="localhost"
15+
TEST_SITE_ADMIN_EMAIL="[email protected]"
16+
TEST_SITE_ADMIN_USERNAME="admin"
17+
TEST_SITE_ADMIN_PASSWORD="admin"
18+
PUBLISHPRESS_API_URL="https://publishpress.com"

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Thumbs.db
1313
*.sublime-workspace
1414

1515
# Ignores the "dev" composer file
16-
/src/vendor
16+
/vendor
1717
/packages
1818

1919
codeception.yml

bylines-functions.php

+7-102
Original file line numberDiff line numberDiff line change
@@ -5,114 +5,19 @@
55
* @copyright Copyright (C) 2018 PublishPress. All rights reserved.
66
* @license GPLv2 or later
77
* @since 1.0.7
8+
*
9+
* @deprecated 3.2.5-beta.8
810
*/
911

10-
if (!function_exists('get_bylines')) {
11-
/**
12-
* Get all bylines for a post.
13-
*
14-
* @param WP_Post|null $post Post to fetch bylines for. Defaults to global post.
15-
*
16-
* @return array Array of Byline objects, a single WP_User object, or empty.
17-
*/
18-
function get_bylines($post = null)
19-
{
20-
return get_multiple_authors($post);
21-
}
22-
}
23-
24-
if (!function_exists('the_bylines')) {
25-
/**
26-
* Renders the bylines display names, without links to their posts.
27-
*
28-
* Equivalent to the_author() template tag.
29-
*
30-
* @return string
31-
*/
32-
function the_bylines()
33-
{
34-
return the_authors();
35-
}
36-
}
37-
38-
if (!function_exists('get_the_bylines')) {
39-
/**
40-
* Gets the bylines display names, without links to their posts.
41-
*
42-
* Equivalent to get_the_author() template tag.
43-
*
44-
* @return string
45-
*/
46-
function get_the_bylines()
47-
{
48-
return get_the_authors();
49-
}
50-
}
51-
52-
if (!function_exists('the_bylines_posts_links')) {
53-
/**
54-
* Renders the bylines display names, with links to their posts.
55-
*
56-
* Equivalent to the_author_posts_link() template tag.
57-
*
58-
* @return string
59-
*/
60-
function the_bylines_posts_links()
61-
{
62-
return the_authors_posts_links();
63-
}
64-
}
65-
66-
if (!function_exists('get_the_bylines_posts_links')) {
67-
/**
68-
* Renders the bylines display names, with links to their posts.
69-
*
70-
* @return string
71-
*/
72-
function get_the_bylines_posts_links()
73-
{
74-
return get_the_authors_posts_links();
75-
}
76-
}
12+
require_once __DIR__ . '/src/functions/bylines-functions.php';
7713

78-
if (!function_exists('the_bylines_links')) {
14+
if (!class_exists('PublishPress_Authors_Bylines_Functions')) {
7915
/**
80-
* Renders the bylines display names, with their website link if it exists.
81-
*
82-
* Equivalent to the_author_link() template tag.
83-
*
84-
* @return string
85-
*/
86-
function the_bylines_links()
87-
{
88-
return the_authors_links();
89-
}
90-
}
91-
92-
if (!function_exists('get_the_bylines_links')) {
93-
/**
94-
* Renders the bylines display names, with their website link if it exists.
95-
*
96-
* @return string
97-
*/
98-
function get_the_bylines_links()
99-
{
100-
return get_the_authors_links();
101-
}
102-
}
103-
104-
if (!function_exists('bylines_render')) {
105-
/**
106-
* Display one or more bylines, according to arguments provided.
107-
*
108-
* @param array $bylines Set of bylines to display.
109-
* @param callable $render_callback Callback to return rendered byline.
110-
* @param array $args Arguments to affect display.
16+
* Class PublishPress_Authors_Bylines_Functions
11117
*
112-
* @return string
18+
* @deprecated 3.2.5-beta.8
11319
*/
114-
function bylines_render($bylines, $render_callback, $args = [])
20+
class PublishPress_Authors_Bylines_Functions
11521
{
116-
return authors_render($bylines, $render_callback, $args);
11722
}
11823
}

coauthors-functions.php

+10-126
Original file line numberDiff line numberDiff line change
@@ -5,135 +5,19 @@
55
* @copyright Copyright (C) 2018 PublishPress. All rights reserved.
66
* @license GPLv2 or later
77
* @since 1.0.7
8+
*
9+
* @deprecated 3.2.5-beta.8
810
*/
911

10-
if (!function_exists('get_coauthors')) {
11-
function get_coauthors($post_id = 0)
12-
{
13-
return get_multiple_authors($post_id);
14-
}
15-
}
16-
17-
if (!function_exists('is_coauthors_for_post')) {
18-
function is_coauthors_for_post($user, $post_id = 0)
19-
{
20-
return is_multiple_author_for_post($user, $post_id);
21-
}
22-
}
23-
24-
if (!class_exists('Couthors_iterator')) {
25-
class Couthors_iterator extends Multiple_authors_iterator
26-
{
27-
28-
}
29-
}
30-
31-
if (!function_exists('coauthors__echo')) {
32-
function coauthors__echo($tag, $type = 'tag', $separators = [], $tag_args = null, $echo = true)
33-
{
34-
return multiple_authors__echo($tag, $type, $separators, $tag_args, $echo);
35-
}
36-
}
37-
38-
if (!function_exists('coauthors')) {
39-
function coauthors($between = null, $betweenLast = null, $before = null, $after = null, $echo = true)
40-
{
41-
return multiple_authors($between, $betweenLast, $before, $after, $echo);
42-
}
43-
}
44-
45-
if (!function_exists('coauthors_posts_links')) {
46-
function coauthors_posts_links(
47-
$between = null,
48-
$betweenLast = null,
49-
$before = null,
50-
$after = null,
51-
$echo = true
52-
) {
53-
return multiple_authors_posts_links($between, $betweenLast, $before, $after, $echo);
54-
}
55-
}
56-
57-
if (!function_exists('coauthors_posts_links_single')) {
58-
function coauthors_posts_links_single($author)
59-
{
60-
return multiple_authors_posts_links_single($author);
61-
}
62-
}
63-
64-
if (!function_exists('coauthors_firstnames')) {
65-
function coauthors_firstnames($between = null, $betweenLast = null, $before = null, $after = null, $echo = true)
66-
{
67-
return multiple_authors_firstnames($between, $betweenLast, $before, $after, $echo);
68-
}
69-
}
70-
71-
if (!function_exists('coauthors_lastnames')) {
72-
function coauthors_lastnames($between = null, $betweenLast = null, $before = null, $after = null, $echo = true)
73-
{
74-
return multiple_authors_lastnames($between, $betweenLast, $before, $after, $echo);
75-
}
76-
}
77-
78-
if (!function_exists('coauthors_nicknames')) {
79-
function coauthors_nicknames($between = null, $betweenLast = null, $before = null, $after = null, $echo = true)
80-
{
81-
return multiple_authors_nicknames($between, $betweenLast, $before, $after, $echo);
82-
}
83-
}
84-
85-
if (!function_exists('coauthors_links')) {
86-
function coauthors_links($between = null, $betweenLast = null, $before = null, $after = null, $echo = true)
87-
{
88-
return multiple_authors_links($between, $betweenLast, $before, $after, $echo);
89-
}
90-
}
91-
92-
if (!function_exists('coauthors_emails')) {
93-
function coauthors_emails($between = null, $betweenLast = null, $before = null, $after = null, $echo = true)
94-
{
95-
return multiple_authors_emails($between, $betweenLast, $before, $after, $echo);
96-
}
97-
}
98-
99-
if (!function_exists('coauthors_links_single')) {
100-
function coauthors_links_single($author)
101-
{
102-
return multiple_authors_links_single($author);
103-
}
104-
}
105-
106-
if (!function_exists('coauthors_ids')) {
107-
function coauthors_ids($between = null, $betweenLast = null, $before = null, $after = null, $echo = true)
108-
{
109-
return multiple_authors_ids($between, $betweenLast, $before, $after, $echo);
110-
}
111-
}
112-
113-
if (!function_exists('get_the_coauthor_meta')) {
114-
function get_the_coauthor_meta($field)
115-
{
116-
return get_the_multiple_author_meta($field);
117-
}
118-
}
119-
120-
if (!function_exists('the_coauthor_meta')) {
121-
function the_coauthor_meta($field, $user_id = 0)
122-
{
123-
the_multiple_author_meta($field, $user_id);
124-
}
125-
}
126-
127-
if (!function_exists('coauthors_wp_list_authors')) {
128-
function coauthors_wp_list_authors($args)
129-
{
130-
return multiple_authors_wp_list_authors($args);
131-
}
132-
}
12+
require_once __DIR__ . '/src/functions/coauthors-functions.php';
13313

134-
if (!function_exists('coauthors_get_avatar')) {
135-
function coauthors_get_avatar($coauthor, $size = 32, $default = '', $alt = false)
14+
if (!class_exists('PublishPress_Authors_CoAuthors_Functions')) {
15+
/**
16+
* Class PublishPress_Authors_CoAuthors_Functions
17+
*
18+
* @deprecated 3.2.5-beta.8
19+
*/
20+
class PublishPress_Authors_CoAuthors_Functions
13621
{
137-
return multiple_authors_get_avatar($coauthor, $size, $default, $alt);
13822
}
13923
}

codeception.dist.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
paths:
2+
tests: tests
3+
output: tests/_output
4+
data: tests/_data
5+
support: tests/_support
6+
envs: tests/_envs
7+
actor_suffix: Tester
8+
extensions:
9+
enabled:
10+
- Codeception\Extension\RunFailed
11+
- tad\WPBrowser\Extension\Copier
12+
commands:
13+
- Codeception\Command\GenerateWPUnit
14+
- Codeception\Command\GenerateWPRestApi
15+
- Codeception\Command\GenerateWPRestController
16+
- Codeception\Command\GenerateWPRestPostTypeController
17+
- Codeception\Command\GenerateWPAjax
18+
- Codeception\Command\GenerateWPCanonical
19+
- Codeception\Command\GenerateWPXMLRPC
20+
config:
21+
tad\WPBrowser\Extension\Copier:
22+
files:
23+
src: "%WP_ROOT_FOLDER%/wp-content/plugins/publishpress-authors/src"
24+
publishpress-authors.php: "%WP_ROOT_FOLDER%/wp-content/plugins/publishpress-authors/publishpress-authors.php"
25+
26+
params:
27+
- .env.testing
28+
settings:
29+
shuffle: true

composer.json

+10-6
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
},
2626
"autoload": {
2727
"psr-4": {
28-
"MultipleAuthors\\": "core/",
29-
"PPAuthors\\YoastSEO\\": "modules/yoast-seo-integration/src/"
28+
"MultipleAuthors\\": "src/core/",
29+
"PPAuthors\\YoastSEO\\": "src/modules/yoast-seo-integration/src/"
3030
}
3131
},
3232
"minimum-stability": "stable",
@@ -37,9 +37,13 @@
3737
"publishpress/wordpress-version-notices": "^1"
3838
},
3939
"require-dev": {
40-
"phpunit/phpunit": "^6",
41-
"behat/behat": "~3",
42-
"phing/phing": "^2.16",
43-
"alledia/wordpress-plugin-builder": "^2.5"
40+
"lucatume/wp-browser": "^2.4",
41+
"codeception/module-asserts": "^1.2",
42+
"codeception/module-phpbrowser": "^1.0",
43+
"codeception/module-webdriver": "^1.0",
44+
"codeception/module-db": "^1.0",
45+
"codeception/module-filesystem": "^1.0",
46+
"codeception/module-cli": "^1.0",
47+
"codeception/util-universalframework": "^1.0"
4448
}
4549
}

0 commit comments

Comments
 (0)