From de2b2f76bca2f12245408d89a021ede811bb8504 Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Sun, 14 Apr 2019 17:05:33 -0700 Subject: [PATCH] Add tests for permalink filters --- tests/test-permalink-filters.php | 69 ++++++++++++++++++++++++++++++++ tests/test-sample.php | 20 --------- 2 files changed, 69 insertions(+), 20 deletions(-) create mode 100755 tests/test-permalink-filters.php delete mode 100755 tests/test-sample.php diff --git a/tests/test-permalink-filters.php b/tests/test-permalink-filters.php new file mode 100755 index 0000000..2b2f4cf --- /dev/null +++ b/tests/test-permalink-filters.php @@ -0,0 +1,69 @@ +<?php +/** + * Class PermalinkFilters + * + * @package External_Permalinks_Redux + */ + +/** + * Test permalink filters + */ +class PermalinkFilters extends WP_UnitTestCase { + /** + * Redirect destination. + */ + const DESTINATION = 'https://w.org/'; + + /** + * Test post ID. + * + * @var int + */ + protected $post_id; + + /** + * Test page ID. + * + * @var int + */ + protected $page_id; + + /** + * Create some objects with redirects. + */ + public function setUp() { + parent::setUp(); + + $plugin = external_permalinks_redux::get_instance(); + + $this->post_id = $this->factory->post->create( + [ + 'post_type' => 'post', + ] + ); + + update_post_meta( $this->post_id, $plugin->meta_key_target, static::DESTINATION ); + + $this->page_id = $this->factory->post->create( + [ + 'post_type' => 'page', + ] + ); + + update_post_meta( $this->page_id, $plugin->meta_key_target, static::DESTINATION ); + } + + /** + * Test post permalink filter. + */ + public function test_post() { + $this->assertEquals( static::DESTINATION, get_permalink( $this->post_id ) ); + } + + /** + * Test page link filter. + */ + public function test_page() { + $this->assertEquals( static::DESTINATION, get_page_link( $this->page_id ) ); + } +} diff --git a/tests/test-sample.php b/tests/test-sample.php deleted file mode 100755 index 5df9d59..0000000 --- a/tests/test-sample.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php -/** - * Class SampleTest - * - * @package External_Permalinks_Redux - */ - -/** - * 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 ); - } -} -- GitLab