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
OptionsTest.php
138 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Integration tests for the Options system. |
| 4 | */ |
| 5 | |
| 6 | class OptionsTest extends WP_UnitTestCase { |
| 7 | |
| 8 | private sasoEventtickets_Options $options; |
| 9 | |
| 10 | public function set_up(): void { |
| 11 | parent::set_up(); |
| 12 | $this->options = sasoEventtickets::Instance()->getOptions(); |
| 13 | } |
| 14 | |
| 15 | // ── getOptions ───────────────────────────────────────────── |
| 16 | |
| 17 | public function test_getOptions_returns_non_empty_array(): void { |
| 18 | $opts = $this->options->getOptions(); |
| 19 | $this->assertIsArray($opts); |
| 20 | $this->assertNotEmpty($opts); |
| 21 | } |
| 22 | |
| 23 | public function test_getOptions_each_has_key_and_type(): void { |
| 24 | $opts = $this->options->getOptions(); |
| 25 | foreach ($opts as $opt) { |
| 26 | $this->assertArrayHasKey('key', $opt, 'Option missing key field'); |
| 27 | $this->assertArrayHasKey('type', $opt, "Option '{$opt['key']}' missing type field"); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | public function test_getOptions_known_option_exists(): void { |
| 32 | $opts = $this->options->getOptions(); |
| 33 | $keys = array_column($opts, 'key'); |
| 34 | $this->assertContains('wcTicketScannerAllowedRoles', $keys); |
| 35 | } |
| 36 | |
| 37 | // ── getOptionsKeys ───────────────────────────────────────── |
| 38 | |
| 39 | public function test_getOptionsKeys_returns_strings(): void { |
| 40 | $keys = $this->options->getOptionsKeys(); |
| 41 | $this->assertIsArray($keys); |
| 42 | $this->assertNotEmpty($keys); |
| 43 | foreach ($keys as $key) { |
| 44 | $this->assertIsString($key); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | // ── getOption ────────────────────────────────────────────── |
| 49 | |
| 50 | public function test_getOption_returns_known_option(): void { |
| 51 | $opt = $this->options->getOption('wcTicketScannerAllowedRoles'); |
| 52 | $this->assertIsArray($opt); |
| 53 | $this->assertSame('wcTicketScannerAllowedRoles', $opt['key']); |
| 54 | } |
| 55 | |
| 56 | public function test_getOption_returns_null_for_unknown(): void { |
| 57 | $opt = $this->options->getOption('this_option_does_not_exist_xyz'); |
| 58 | $this->assertNull($opt); |
| 59 | } |
| 60 | |
| 61 | // ── getOptionValue ───────────────────────────────────────── |
| 62 | |
| 63 | public function test_getOptionValue_returns_default_for_unknown(): void { |
| 64 | $val = $this->options->getOptionValue('nonexistent_xyz', 'fallback'); |
| 65 | $this->assertSame('fallback', $val); |
| 66 | } |
| 67 | |
| 68 | // ── isOptionCheckboxActive ───────────────────────────────── |
| 69 | |
| 70 | public function test_isOptionCheckboxActive_returns_bool(): void { |
| 71 | $result = $this->options->isOptionCheckboxActive('displayFirstStepsHelp'); |
| 72 | $this->assertIsBool($result); |
| 73 | } |
| 74 | |
| 75 | // ── changeOption round-trip ──────────────────────────────── |
| 76 | |
| 77 | public function test_changeOption_and_read_back(): void { |
| 78 | // Find a text option to test with |
| 79 | $opts = $this->options->getOptions(); |
| 80 | $textOpt = null; |
| 81 | foreach ($opts as $opt) { |
| 82 | if ($opt['type'] === 'text' && !empty($opt['key'])) { |
| 83 | $textOpt = $opt; |
| 84 | break; |
| 85 | } |
| 86 | } |
| 87 | if ($textOpt === null) { |
| 88 | $this->markTestSkipped('No text option found for round-trip test'); |
| 89 | } |
| 90 | |
| 91 | $key = $textOpt['key']; |
| 92 | $testValue = 'phpunit_test_value_' . time(); |
| 93 | |
| 94 | $this->options->changeOption(['key' => $key, 'value' => $testValue]); |
| 95 | |
| 96 | // Force reload |
| 97 | $freshValue = get_option('sasoEventtickets' . $key); |
| 98 | $this->assertSame($testValue, $freshValue); |
| 99 | } |
| 100 | |
| 101 | // ── date/time format getters ─────────────────────────────── |
| 102 | |
| 103 | public function test_getOptionDateFormat_returns_string(): void { |
| 104 | $format = $this->options->getOptionDateFormat(); |
| 105 | $this->assertIsString($format); |
| 106 | $this->assertNotEmpty($format); |
| 107 | } |
| 108 | |
| 109 | public function test_getOptionTimeFormat_returns_string(): void { |
| 110 | $format = $this->options->getOptionTimeFormat(); |
| 111 | $this->assertIsString($format); |
| 112 | $this->assertNotEmpty($format); |
| 113 | } |
| 114 | |
| 115 | public function test_getOptionDateTimeFormat_combines_date_and_time(): void { |
| 116 | $dateFormat = $this->options->getOptionDateFormat(); |
| 117 | $timeFormat = $this->options->getOptionTimeFormat(); |
| 118 | $combined = $this->options->getOptionDateTimeFormat(); |
| 119 | $this->assertStringContainsString($dateFormat, $combined); |
| 120 | $this->assertStringContainsString($timeFormat, $combined); |
| 121 | } |
| 122 | |
| 123 | // ── getOptionsOnlyPublic ─────────────────────────────────── |
| 124 | |
| 125 | public function test_getOptionsOnlyPublic_subset_of_all(): void { |
| 126 | $all = $this->options->getOptions(); |
| 127 | $public = $this->options->getOptionsOnlyPublic(); |
| 128 | $this->assertLessThanOrEqual(count($all), count($public)); |
| 129 | } |
| 130 | |
| 131 | // ── get_wcTicketAttachTicketToMailOf ──────────────────────── |
| 132 | |
| 133 | public function test_get_wcTicketAttachTicketToMailOf_returns_array(): void { |
| 134 | $result = $this->options->get_wcTicketAttachTicketToMailOf(); |
| 135 | $this->assertIsArray($result); |
| 136 | } |
| 137 | } |
| 138 |