Skip to content

Commit 1b0ace9

Browse files
authored
Fix test_prevent_empty_post_meta to work in isolation (#2628)
1 parent 7ee18f5 commit 1b0ace9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/phpunit/tests/includes/class-test-post-types.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Activitypub\Tests;
99

10-
use Activitypub\Activitypub;
1110
use Activitypub\Post_Types;
1211

1312
/**
@@ -20,9 +19,9 @@ class Test_Post_Types extends \WP_UnitTestCase {
2019
/**
2120
* Set up test environment.
2221
*/
23-
public function setUp(): void {
24-
parent::setUp();
25-
Activitypub::init();
22+
public function set_up(): void {
23+
parent::set_up();
24+
Post_Types::init();
2625
}
2726

2827
/**
@@ -33,12 +32,15 @@ public function setUp(): void {
3332
public function test_prevent_empty_post_meta() {
3433
$post_id = self::factory()->post->create( array( 'post_author' => 1 ) );
3534

35+
// Storing the default value should be prevented.
3636
\update_post_meta( $post_id, 'activitypub_max_image_attachments', ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS );
37-
$this->assertEmpty( \get_post_meta( $post_id, 'activitypub_max_image_attachments', true ) );
38-
\delete_post_meta( $post_id, 'activitypub_max_image_attachments' );
37+
$this->assertFalse( \metadata_exists( 'post', $post_id, 'activitypub_max_image_attachments' ) );
3938

39+
// Storing a non-default value should work.
4040
\update_post_meta( $post_id, 'activitypub_max_image_attachments', ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS + 3 );
41+
$this->assertTrue( \metadata_exists( 'post', $post_id, 'activitypub_max_image_attachments' ) );
4142
$this->assertEquals( ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS + 3, \get_post_meta( $post_id, 'activitypub_max_image_attachments', true ) );
43+
4244
\delete_post_meta( $post_id, 'activitypub_max_image_attachments' );
4345
}
4446
}

0 commit comments

Comments
 (0)