- Timestamp:
- 10/02/2025 09:46:07 PM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/admin/wpPrivacyRequestsTable.php
r60729 r60891 210 210 $this->assertSame( $expected, $this->get_mocked_class_instance()->get_views() ); 211 211 } 212 213 /** 214 * Test the get_timestamp_as_date method formats timestamps correctly. 215 * 216 * @ticket 44267 217 * 218 * @covers WP_Privacy_Requests_Table::get_timestamp_as_date 219 */ 220 public function test_get_timestamp_as_date() { 221 $table = $this->get_mocked_class_instance(); 222 223 $reflection = new ReflectionClass( $table ); 224 $method = $reflection->getMethod( 'get_timestamp_as_date' ); 225 $method->setAccessible( true ); 226 227 $date_format = __( 'Y/m/d' ); 228 $time_format = __( 'g:i a' ); 229 230 $current_time = time(); 231 232 $this->assertSame( '', $method->invoke( $table, '' ) ); 233 234 // Test recent timestamp (less than 24 hours ago). 235 $recent_time = $current_time - HOUR_IN_SECONDS; 236 $result = $method->invoke( $table, $recent_time ); 237 $this->assertStringContainsString( 'ago', $result ); 238 239 $old_time = $current_time - 2 * DAY_IN_SECONDS; 240 $result = $method->invoke( $table, $old_time ); 241 242 $date_part = date_i18n( $date_format, $old_time ); 243 $time_part = date_i18n( $time_format, $old_time ); 244 245 $this->assertStringContainsString( $date_part, $result ); 246 $this->assertStringContainsString( 'at', $result ); 247 $this->assertStringContainsString( $time_part, $result ); 248 } 212 249 }
Note: See TracChangeset
for help on using the changeset viewer.