Skip to content

Commit

Permalink
fix testRemoveIrrelevantPostmeta: update_post_meta takes an post ID, …
Browse files Browse the repository at this point in the history
…not an object (#1608)
  • Loading branch information
nelarsen authored Jul 3, 2024
1 parent 85cd4f1 commit e109db5
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions tests/php/Wordpress/CustomPostType/TimeframeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,21 +228,22 @@ public function testManageTimeframeMeta_withLocationTaxonomy() {
*/
public function testRemoveIrrelevantPostmeta() {
$tf = new \CommonsBooking\Model\Timeframe( $this->createBookableTimeFrameIncludingCurrentDay() );
update_post_meta( $tf, \CommonsBooking\Model\Timeframe::META_ITEM_ID_LIST, [ $this->itemId ] );
update_post_meta( $tf, \CommonsBooking\Model\Timeframe::META_LOCATION_ID_LIST, [ $this->locationId ] );
update_post_meta( $tf, \CommonsBooking\Model\Timeframe::META_LOCATION_SELECTION_TYPE, \CommonsBooking\Model\Timeframe::SELECTION_ALL_ID );
update_post_meta( $tf, \CommonsBooking\Model\Timeframe::META_ITEM_SELECTION_TYPE, \CommonsBooking\Model\Timeframe::SELECTION_ALL_ID );
update_post_meta( $tf, \CommonsBooking\Model\Timeframe::META_LOCATION_CATEGORY_IDS, [ '123' ] );
update_post_meta( $tf, \CommonsBooking\Model\Timeframe::META_ITEM_CATEGORY_IDS, [ '123' ] );
update_post_meta( $tf->ID, \CommonsBooking\Model\Timeframe::META_ITEM_ID_LIST, [ $this->itemId ] );
update_post_meta( $tf->ID, \CommonsBooking\Model\Timeframe::META_LOCATION_ID_LIST, [ $this->locationId ] );
update_post_meta( $tf->ID, \CommonsBooking\Model\Timeframe::META_LOCATION_SELECTION_TYPE, \CommonsBooking\Model\Timeframe::SELECTION_ALL_ID );
update_post_meta( $tf->ID, \CommonsBooking\Model\Timeframe::META_ITEM_SELECTION_TYPE, \CommonsBooking\Model\Timeframe::SELECTION_ALL_ID );
update_post_meta( $tf->ID, \CommonsBooking\Model\Timeframe::META_LOCATION_CATEGORY_IDS, [ '123' ] );
update_post_meta( $tf->ID, \CommonsBooking\Model\Timeframe::META_ITEM_CATEGORY_IDS, [ '123' ] );

Timeframe::removeIrrelevantPostmeta( $tf );
//especially assert, that no item ids are assigned when updating the multi-select
Timeframe::manageTimeframeMeta( $tf->ID );
$this->assertEmpty( get_post_meta( $tf, \CommonsBooking\Model\Timeframe::META_ITEM_ID_LIST, true ) );
$this->assertEmpty( get_post_meta( $tf, \CommonsBooking\Model\Timeframe::META_LOCATION_ID_LIST, true ) );
$this->assertEmpty( get_post_meta( $tf, \CommonsBooking\Model\Timeframe::META_LOCATION_SELECTION_TYPE, true ) );
$this->assertEmpty( get_post_meta( $tf, \CommonsBooking\Model\Timeframe::META_ITEM_SELECTION_TYPE, true ) );
$this->assertEmpty( get_post_meta( $tf, \CommonsBooking\Model\Timeframe::META_LOCATION_CATEGORY_IDS, true ) );
$this->assertEmpty( get_post_meta( $tf, \CommonsBooking\Model\Timeframe::META_ITEM_CATEGORY_IDS, true ) );
$this->assertEmpty( get_post_meta( $tf->ID, \CommonsBooking\Model\Timeframe::META_ITEM_ID_LIST, true ) );
$this->assertEmpty( get_post_meta( $tf->ID, \CommonsBooking\Model\Timeframe::META_LOCATION_ID_LIST, true ) );
$this->assertEmpty( get_post_meta( $tf->ID, \CommonsBooking\Model\Timeframe::META_LOCATION_SELECTION_TYPE, true ) );
$this->assertEmpty( get_post_meta( $tf->ID, \CommonsBooking\Model\Timeframe::META_ITEM_SELECTION_TYPE, true ) );
$this->assertEmpty( get_post_meta( $tf->ID, \CommonsBooking\Model\Timeframe::META_LOCATION_CATEGORY_IDS, true ) );
$this->assertEmpty( get_post_meta( $tf->ID, \CommonsBooking\Model\Timeframe::META_ITEM_CATEGORY_IDS, true ) );

}

Expand Down

0 comments on commit e109db5

Please sign in to comment.