bin
3 months ago
fixtures
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
ContextWizardTest.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
OldPremiumGuardTest.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
OptionsHistoryTest.php
3 months ago
OptionsMigrationTest.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
SeatingExportTest.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
test-premium-compat.sh
3 months ago
HelpersTest.php
115 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Tests for SASO_EVENTTICKETS static helper methods. |
| 4 | */ |
| 5 | |
| 6 | class HelpersTest extends WP_UnitTestCase { |
| 7 | |
| 8 | // ── PasswortGenerieren ───────────────────────────────────── |
| 9 | |
| 10 | public function test_password_default_length_is_8(): void { |
| 11 | $pw = SASO_EVENTTICKETS::PasswortGenerieren(); |
| 12 | $this->assertSame(8, strlen($pw)); |
| 13 | } |
| 14 | |
| 15 | public function test_password_custom_length(): void { |
| 16 | $pw = SASO_EVENTTICKETS::PasswortGenerieren(16); |
| 17 | $this->assertSame(16, strlen($pw)); |
| 18 | } |
| 19 | |
| 20 | public function test_password_length_1(): void { |
| 21 | $pw = SASO_EVENTTICKETS::PasswortGenerieren(1); |
| 22 | $this->assertSame(1, strlen($pw)); |
| 23 | } |
| 24 | |
| 25 | public function test_password_contains_only_allowed_chars(): void { |
| 26 | $allowed = '23456789abcdefghjkmnpqrstwxyz'; |
| 27 | for ($i = 0; $i < 20; $i++) { |
| 28 | $pw = SASO_EVENTTICKETS::PasswortGenerieren(32); |
| 29 | for ($c = 0; $c < strlen($pw); $c++) { |
| 30 | $this->assertStringContainsString( |
| 31 | $pw[$c], $allowed, |
| 32 | "Character '{$pw[$c]}' not in allowed set" |
| 33 | ); |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | public function test_password_randomness_not_identical(): void { |
| 39 | $passwords = []; |
| 40 | for ($i = 0; $i < 10; $i++) { |
| 41 | $passwords[] = SASO_EVENTTICKETS::PasswortGenerieren(16); |
| 42 | } |
| 43 | $unique = array_unique($passwords); |
| 44 | $this->assertGreaterThan(1, count($unique), 'Passwords should not all be identical'); |
| 45 | } |
| 46 | |
| 47 | // ── sanitize_date_from_datepicker ────────────────────────── |
| 48 | |
| 49 | public function test_sanitize_valid_date(): void { |
| 50 | $this->assertSame('2026-02-20', SASO_EVENTTICKETS::sanitize_date_from_datepicker('2026-02-20')); |
| 51 | } |
| 52 | |
| 53 | public function test_sanitize_date_with_time_truncated(): void { |
| 54 | $this->assertSame('2026-02-20', SASO_EVENTTICKETS::sanitize_date_from_datepicker('2026-02-20 14:30:00')); |
| 55 | } |
| 56 | |
| 57 | public function test_sanitize_invalid_date_returns_empty(): void { |
| 58 | $this->assertSame('', SASO_EVENTTICKETS::sanitize_date_from_datepicker('not-a-date')); |
| 59 | } |
| 60 | |
| 61 | public function test_sanitize_empty_string_returns_empty(): void { |
| 62 | $this->assertSame('', SASO_EVENTTICKETS::sanitize_date_from_datepicker('')); |
| 63 | } |
| 64 | |
| 65 | public function test_sanitize_wrong_format_returns_empty(): void { |
| 66 | $this->assertSame('', SASO_EVENTTICKETS::sanitize_date_from_datepicker('20/02/2026')); |
| 67 | } |
| 68 | |
| 69 | public function test_sanitize_partial_date_returns_empty(): void { |
| 70 | $this->assertSame('', SASO_EVENTTICKETS::sanitize_date_from_datepicker('2026-02')); |
| 71 | } |
| 72 | |
| 73 | // ── is_assoc_array ───────────────────────────────────────── |
| 74 | |
| 75 | public function test_is_assoc_array_with_string_keys(): void { |
| 76 | $this->assertTrue(SASO_EVENTTICKETS::is_assoc_array(['a' => 1, 'b' => 2])); |
| 77 | } |
| 78 | |
| 79 | public function test_is_assoc_array_with_numeric_keys(): void { |
| 80 | $this->assertFalse(SASO_EVENTTICKETS::is_assoc_array([1, 2, 3])); |
| 81 | } |
| 82 | |
| 83 | public function test_is_assoc_array_empty_returns_true(): void { |
| 84 | // empty arrays are considered associative by the implementation |
| 85 | $this->assertTrue(SASO_EVENTTICKETS::is_assoc_array([])); |
| 86 | } |
| 87 | |
| 88 | public function test_is_assoc_array_not_array_returns_false(): void { |
| 89 | $this->assertFalse(SASO_EVENTTICKETS::is_assoc_array('string')); |
| 90 | } |
| 91 | |
| 92 | public function test_is_assoc_array_mixed_keys(): void { |
| 93 | $this->assertTrue(SASO_EVENTTICKETS::is_assoc_array([0 => 'a', 'key' => 'b'])); |
| 94 | } |
| 95 | |
| 96 | // ── getRESTPrefixURL ─────────────────────────────────────── |
| 97 | |
| 98 | public function test_getRESTPrefixURL_returns_plugin_dirname(): void { |
| 99 | $result = SASO_EVENTTICKETS::getRESTPrefixURL(); |
| 100 | $this->assertSame('event-tickets-with-ticket-scanner', $result); |
| 101 | } |
| 102 | |
| 103 | // ── getRequestPara ───────────────────────────────────────── |
| 104 | |
| 105 | public function test_getRequestPara_returns_default_when_not_set(): void { |
| 106 | $result = SASO_EVENTTICKETS::getRequestPara('nonexistent_param_xyz', 'fallback'); |
| 107 | $this->assertSame('fallback', $result); |
| 108 | } |
| 109 | |
| 110 | public function test_getRequestPara_returns_null_default(): void { |
| 111 | $result = SASO_EVENTTICKETS::getRequestPara('nonexistent_param_xyz'); |
| 112 | $this->assertNull($result); |
| 113 | } |
| 114 | } |
| 115 |