Skip to content

Commit 79ee528

Browse files
westonruterpierlon
andcommitted
Fix PHPUnit tests in WordPress 5.6-beta1 (#5531)
Co-authored-by: Pierre Gordon <[email protected]>
1 parent de663f8 commit 79ee528

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

tests/php/src/PluginRegistryTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
use AmpProject\AmpWP\Infrastructure\Service;
66
use AmpProject\AmpWP\PluginRegistry;
77
use AmpProject\AmpWP\Tests\Helpers\MockPluginEnvironment;
8+
use AmpProject\AmpWP\Tests\Helpers\PrivateAccess;
89
use PHPUnit\Framework\TestCase;
910

1011
final class PluginRegistryTest extends TestCase {
12+
use PrivateAccess;
1113

1214
private function populate_plugins() {
1315
wp_cache_set( 'plugins', [ '' => MockPluginEnvironment::PLUGINS_DATA ], 'plugins' );
@@ -21,6 +23,18 @@ public function test_it_can_be_initialized() {
2123
$this->assertInstanceOf( Service::class, $plugin_registry );
2224
}
2325

26+
/** @covers PluginRegistry::get_plugin_dir() */
27+
public function test_get_plugin_dir() {
28+
$plugin_registry = new PluginRegistry();
29+
30+
$plugin_directory = $plugin_registry->get_plugin_dir();
31+
$this->assertEquals( WP_CONTENT_DIR . '/plugins', $plugin_directory );
32+
33+
$this->set_private_property( $plugin_registry, 'plugin_folder', 'amp/tests/php/data/plugins' );
34+
$plugin_directory = $plugin_registry->get_plugin_dir();
35+
$this->assertEquals( WP_CONTENT_DIR . '/plugins/amp/tests/php/data/plugins', $plugin_directory );
36+
}
37+
2438
/** @covers PluginRegistry::get_plugin_slug_from_file() */
2539
public function test_get_plugin_slug_from_file() {
2640
$plugin_registry = new PluginRegistry();

tests/php/test-amp-facebook-embed-handler.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ public function get_scripts_data() {
9595
* @param array $expected Expected scripts.
9696
*/
9797
public function test__get_scripts( $source, $expected ) {
98+
if ( self::is_external_http_test_suite() ) {
99+
$this->markTestSkipped( 'Endpoint is gone.' );
100+
}
101+
98102
$embed = new AMP_Facebook_Embed_Handler();
99103
$embed->register_embed();
100104

101105
$filtered_content = apply_filters( 'the_content', $source );
102106

103-
if ( self::is_external_http_test_suite() && "<p>$source</p>" === trim( $filtered_content ) ) {
104-
$this->markTestSkipped( 'Endpoint is down.' );
105-
}
106-
107107
$dom = AMP_DOM_Utils::get_dom_from_content( $filtered_content );
108108
$embed->sanitize_raw_embeds( $dom );
109109

@@ -280,15 +280,15 @@ public function get_raw_embed_dataset() {
280280
* @covers AMP_Facebook_Embed_Handler::sanitize_raw_embeds()
281281
*/
282282
public function test__raw_embed_sanitizer( $source, $expected ) {
283+
if ( self::is_external_http_test_suite() ) {
284+
$this->markTestSkipped( 'Endpoint is gone.' );
285+
}
286+
283287
$embed = new AMP_Facebook_Embed_Handler();
284288
$embed->register_embed();
285289

286290
$filtered_content = apply_filters( 'the_content', $source );
287291

288-
if ( self::is_external_http_test_suite() && "<p>$source</p>" === trim( $filtered_content ) ) {
289-
$this->markTestSkipped( 'Endpoint is down.' );
290-
}
291-
292292
$dom = AMP_DOM_Utils::get_dom_from_content( $filtered_content );
293293
$embed->sanitize_raw_embeds( $dom );
294294

0 commit comments

Comments
 (0)