Commit 1aa31a9b authored by Erick Hitter's avatar Erick Hitter

Merge branch 'fix/1-wp' into 'master'

Add tests for post-content manipulation

Closes #1

See merge request !10
parents e070f90c 20dc2f63
Pipeline #1187 passed with stages
in 11 minutes and 38 seconds
......@@ -3,16 +3,14 @@
**Donate link:** http://www.thinkoomph.com/plugins-modules/view-all-posts-pages/
**Tags:** view all, pages, paged, paged post, multipage, single view, single page, wp_link_pages, nextpage, next page, quicktag
**Requires at least:** 3.2.1
**Tested up to:** 5.1
**Stable tag:** 0.9.2
**Tested up to:** 5.2
**Stable tag:** 0.9.3
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
Provides a "view all" (single page) option for content paged using WordPress' <!--nextpage--> Quicktag (multipage posts).
## Description ##
**This plugin is not yet compatible with WordPress 5.2.**
Provides a "view all" (single page) option for posts, pages, and custom post types paged using WordPress' <a href="http://codex.wordpress.org/Write_Post_SubPanel#Quicktags" target="_blank"><code>&lt;!--nextpage--&gt;</code> Quicktag</a> (multipage posts).
Your theme must use `wp_link_pages()` to generate post page links, or you must use either the automatic or manual link capabilities provided in the plugin.
......@@ -27,10 +25,6 @@ Your theme must use `wp_link_pages()` to generate post page links, or you must u
## Frequently Asked Questions ##
### I upgraded to WordPress 5.2 and this plugin stopped working. ###
WordPress 5.2 updated the function that's used to retrieve post content, defeating this plugin's method of creating the view-all output. Progress towards a 5.2-compatible approach will be tracked at [https://git.ethitter.com/wp-plugins/view-all-posts-pages/issues/1](https://git.ethitter.com/wp-plugins/view-all-posts-pages/issues/1).
### Links don't work ###
First, navigate to Options > Permalinks in WP Admin, click *Save Changes*, and try again.
......@@ -51,6 +45,9 @@ This plugin is known to conflict with certain plugins, many pertaining to SEO an
## Changelog ##
### 0.9.3 ###
* Compatible with WordPress 5.2
### 0.9.2 ###
* Compatible with PHP 7.3
* Introduce PHPCS tests
......@@ -106,6 +103,9 @@ This plugin is known to conflict with certain plugins, many pertaining to SEO an
## Upgrade Notice ##
### 0.9.3 ###
Ensures compatibility with WordPress 5.2.
### 0.9.2 ###
Adds support for PHP 7.3 and fixes various PHPCS errors, neither of which should impact the plugin's functionality.
......
......@@ -2,10 +2,10 @@
# This file is distributed under the same license as the View All Posts Pages package.
msgid ""
msgstr ""
"Project-Id-Version: View All Posts Pages 0.9.2\n"
"Project-Id-Version: View All Posts Pages 0.9.3\n"
"Report-Msgid-Bugs-To: "
"https://wordpress.org/support/plugin/view-all-posts-pages\n"
"POT-Creation-Date: 2019-04-13 21:12:19+00:00\n"
"POT-Creation-Date: 2019-05-12 18:33:30+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
......
......@@ -3,16 +3,14 @@ Contributors: ethitter, thinkoomph
Donate link: http://www.thinkoomph.com/plugins-modules/view-all-posts-pages/
Tags: view all, pages, paged, paged post, multipage, single view, single page, wp_link_pages, nextpage, next page, quicktag
Requires at least: 3.2.1
Tested up to: 5.1
Stable tag: 0.9.2
Tested up to: 5.2
Stable tag: 0.9.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Provides a "view all" (single page) option for content paged using WordPress' &lt;!--nextpage--&gt; Quicktag (multipage posts).
== Description ==
**This plugin is not yet compatible with WordPress 5.2.**
Provides a "view all" (single page) option for posts, pages, and custom post types paged using WordPress' <a href="http://codex.wordpress.org/Write_Post_SubPanel#Quicktags" target="_blank"><code>&lt;!--nextpage--&gt;</code> Quicktag</a> (multipage posts).
Your theme must use `wp_link_pages()` to generate post page links, or you must use either the automatic or manual link capabilities provided in the plugin.
......@@ -27,10 +25,6 @@ Your theme must use `wp_link_pages()` to generate post page links, or you must u
== Frequently Asked Questions ==
= I upgraded to WordPress 5.2 and this plugin stopped working. =
WordPress 5.2 updated the function that's used to retrieve post content, defeating this plugin's method of creating the view-all output. Progress towards a 5.2-compatible approach will be tracked at [https://git.ethitter.com/wp-plugins/view-all-posts-pages/issues/1](https://git.ethitter.com/wp-plugins/view-all-posts-pages/issues/1).
= Links don't work =
First, navigate to Options > Permalinks in WP Admin, click *Save Changes*, and try again.
......@@ -51,6 +45,9 @@ This plugin is known to conflict with certain plugins, many pertaining to SEO an
== Changelog ==
= 0.9.3 =
* Compatible with WordPress 5.2
= 0.9.2 =
* Compatible with PHP 7.3
* Introduce PHPCS tests
......@@ -106,6 +103,9 @@ This plugin is known to conflict with certain plugins, many pertaining to SEO an
== Upgrade Notice ==
= 0.9.3 =
Ensures compatibility with WordPress 5.2.
= 0.9.2 =
Adds support for PHP 7.3 and fixes various PHPCS errors, neither of which should impact the plugin's functionality.
......
......@@ -23,7 +23,7 @@ require_once $_tests_dir . '/includes/functions.php';
* Manually load the plugin being tested.
*/
function _manually_load_plugin() {
require dirname( dirname( __FILE__ ) ) . '/view-all-posts-pages.php';
require dirname( __FILE__, 2 ) . '/view-all-posts-pages.php';
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
......
<?php
/**
* Class PostFilters
*
* @package View_All_Posts_Pages
*/
/**
* Content-filter test case.
*/
class PostFilters extends WP_UnitTestCase {
/**
* Text for each page of multipage post.
*
* @var array
*/
protected static $pages_content = [
1 => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec at neque sit amet massa pulvinar ullamcorper. Sed cursus, quam a tristique volutpat, diam justo cursus nunc, eu elementum sem orci ut ante. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras aliquet, diam sit amet tincidunt pulvinar, tortor neque accumsan dui, efficitur placerat justo nisl et justo. Pellentesque convallis dui nulla, vel finibus dui cursus quis. Sed semper nunc et euismod tristique. Aliquam tincidunt eget massa ac congue. Ut ipsum eros, dignissim ut eleifend eu, consectetur a eros. Proin in mattis dui.',
2 => 'Sed sed sapien et lectus aliquam tempor. Duis consequat sapien scelerisque metus pulvinar aliquam. Pellentesque vestibulum id justo vel egestas. Nullam a metus sed risus blandit egestas. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed scelerisque ipsum ante, quis iaculis nibh suscipit eget. Nulla facilisi. Nulla at lacus at mauris sodales varius et nec massa. Etiam in nisi commodo, semper velit vitae, condimentum nisl. Ut quis mauris non ipsum feugiat vehicula pulvinar vitae dui. Nulla facilisi.',
3 => 'Donec condimentum ipsum felis. Vivamus rhoncus mauris ac commodo hendrerit. Quisque ultrices nibh laoreet purus volutpat, ut congue purus suscipit. Sed eget lacus nec eros scelerisque volutpat. Fusce tristique quam eu risus porta, id vulputate dui maximus. Phasellus suscipit faucibus leo, imperdiet facilisis nisi. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sit amet velit eu felis rhoncus placerat vel rutrum ante. Donec luctus urna quis nulla porta vestibulum. Vivamus ac lacinia odio.',
];
/**
* Page break trigger.
*
* @var string
*/
protected static $page_break = "<!--nextpage-->";
/**
* Test post ID.
*
* @var int
*/
protected static $post_id;
/**
* Prepare data for tests.
*/
public function setUp(): void {
parent::setUp();
static::$post_id = $this->factory->post->create(
[
'post_title' => 'Pagination Test',
'post_status' => 'publish',
'post_date' => '2019-01-01 00:01:01',
'post_content' => implode( static::$page_break, static::$pages_content ),
]
);
}
/**
* Test retrieving page 1 content.
*/
public function test_view_page_1(): void {
query_posts(
[
'p' => static::$post_id,
]
);
$this->assertTrue( have_posts() );
while ( have_posts() ) {
the_post();
$this->assertEquals( static::$pages_content[1], get_the_content() );
}
}
/**
* Test retrieving page 2 content.
*/
public function test_view_page_2(): void {
query_posts(
[
'p' => static::$post_id,
'page' => 2,
]
);
$this->assertTrue( have_posts() );
while ( have_posts() ) {
the_post();
$this->assertEquals( static::$pages_content[2], get_the_content() );
}
}
/**
* Test retrieving page 3 content.
*/
public function test_view_page_3(): void {
query_posts(
[
'p' => static::$post_id,
'page' => 3,
]
);
$this->assertTrue( have_posts() );
while ( have_posts() ) {
the_post();
$this->assertEquals( static::$pages_content[3], get_the_content() );
}
}
/**
* Test retrieving "view all" contents.
*/
public function test_view_all(): void {
query_posts(
[
'p' => static::$post_id,
'view-all' => true,
]
);
$this->assertTrue( have_posts() );
while ( have_posts() ) {
the_post();
$content = get_the_content();
foreach ( static::$pages_content as $page => $text ) {
$this->assertContains( $text, $content, "Failed to assert that content contained page {$page}." );
}
}
}
}
<?php
/**
* Class SampleTest
*
* @package View_All_Posts_Pages
*/
/**
* Sample test case.
*/
class SampleTest extends WP_UnitTestCase {
/**
* A single example test.
*/
public function test_sample() {
// Replace this with some actual testing code.
$this->assertTrue( true );
}
}
......@@ -9,7 +9,7 @@
* Author URI: http://www.oomphinc.com/
* Text Domain: view_all_posts_pages
* Domain Path: /languages
* Version: 0.9.2
* Version: 0.9.3
*
* @package View_All_Posts_Pages
*
......@@ -762,7 +762,6 @@ class view_all_posts_pages { // phpcs:ignore PEAR.NamingConventions.ValidClassNa
endif;
}
}
view_all_posts_pages::get_instance();
/**
* Alias global variable used to hold instantiated plugin prior to singleton's introduction in version 0.7.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment