bin
3 months ago
AdminCodeCleanupAndPDFTest.php
3 months ago
AdminCodesByProductTest.php
3 months ago
AdminCustomerNameTest.php
3 months ago
AdminErrorLogTest.php
3 months ago
AdminFormatWarningTest.php
3 months ago
AdminListAndCodeOpsTest.php
3 months ago
AdminListQueryTest.php
3 months ago
AdminMetaAndErrorTest.php
3 months ago
AdminOptionsAndMigrationTest.php
3 months ago
AdminOrderInfoTest.php
3 months ago
AdminRedeemAmountTest.php
3 months ago
AdminRestrictionAndRstrTest.php
3 months ago
AdminSettingsAndDatepickerTest.php
3 months ago
AdminSettingsCodeTest.php
3 months ago
AdminTicketInfoTest.php
3 months ago
AdminTimezoneAndMiscTest.php
3 months ago
AdminWCCodeOpsTest.php
3 months ago
AuthtokenAccessTest.php
3 months ago
AuthtokenCRUDTest.php
3 months ago
AuthtokenEditAndRemoveTest.php
3 months ago
AuthtokenTest.php
3 months ago
BaseLimitsTest.php
3 months ago
CartCodeRestrictionAndAssignTest.php
3 months ago
CartMetaAndBeforeCartTest.php
3 months ago
CartValidationTest.php
3 months ago
CoreAlignAndSearchTest.php
3 months ago
CoreCodeOpsAndDBLogTest.php
3 months ago
CoreDecodeAndReplaceTest.php
3 months ago
CoreEncodeMetaTest.php
3 months ago
CoreExpiredAndRegisteredTest.php
3 months ago
CoreMetaAndUrlTest.php
3 months ago
CoreMetaObjectStructureTest.php
3 months ago
CoreMetaTest.php
3 months ago
CoreMethodsTest.php
3 months ago
CoreOrderAndIPTest.php
3 months ago
CoreParserAndQueryTest.php
3 months ago
CoreParserURLAndMergePDFTest.php
3 months ago
CoreReplaceAndExpireTest.php
3 months ago
CoreTicketIdAndExpirationTest.php
3 months ago
CoreTicketIdAndUrlTest.php
3 months ago
CoreTicketURLComponentsTest.php
3 months ago
CountRedeemsTodayTest.php
3 months ago
CronjobTest.php
3 months ago
DBOperationsTest.php
3 months ago
DBSanitizeAndQueryTest.php
3 months ago
DBSanitizeTest.php
3 months ago
DBTablesAndUpdateTest.php
3 months ago
DatabaseTest.php
3 months ago
DateCalcAndCorrectProductTest.php
3 months ago
DaychooserTest.php
3 months ago
EmailHandlerTest.php
3 months ago
EmailOrderMetaAndAttachmentsTest.php
3 months ago
ErrorLogAndSanitizeTest.php
3 months ago
EventTimeWindowTest.php
3 months ago
FrontendCheckCodeTest.php
3 months ago
FrontendCountConfirmedTest.php
3 months ago
FrontendExecuteJSONAndCheckCodeTest.php
3 months ago
FrontendIsUsedAndOptionsTest.php
3 months ago
FrontendMarkUsedTest.php
3 months ago
FrontendValidationTest.php
3 months ago
FullTicketFlowTest.php
3 months ago
HelpersTest.php
3 months ago
ListManagementTest.php
3 months ago
MaxRedeemPerDayTest.php
3 months ago
MessengerAndRESTEndpointsTest.php
3 months ago
MessengerTypeCheckTest.php
3 months ago
OneTimeUseTest.php
3 months ago
OptionsChangeAndLoadTest.php
3 months ago
OptionsDeleteAndResetTest.php
3 months ago
OptionsExportImportTest.php
3 months ago
OptionsFormatsTest.php
3 months ago
OptionsResetAndFormatTest.php
3 months ago
OptionsTest.php
3 months ago
OrderDeleteAndRefundDeleteTest.php
3 months ago
OrderMetaKeyValueDisplayTest.php
3 months ago
OrderStatusHandlerTest.php
3 months ago
OrderTicketGenerationTest.php
3 months ago
OrderTicketQueryTest.php
3 months ago
PDFAndQRConfigTest.php
3 months ago
PDFMergeAndPWAServiceWorkerTest.php
3 months ago
PDFSettersTest.php
3 months ago
PDFSettingsTest.php
3 months ago
PDFUtilsTest.php
3 months ago
PWAManifestAndSessionTest.php
3 months ago
PartialRefundAndCodeCleanupTest.php
3 months ago
PluginInitAndShortcodeTest.php
3 months ago
ProductSettingsTest.php
3 months ago
QRCodeAndDesignerTest.php
3 months ago
QRPDFAndBadgePDFTest.php
3 months ago
RESTRoutesAndPingTest.php
3 months ago
RefundTest.php
3 months ago
RestApiTest.php
3 months ago
RestApiTicketTest.php
3 months ago
ScannerBoilerplateAndFormatWarningsTest.php
3 months ago
SeatingBlockTest.php
3 months ago
SeatingCoordinatorTest.php
3 months ago
SeatingMetaTest.php
3 months ago
SeatingPlanCRUDTest.php
3 months ago
SeatingPlanTest.php
3 months ago
SeatingSeatCRUDTest.php
3 months ago
SetupWizardTest.php
3 months ago
ShortcodeAndCartCheckTest.php
3 months ago
ShortcodeAndCodesDisplayTest.php
3 months ago
ShortcodesAndCodeListTest.php
3 months ago
StaticDateAndTimeTest.php
3 months ago
StaticHelpersAndMessengerTest.php
3 months ago
StaticUtilMethodsTest.php
3 months ago
TicketBadgeTemplateTest.php
3 months ago
TicketCalcDateTest.php
3 months ago
TicketDesignerAndBadgeTest.php
3 months ago
TicketDesignerTemplateTest.php
3 months ago
TicketDesignerTest.php
3 months ago
TicketDisplayTest.php
3 months ago
TicketExpirationAndICSTest.php
3 months ago
TicketLabelAndDisplayTest.php
3 months ago
TicketLabelsAndStaticsTest.php
3 months ago
TicketQRSettersTest.php
3 months ago
TicketRedeemTest.php
3 months ago
TicketRoutingTest.php
3 months ago
TicketScannerMethodsTest.php
3 months ago
TicketSettersAndOrderTest.php
3 months ago
TicketUtilAndICSTest.php
3 months ago
TicketUtilMethodsTest.php
3 months ago
TicketWPMLAndSubscriptionTest.php
3 months ago
TimezoneRedeemBlockingTest.php
3 months ago
UrlParsingTest.php
3 months ago
VariationTicketTest.php
3 months ago
WCBaseMetaConstantsTest.php
3 months ago
WCCheckoutCartFlowTest.php
3 months ago
WCEmailAttachmentTest.php
3 months ago
WCFrontendAjaxAndDatepickerTest.php
3 months ago
WCFrontendCartHandlerTest.php
3 months ago
WCFrontendCartHandlersTest.php
3 months ago
WCFrontendCartTest.php
3 months ago
WCFrontendCartValidationTest.php
3 months ago
WCFrontendHandlersTest.php
3 months ago
WCFrontendLabelsTest.php
3 months ago
WCFrontendMethodsTest.php
3 months ago
WCOrderDeleteTest.php
3 months ago
WCOrderDisplayMetaTest.php
3 months ago
WCOrderHasTicketsTest.php
3 months ago
WCOrderHooksTest.php
3 months ago
WCOrderItemMetaDisplayTest.php
3 months ago
WCOrderItemOpsTest.php
3 months ago
WCOrderLifecycleTest.php
3 months ago
WCOrderMethodsTest.php
3 months ago
WCOrderTicketDetectionTest.php
3 months ago
WCOrderTicketNumberTest.php
3 months ago
WCProductAndVariationTest.php
3 months ago
WCProductColumnsTest.php
3 months ago
WCProductConfigAndColumnsTest.php
3 months ago
WCProductIsTicketAndListsTest.php
3 months ago
WCProductMetaSaveTest.php
3 months ago
WCProductMethodsTest.php
3 months ago
WCProductTabsAndSideBoxTest.php
3 months ago
WCProductTicketTest.php
3 months ago
WebhooksAndMigrationTest.php
3 months ago
bootstrap.php
3 months ago
composer.json
3 months ago
phpunit.xml
3 months ago
StaticUtilMethodsTest.php
125 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Tests for SASO_EVENTTICKETS static utility methods: |
| 4 | * PasswortGenerieren, time, date, is_assoc_array, |
| 5 | * sanitize_date_from_datepicker, getRequestPara. |
| 6 | */ |
| 7 | |
| 8 | class StaticUtilMethodsTest extends WP_UnitTestCase { |
| 9 | |
| 10 | // ── PasswortGenerieren ───────────────────────────────────────── |
| 11 | |
| 12 | public function test_PasswortGenerieren_default_length(): void { |
| 13 | $pw = SASO_EVENTTICKETS::PasswortGenerieren(); |
| 14 | $this->assertEquals(8, strlen($pw)); |
| 15 | } |
| 16 | |
| 17 | public function test_PasswortGenerieren_custom_length(): void { |
| 18 | $pw = SASO_EVENTTICKETS::PasswortGenerieren(16); |
| 19 | $this->assertEquals(16, strlen($pw)); |
| 20 | } |
| 21 | |
| 22 | public function test_PasswortGenerieren_unique(): void { |
| 23 | $pw1 = SASO_EVENTTICKETS::PasswortGenerieren(20); |
| 24 | $pw2 = SASO_EVENTTICKETS::PasswortGenerieren(20); |
| 25 | $this->assertNotEquals($pw1, $pw2); |
| 26 | } |
| 27 | |
| 28 | public function test_PasswortGenerieren_alphanumeric(): void { |
| 29 | $pw = SASO_EVENTTICKETS::PasswortGenerieren(100); |
| 30 | // Should only contain chars from the allowed set (digits 2-9, lowercase letters excluding confusable ones) |
| 31 | $this->assertMatchesRegularExpression('/^[2-9a-hjkmnp-twxyz]+$/', $pw); |
| 32 | } |
| 33 | |
| 34 | // ── time ─────────────────────────────────────────────────────── |
| 35 | |
| 36 | public function test_time_returns_integer(): void { |
| 37 | $result = SASO_EVENTTICKETS::time(); |
| 38 | $this->assertIsInt($result); |
| 39 | } |
| 40 | |
| 41 | public function test_time_returns_reasonable_timestamp(): void { |
| 42 | $result = SASO_EVENTTICKETS::time(); |
| 43 | // Should be after 2020 and before 2030 |
| 44 | $this->assertGreaterThan(strtotime('2020-01-01'), $result); |
| 45 | $this->assertLessThan(strtotime('2030-01-01'), $result); |
| 46 | } |
| 47 | |
| 48 | // ── date ─────────────────────────────────────────────────────── |
| 49 | |
| 50 | public function test_date_returns_string(): void { |
| 51 | $result = SASO_EVENTTICKETS::date('Y-m-d'); |
| 52 | $this->assertIsString($result); |
| 53 | } |
| 54 | |
| 55 | public function test_date_format_Y_m_d(): void { |
| 56 | $result = SASO_EVENTTICKETS::date('Y-m-d'); |
| 57 | $this->assertMatchesRegularExpression('/^\d{4}-\d{2}-\d{2}$/', $result); |
| 58 | } |
| 59 | |
| 60 | public function test_date_with_timestamp(): void { |
| 61 | $timestamp = mktime(12, 0, 0, 6, 15, 2025); |
| 62 | $result = SASO_EVENTTICKETS::date('Y-m-d', $timestamp); |
| 63 | $this->assertEquals('2025-06-15', $result); |
| 64 | } |
| 65 | |
| 66 | // ── is_assoc_array ───────────────────────────────────────────── |
| 67 | |
| 68 | public function test_is_assoc_array_true_for_assoc(): void { |
| 69 | $this->assertTrue(SASO_EVENTTICKETS::is_assoc_array(['key' => 'value'])); |
| 70 | } |
| 71 | |
| 72 | public function test_is_assoc_array_false_for_sequential(): void { |
| 73 | $this->assertFalse(SASO_EVENTTICKETS::is_assoc_array(['a', 'b', 'c'])); |
| 74 | } |
| 75 | |
| 76 | public function test_is_assoc_array_false_for_non_array(): void { |
| 77 | $this->assertFalse(SASO_EVENTTICKETS::is_assoc_array('not an array')); |
| 78 | } |
| 79 | |
| 80 | public function test_is_assoc_array_true_for_empty(): void { |
| 81 | // Implementation treats empty array as associative |
| 82 | $this->assertTrue(SASO_EVENTTICKETS::is_assoc_array([])); |
| 83 | } |
| 84 | |
| 85 | // ── sanitize_date_from_datepicker ────────────────────────────── |
| 86 | |
| 87 | public function test_sanitize_date_valid(): void { |
| 88 | $result = SASO_EVENTTICKETS::sanitize_date_from_datepicker('2026-12-25'); |
| 89 | $this->assertEquals('2026-12-25', $result); |
| 90 | } |
| 91 | |
| 92 | public function test_sanitize_date_invalid_format(): void { |
| 93 | $result = SASO_EVENTTICKETS::sanitize_date_from_datepicker('25/12/2026'); |
| 94 | $this->assertEquals('', $result); |
| 95 | } |
| 96 | |
| 97 | public function test_sanitize_date_empty(): void { |
| 98 | $result = SASO_EVENTTICKETS::sanitize_date_from_datepicker(''); |
| 99 | $this->assertEquals('', $result); |
| 100 | } |
| 101 | |
| 102 | public function test_sanitize_date_truncates_extra(): void { |
| 103 | $result = SASO_EVENTTICKETS::sanitize_date_from_datepicker('2026-12-25T10:00:00'); |
| 104 | $this->assertEquals('2026-12-25', $result); |
| 105 | } |
| 106 | |
| 107 | public function test_sanitize_date_script_injection(): void { |
| 108 | $result = SASO_EVENTTICKETS::sanitize_date_from_datepicker('<script>alert(1)</script>'); |
| 109 | $this->assertEquals('', $result); |
| 110 | } |
| 111 | |
| 112 | // ── getRequestPara ───────────────────────────────────────────── |
| 113 | |
| 114 | public function test_getRequestPara_returns_default_for_missing(): void { |
| 115 | $ref = new ReflectionProperty('SASO_EVENTTICKETS', 'REQUEST_DATA'); |
| 116 | $ref->setAccessible(true); |
| 117 | $ref->setValue(null, null); |
| 118 | |
| 119 | $result = SASO_EVENTTICKETS::getRequestPara('nonexistent_key_' . uniqid(), 'default_val'); |
| 120 | $this->assertEquals('default_val', $result); |
| 121 | |
| 122 | $ref->setValue(null, null); |
| 123 | } |
| 124 | } |
| 125 |