Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauteri committed Apr 25, 2024
1 parent 3f8634a commit 9f45247
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 45 deletions.
6 changes: 3 additions & 3 deletions includes/core/classes/class-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ protected function localize( int $post_id ): array {
$event_details = array(
'currentUser' => $event->rsvp->get( get_current_user_id() ),
'dateTime' => $event->get_datetime(),
'enableAnonymousRsvp' => (bool) get_post_meta( $post_id, 'enable_anonymous_rsvp', true ),
'enableInitialDecline' => (bool) get_post_meta( $post_id, 'enable_initial_decline', true ),
'maxGuestLimit' => (int) get_post_meta( $post_id, 'max_guest_limit', true ),
'enableAnonymousRsvp' => (bool) get_post_meta( $post_id, 'gatherpress_enable_anonymous_rsvp', true ),
'enableInitialDecline' => (bool) get_post_meta( $post_id, 'gatherpress_enable_initial_decline', true ),
'maxGuestLimit' => (int) get_post_meta( $post_id, 'gatherpress_max_guest_limit', true ),
'hasEventPast' => $event->has_event_past(),
'postId' => $post_id,
'responses' => $event->rsvp->responses(),
Expand Down
8 changes: 4 additions & 4 deletions includes/core/classes/class-event-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function register_post_type(): void {
*/
public function register_post_meta(): void {
$post_meta = array(
'max_guest_limit' => array(
'gatherpress_max_guest_limit' => array(
'auth_callback' => function () {
return current_user_can( 'edit_posts' );
},
Expand All @@ -165,7 +165,7 @@ public function register_post_meta(): void {
'single' => true,
'type' => 'number',
),
'enable_anonymous_rsvp' => array(
'gatherpress_enable_anonymous_rsvp' => array(
'auth_callback' => function () {
return current_user_can( 'edit_posts' );
},
Expand All @@ -174,7 +174,7 @@ public function register_post_meta(): void {
'single' => true,
'type' => 'boolean',
),
'enable_initial_decline' => array(
'gatherpress_enable_initial_decline' => array(
'auth_callback' => function () {
return current_user_can( 'edit_posts' );
},
Expand All @@ -183,7 +183,7 @@ public function register_post_meta(): void {
'single' => true,
'type' => 'boolean',
),
'online_event_link' => array(
'gatherpress_online_event_link' => array(
'auth_callback' => function () {
return current_user_can( 'edit_posts' );
},
Expand Down
4 changes: 2 additions & 2 deletions includes/core/classes/class-event.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public function get_venue_information(): array {
}

if ( is_a( $venue, 'WP_Post' ) ) {
$venue_meta = json_decode( get_post_meta( $venue->ID, 'venue_information', true ) );
$venue_meta = json_decode( get_post_meta( $venue->ID, 'gatherpress_venue_information', true ) );
$venue_information['full_address'] = $venue_meta->fullAddress ?? ''; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
$venue_information['phone_number'] = $venue_meta->phoneNumber ?? ''; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
$venue_information['website'] = $venue_meta->website ?? '';
Expand Down Expand Up @@ -699,7 +699,7 @@ function ( $key ) {
* @return string The online event link if all conditions are met; otherwise, an empty string.
*/
public function maybe_get_online_event_link(): string {
$event_link = (string) get_post_meta( $this->event->ID, 'online_event_link', true );
$event_link = (string) get_post_meta( $this->event->ID, 'gatherpress_online_event_link', true );

/**
* Filters whether to force the display of the online event link.
Expand Down
4 changes: 2 additions & 2 deletions includes/core/classes/class-rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ static function ( $slug ): string {
'featured_image' => get_the_post_thumbnail( $post_id, 'medium' ),
'featured_image_large' => get_the_post_thumbnail( $post_id, 'large' ),
'featured_image_thumbnail' => get_the_post_thumbnail( $post_id, 'thumbnail' ),
'enable_anonymous_rsvp' => (bool) get_post_meta( $post_id, 'enable_anonymous_rsvp', true ),
'enable_initial_decline' => (bool) get_post_meta( $post_id, 'enable_initial_decline', true ),
'enable_anonymous_rsvp' => (bool) get_post_meta( $post_id, 'gatherpress_enable_anonymous_rsvp', true ),
'enable_initial_decline' => (bool) get_post_meta( $post_id, 'gatherpress_enable_initial_decline', true ),
'responses' => ( $event->rsvp ) ? $event->rsvp->responses() : array(),
'current_user' => ( $event->rsvp && $event->rsvp->get( get_current_user_id() ) )
? $event->rsvp->get( get_current_user_id() )
Expand Down
2 changes: 1 addition & 1 deletion includes/core/classes/class-rsvp.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function get( int $user_id ): array {
public function save( int $user_id, string $status, int $anonymous = 0, int $guests = 0 ): array {
global $wpdb;

$max_guest_limit = intval( get_post_meta( $this->event->ID, 'max_guest_limit', true ) );
$max_guest_limit = intval( get_post_meta( $this->event->ID, 'gatherpress_max_guest_limit', true ) );

if ( $max_guest_limit < $guests ) {
$guests = $max_guest_limit;
Expand Down
4 changes: 2 additions & 2 deletions includes/core/classes/class-venue.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function register_post_type(): void {
*/
public function register_post_meta(): void {
$post_meta = array(
'venue_information' => array(
'gatherpress_venue_information' => array(
'auth_callback' => static function () {
return current_user_can( 'edit_posts' ); // @codeCoverageIgnore
},
Expand Down Expand Up @@ -414,7 +414,7 @@ public function get_venue_meta( int $post_id, string $post_type ): array {
$venue_meta['name'] = get_the_title( $venue_post );
$venue_meta = array_merge(
$venue_meta,
(array) json_decode( get_post_meta( $venue_post->ID, 'venue_information', true ) )
(array) json_decode( get_post_meta( $venue_post->ID, 'gatherpress_venue_information', true ) )
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/blocks/online-event/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Edit = ({ isSelected }) => {
const onlineEventLink = useSelect(
(select) =>
select('core/editor')?.getEditedPostAttribute('meta')
?.online_event_link
?.gatherpress_online_event_link
);

return (
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/venue/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ const Edit = ({ attributes, setAttributes, isSelected }) => {
const onlineEventLink = useSelect(
(select) =>
select('core/editor')?.getEditedPostAttribute('meta')
?.online_event_link
?.gatherpress_online_event_link
);

let { mapShow } = attributes;

let venueInformationMetaData = useSelect(
(select) =>
select('core/editor')?.getEditedPostAttribute('meta')
?.venue_information
?.gatherpress_venue_information
);

if (venueInformationMetaData) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/AnonymousRsvp.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const AnonymousRsvp = () => {

let defaultAnonymousRsvp = useSelect((select) => {
return select('core/editor').getEditedPostAttribute('meta')
.enable_anonymous_rsvp;
.gatherpress_enable_anonymous_rsvp;
}, []);

if (isNewEvent) {
Expand All @@ -40,7 +40,7 @@ const AnonymousRsvp = () => {

const updateAnonymousRsvp = useCallback(
(value) => {
const meta = { enable_anonymous_rsvp: Number(value) };
const meta = { gatherpress_enable_anonymous_rsvp: Number(value) };

setAnonymousRsvp(value);
editPost({ meta });
Expand Down
4 changes: 2 additions & 2 deletions src/components/EventItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ const EventItem = (props) => {
postId={event.ID}
currentUser={event.current_user}
type={type}
enableAnonymousRsvp={event.enable_anonymous_rsvp}
enableInitialDecline={event.enable_initial_decline}
enableAnonymousRsvp={event.gatherpress_enable_anonymous_rsvp}

Check failure on line 110 in src/components/EventItem.js

View workflow job for this annotation

GitHub Actions / JavaScript Coding Standards

Replace `event.gatherpress_enable_anonymous_rsvp` with `⏎↹↹↹↹↹↹↹event.gatherpress_enable_anonymous_rsvp⏎↹↹↹↹↹↹`
enableInitialDecline={event.gatherpress_enable_initial_decline}

Check failure on line 111 in src/components/EventItem.js

View workflow job for this annotation

GitHub Actions / JavaScript Coding Standards

Replace `event.gatherpress_enable_initial_decline` with `⏎↹↹↹↹↹↹↹event.gatherpress_enable_initial_decline⏎↹↹↹↹↹↹`
/>
)}

Expand Down
4 changes: 2 additions & 2 deletions src/components/GuestLimit.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const GuestLimit = () => {

let defaultGuestLimit = useSelect((select) => {
return select('core/editor').getEditedPostAttribute('meta')
.max_guest_limit;
.gatherpress_max_guest_limit;
}, []);

if (isNewEvent) {
Expand All @@ -47,7 +47,7 @@ const GuestLimit = () => {

const updateGuestLimit = useCallback(
(value) => {
const meta = { max_guest_limit: Number(value) };
const meta = { gatherpress_max_guest_limit: Number(value) };

setGuestLimit(value);
editPost({ meta });
Expand Down
4 changes: 2 additions & 2 deletions src/components/InitialDecline.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const InitialDecline = () => {

let defaultInitialDecline = useSelect((select) => {
return select('core/editor').getEditedPostAttribute('meta')
.enable_initial_decline;
.gatherpress_enable_initial_decline;
}, []);

if (isNewEvent) {
Expand All @@ -40,7 +40,7 @@ const InitialDecline = () => {

const updateInitialDecline = useCallback(
(value) => {
const meta = { enable_initial_decline: Number(value) };
const meta = { gatherpress_enable_initial_decline: Number(value) };

setInitialDecline(value);
editPost({ meta });
Expand Down
4 changes: 2 additions & 2 deletions src/components/OnlineEventLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ const OnlineEventLink = () => {
const onlineEventLinkMetaData = useSelect(
(select) =>
select('core/editor').getEditedPostAttribute('meta')
.online_event_link
.gatherpress_online_event_link
);
const [onlineEventLink, setOnlineEventLink] = useState(
onlineEventLinkMetaData
);
const updateEventLink = (value) => {
const meta = { online_event_link: value };
const meta = { gatherpress_online_event_link: value };

editPost({ meta });
setOnlineEventLink(value);
Expand Down
4 changes: 2 additions & 2 deletions src/components/VenueInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ const VenueInformation = () => {
...venueInformationMetaData,
[key]: value,
});
const meta = { venue_information: payload };
const meta = { gatherpress_venue_information: payload };

editPost({ meta });
};

let venueInformationMetaData = useSelect(
(select) =>
select('core/editor').getEditedPostAttribute('meta')
.venue_information
.gatherpress_venue_information
);

if (venueInformationMetaData) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/VenueSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const VenueSelector = () => {
let venueInformation = {};

if (venueSlug && Array.isArray(venuePost)) {
const jsonString = venuePost[0]?.meta?.venue_information ?? '{}';
const jsonString = venuePost[0]?.meta?.gatherpress_venue_information ?? '{}';

Check failure on line 66 in src/components/VenueSelector.js

View workflow job for this annotation

GitHub Actions / JavaScript Coding Standards

Replace `·` with `⏎↹↹↹↹`

if (jsonString) {
venueInformation = JSON.parse(jsonString);
Expand Down
16 changes: 8 additions & 8 deletions test/unit/php/includes/core/classes/class-test-event-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,22 @@ public function test_register_post_type(): void {
public function test_register_post_meta(): void {
$instance = Event_Setup::get_instance();

unregister_post_meta( Event::POST_TYPE, 'online_event_link' );
unregister_post_meta( Event::POST_TYPE, 'enable_anonymous_rsvp' );
unregister_post_meta( Event::POST_TYPE, 'gatherpress_online_event_link' );
unregister_post_meta( Event::POST_TYPE, 'gatherpress_enable_anonymous_rsvp' );

$meta = get_registered_meta_keys( 'post', Event::POST_TYPE );

$this->assertArrayNotHasKey( 'online_event_link', $meta, 'Failed to assert that online_event_link does not exist.' );
$this->assertArrayNotHasKey( 'enable_anonymous_rsvp', $meta, 'Failed to assert that enable_anonymous_rsvp does not exist.' );
$this->assertArrayNotHasKey( 'max_guest_limit', $meta, 'Failed to assert that max_guest_limit does not exist.' );
$this->assertArrayNotHasKey( 'gatherpress_online_event_link', $meta, 'Failed to assert that gatherpress_online_event_link does not exist.' );
$this->assertArrayNotHasKey( 'gatherpress_enable_anonymous_rsvp', $meta, 'Failed to assert that gatherpress_enable_anonymous_rsvp does not exist.' );
$this->assertArrayNotHasKey( 'gatherpress_max_guest_limit', $meta, 'Failed to assert that gatherpress_max_guest_limit does not exist.' );

$instance->register_post_meta();

$meta = get_registered_meta_keys( 'post', Event::POST_TYPE );

$this->assertArrayHasKey( 'online_event_link', $meta, 'Failed to assert that online_event_link does exist.' );
$this->assertArrayHasKey( 'enable_anonymous_rsvp', $meta, 'Failed to assert that enable_anonymous_rsvp does exist.' );
$this->assertArrayHasKey( 'max_guest_limit', $meta, 'Failed to assert that max_guest_limit does exist.' );
$this->assertArrayHasKey( 'gatherpress_online_event_link', $meta, 'Failed to assert that gatherpress_online_event_link does exist.' );
$this->assertArrayHasKey( 'gatherpress_enable_anonymous_rsvp', $meta, 'Failed to assert that gatherpress_enable_anonymous_rsvp does exist.' );
$this->assertArrayHasKey( 'gatherpress_max_guest_limit', $meta, 'Failed to assert that gatherpress_max_guest_limit does exist.' );
}

/**
Expand Down
6 changes: 3 additions & 3 deletions test/unit/php/includes/core/classes/class-test-event.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public function test_get_venue_information(): void {
$event = new Event( $event_id );
$venue_info = '{"fullAddress":"123 Main Street, Montclair, NJ 07042","phoneNumber":"(123) 123-1234","website":"https://gatherpress.org/"}';

update_post_meta( $venue->ID, 'venue_information', $venue_info );
update_post_meta( $venue->ID, 'gatherpress_venue_information', $venue_info );
wp_set_post_terms( $event_id, '_unit-test-venue', Venue::TAXONOMY );

$response = $event->get_venue_information();
Expand Down Expand Up @@ -401,7 +401,7 @@ public function test_get_calendar_links(): void {
'datetime_end' => '2020-05-11 17:00:00',
);

update_post_meta( $venue->ID, 'venue_information', $venue_info );
update_post_meta( $venue->ID, 'gatherpress_venue_information', $venue_info );
wp_set_post_terms( $post->ID, '_unit-test-venue', Venue::TAXONOMY );

$event->save_datetimes( $params );
Expand Down Expand Up @@ -679,7 +679,7 @@ public function test_maybe_get_online_event_link(): void {

$event->save_datetimes( $params );

update_post_meta( $event_id, 'online_event_link', $link );
update_post_meta( $event_id, 'gatherpress_online_event_link', $link );

$this->assertEmpty(
$event->maybe_get_online_event_link(),
Expand Down
2 changes: 1 addition & 1 deletion test/unit/php/includes/core/classes/class-test-rsvp.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function test_save(): void {
array(
'post_type' => 'gatherpress_event',
'post_meta' => array(
'max_guest_limit' => 2,
'gatherpress_max_guest_limit' => 2,
),
)
)->get();
Expand Down
6 changes: 3 additions & 3 deletions test/unit/php/includes/core/classes/class-test-venue.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,17 @@ public function test_register_post_type(): void {
public function test_register_post_meta(): void {
$instance = Venue::get_instance();

unregister_post_meta( Venue::POST_TYPE, 'venue_information' );
unregister_post_meta( Venue::POST_TYPE, 'gatherpress_venue_information' );

$meta = get_registered_meta_keys( 'post', Venue::POST_TYPE );

$this->assertArrayNotHasKey( 'venue_information', $meta, 'Failed to assert that online_event_link does not exist.' );
$this->assertArrayNotHasKey( 'gatherpress_venue_information', $meta, 'Failed to assert that gatherpress_venue_information does not exist.' );

$instance->register_post_meta();

$meta = get_registered_meta_keys( 'post', Venue::POST_TYPE );

$this->assertArrayHasKey( 'venue_information', $meta, 'Failed to assert that online_event_link does exist.' );
$this->assertArrayHasKey( 'gatherpress_venue_information', $meta, 'Failed to assert that gatherpress_venue_information does exist.' );
}

/**
Expand Down

0 comments on commit 9f45247

Please sign in to comment.