From 3cfd0ec230ebd2a596d30009b10d735a07bb2c8c Mon Sep 17 00:00:00 2001 From: Gustavo Bordoni Date: Sat, 12 Oct 2024 00:15:29 -0400 Subject: [PATCH] Remove more marketing tests --- .../wpunit/Tribe/Notices/Black_FridayTest.php | 168 ------------------ .../wpunit/Tribe/Notices/Stellar_SaleTest.php | 152 ---------------- 2 files changed, 320 deletions(-) delete mode 100644 tests/wpunit/Tribe/Notices/Black_FridayTest.php delete mode 100644 tests/wpunit/Tribe/Notices/Stellar_SaleTest.php diff --git a/tests/wpunit/Tribe/Notices/Black_FridayTest.php b/tests/wpunit/Tribe/Notices/Black_FridayTest.php deleted file mode 100644 index 60fff0f74..000000000 --- a/tests/wpunit/Tribe/Notices/Black_FridayTest.php +++ /dev/null @@ -1,168 +0,0 @@ -set_const_value( 'TRIBE_HIDE_UPSELL', true ); - // Ensure we're on a good date. - add_filter( - 'tribe_black-friday_notice_start_date', - function ( $date ) { - // Set the start date to the past. - return Dates::build_date_object( '-7 days', 'UTC' ); - } - ); - - add_filter( - 'tribe_black-friday_notice_end_date', - function ( $date ) { - // Set the end date to the future. - return Dates::build_date_object( '+7 days', 'UTC' ); - } - ); - - // Ensure we're on a good screen. - set_current_screen( 'tribe_events_page_tribe-common' ); - - $notice = tribe( \TEC\Common\Admin\Notices\Black_Friday::class ); - - $this->assertFalse( $notice->should_display() ); - } - - /** - * Test ! should_display() when on wrong screen. - * Note this test assumes we have not set the constant in our testing environment. - * - * @test - */ - public function should_not_display_when_wrong_screen() { - // Ensure we're on a good date. - add_filter( - 'tribe_black-friday_notice_start_date', - function ( $date ) { - // Set the start date to the past. - return Dates::build_date_object( '-7 days', 'UTC' ); - } - ); - - add_filter( - 'tribe_black-friday_notice_end_date', - function ( $date ) { - // Set the end date to the future. - return Dates::build_date_object( '+7 days', 'UTC' ); - } - ); - - // Ensure we're on the WRONG screen. - set_current_screen( 'edit-post' ); - - $notice = tribe( \TEC\Common\Admin\Notices\Black_Friday::class ); - - $this->assertFalse( $notice->should_display() ); - } - - /** - * Test ! should_display() when date passed. - * Note this test assumes we have not set the constant in our testing environment. - * - * @test - */ - public function should_not_display_when_past() { - add_filter( - 'tribe_black-friday_notice_start_date', - function ( $date ) { - // Set the start date to the past. - return Dates::build_date_object( '-7 days', 'UTC' ); - }, 200 - ); - - add_filter( - 'tribe_black-friday_notice_end_date', - function ( $date ) { - // Set the end date to the past. - return Dates::build_date_object( '-5 days', 'UTC' ); - }, 200 - ); - - // Ensure we're on a good screen. - set_current_screen( 'tribe_events_page_tribe-common' ); - - $notice = tribe( \TEC\Common\Admin\Notices\Black_Friday::class ); - - $this->assertFalse( $notice->should_display() ); - } - - /** - * Test ! should_display() when date in future. - * Note this test assumes we have not set the constant in our testing environment. - * - * @test - */ - public function should_not_display_when_in_future() { - add_filter( - 'tribe_black-friday_notice_start_date', - function ( $date ) { - // Set the start date to the future. - return Dates::build_date_object( '+5 days', 'UTC' ); - }, 200 - ); - - add_filter( - 'tribe_black-friday_notice_end_date', - function ( $date ) { - // Set the end date to the future. - return Dates::build_date_object( '+7 days', 'UTC' ); - }, 200 - ); - - // Ensure we're on a good screen. - set_current_screen( 'tribe_events_page_tribe-common' ); - - $notice = tribe( \TEC\Common\Admin\Notices\Black_Friday::class ); - - $this->assertFalse( $notice->should_display() ); - } - - /** - * Test should_display() when the stars align (all conditions true). - * Note this test assumes we have not set the constant in our testing environment. - * - * @test - */ - public function should_display_when_stars_align() { - add_filter( - 'tribe_black-friday_notice_start_date', - function ( $date ) { - // Set the start date to the past. - return Dates::build_date_object( '-7 days', 'UTC' ); - }, 200 - ); - - add_filter( - 'tribe_black-friday_notice_end_date', - function ( $date ) { - // Set the end date to the future. - return Dates::build_date_object( '+7 days', 'UTC' ); - }, 200 - ); - - // Ensure we're on a good screen. - set_current_screen( 'tribe_events_page_tribe-common' ); - - $notice = tribe( \TEC\Common\Admin\Notices\Black_Friday::class ); - - codecept_debug( $notice ); - - $this->assertTrue( $notice->should_display() ); - } -} diff --git a/tests/wpunit/Tribe/Notices/Stellar_SaleTest.php b/tests/wpunit/Tribe/Notices/Stellar_SaleTest.php deleted file mode 100644 index 352930070..000000000 --- a/tests/wpunit/Tribe/Notices/Stellar_SaleTest.php +++ /dev/null @@ -1,152 +0,0 @@ -assertFalse( $notice->should_display() ); - - // So we don't muck up later tests. - remove_all_filters( 'tribe_stellar-sale-2024_notice_start_date' ); - uopz_undefine( 'TRIBE_HIDE_UPSELL' ); - } - - /** - * Test ! should_display() when on wrong screen. - * Note this test assumes we have not set the constant in our testing environment. - * - * @test - */ - public function should_not_display_when_wrong_screen() { - // Ensure we're on a good date. - add_filter( - 'tribe_stellar-sale-2024_notice_start_date', - function( $date ) { - // Set the start date to the past. - return Dates::build_date_object( '-7 days', 'UTC' ); - } - ); - - add_filter( - 'tribe_stellar-sale-2024_notice_end_date', - function( $date ) { - // Set the end date to the future. - return Dates::build_date_object( '+7 days', 'UTC' ); - } - ); - - // Ensure we're on the WRONG screen. - set_current_screen( 'edit-post' ); - - $notice = tribe( Tribe\Admin\Notice\Marketing\Stellar_Sale::class ); - - $this->assertFalse( $notice->should_display() ); - - // So we don't muck up later tests. - remove_all_filters( 'tribe_stellar-sale-2024_notice_start_date' ); - } - - /** - * Test ! should_display() when date passed. - * Note this test assumes we have not set the constant in our testing environment. - * - * @test - */ - public function should_not_display_when_past() { - // Ensure we're on a good screen. - set_current_screen( 'tribe_events_page_tribe-common' ); - - // Mock the `now` date to be this year, in the past of the notice display date. - $year = date( 'Y' ); - $this->set_class_fn_return( Dates::class, 'build_date_object', static function ( $input ) use ( $year ) { - return $input === 'now' ? - new DateTime( "$year-02-23 09:23:23" ) - : new DateTime( $input ); - }, true ); - - $notice = tribe( Tribe\Admin\Notice\Marketing\Stellar_Sale::class ); - - $this->assertFalse( $notice->should_display() ); - } - - /** - * Test ! should_display() when date in future. - * Note this test assumes we have not set the constant in our testing environment. - * - * @test - */ - public function should_not_display_when_in_future() { - // Ensure we're on a good screen. - set_current_screen( 'tribe_events_page_tribe-common' ); - - // Mock the `now` date to be this year, in the future of the notice display date. - $year = date( 'Y' ); - $this->set_class_fn_return( Dates::class, 'build_date_object', static function ( $input ) use ( $year ) { - return $input === 'now' ? - new DateTime( "$year-12-10 09:23:23" ) - : new DateTime( $input ); - }, true ); - - $notice = tribe( Tribe\Admin\Notice\Marketing\Stellar_Sale::class ); - - $this->assertFalse( $notice->should_display() ); - } - - /** - * Test should_display() when the stars align (all conditions true). - * Note this test assumes we have not set the constant in our testing environment. - * - * @test - */ - public function should_display_when_stars_align() { - // Ensure we're on a good screen. - set_current_screen( 'tribe_events_page_tribe-common' ); - - // Mock the `now` date to be this year on November 21st. - $year = date( 'Y' ); - $this->set_class_fn_return( Dates::class, 'build_date_object', static function ( $input ) use ( $year ) { - return $input === 'now' ? - new DateTime( '2024-07-26 19:23:23' ) - : new DateTime( $input ); - }, true ); - - $notice = tribe( Tribe\Admin\Notice\Marketing\Stellar_Sale::class ); - - $this->assertTrue( $notice->should_display() ); - } -}