PluginProbe ʕ •ᴥ•ʔ
Event Tickets with Ticket Scanner / 2.9.4
Event Tickets with Ticket Scanner v2.9.4
3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.4 trunk 2.6.0 2.7.0 2.7.1 2.7.10 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.10 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.0 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 3.0.1 3.0.2 3.0.3
event-tickets-with-ticket-scanner / tests / BaseLimitsTest.php
event-tickets-with-ticket-scanner / tests Last commit date
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
BaseLimitsTest.php
158 lines
1 <?php
2 /**
3 * Tests for Base methods: getMaxValue, getMaxValues, getOverallTicketCounterValue,
4 * increaseGlobalTicketCounter, _isMaxReachedForList, _isMaxReachedForTickets,
5 * _isMaxReachedForAuthtokens.
6 */
7
8 class BaseLimitsTest extends WP_UnitTestCase {
9
10 private $main;
11
12 public function set_up(): void {
13 parent::set_up();
14 $this->main = sasoEventtickets::Instance();
15 }
16
17 // ── getMaxValues ─────────────────────────────────────────────
18
19 public function test_getMaxValues_returns_array(): void {
20 $values = $this->main->getBase()->getMaxValues();
21 $this->assertIsArray($values);
22 }
23
24 // ── getMaxValue ──────────────────────────────────────────────
25
26 public function test_getMaxValue_returns_int_for_known_key(): void {
27 $val = $this->main->getBase()->getMaxValue('codes_total');
28 $this->assertIsInt($val);
29 }
30
31 public function test_getMaxValue_returns_default_for_unknown_key(): void {
32 $val = $this->main->getBase()->getMaxValue('nonexistent_key_xyz', 99);
33 $this->assertEquals(99, $val);
34 }
35
36 // ── getOverallTicketCounterValue ─────────────────────────────
37
38 public function test_getOverallTicketCounterValue_returns_int(): void {
39 $val = $this->main->getBase()->getOverallTicketCounterValue();
40 $this->assertIsInt($val);
41 $this->assertGreaterThanOrEqual(0, $val);
42 }
43
44 // ── increaseGlobalTicketCounter ──────────────────────────────
45
46 public function test_increaseGlobalTicketCounter_increments(): void {
47 $before = $this->main->getBase()->getOverallTicketCounterValue();
48 $this->main->getBase()->increaseGlobalTicketCounter(1);
49 $after = $this->main->getBase()->getOverallTicketCounterValue();
50
51 $this->assertEquals($before + 1, $after);
52 }
53
54 public function test_increaseGlobalTicketCounter_by_custom_amount(): void {
55 $before = $this->main->getBase()->getOverallTicketCounterValue();
56 $this->main->getBase()->increaseGlobalTicketCounter(5);
57 $after = $this->main->getBase()->getOverallTicketCounterValue();
58
59 $this->assertEquals($before + 5, $after);
60 }
61
62 // ── _isMaxReachedForList ─────────────────────────────────────
63
64 public function test_isMaxReachedForList_returns_bool(): void {
65 $result = $this->main->getBase()->_isMaxReachedForList(0);
66 $this->assertIsBool($result);
67 }
68
69 public function test_isMaxReachedForList_low_count_not_exceeded(): void {
70 // With 0 lists, should not be exceeded
71 $result = $this->main->getBase()->_isMaxReachedForList(0);
72 $this->assertTrue($result, 'Zero lists should not exceed limit');
73 }
74
75 // ── _isMaxReachedForTickets ──────────────────────────────────
76
77 public function test_isMaxReachedForTickets_returns_bool(): void {
78 $result = $this->main->getBase()->_isMaxReachedForTickets(0);
79 $this->assertIsBool($result);
80 }
81
82 public function test_isMaxReachedForTickets_low_count_not_exceeded(): void {
83 $result = $this->main->getBase()->_isMaxReachedForTickets(0);
84 $this->assertTrue($result, 'Zero tickets should not exceed limit');
85 }
86
87 public function test_isMaxReachedForTickets_very_high_count(): void {
88 // Free version limit is 50 — very high count should exceed (return false)
89 $result = $this->main->getBase()->_isMaxReachedForTickets(999999);
90 $this->assertFalse($result, 'Very high ticket count should exceed free limit');
91 }
92
93 // ── Counter brake (delete+recreate prevention) ───────────────
94
95 public function test_counter_brake_allows_when_counter_is_zero(): void {
96 update_option($this->main->getPrefix() . 'mvct', 0);
97 $result = $this->main->getBase()->_isMaxReachedForTickets(5);
98 $this->assertTrue($result, 'Counter=0 should not block');
99 }
100
101 public function test_counter_brake_allows_within_grace(): void {
102 // Counter 200, current total 100 → difference 100 < 150 grace → allowed
103 update_option($this->main->getPrefix() . 'mvct', 200);
104 $result = $this->main->getBase()->_isMaxReachedForTickets(100);
105 // Note: total 100 > codes_total(50) → already blocked by first check
106 // Test with total within limit
107 update_option($this->main->getPrefix() . 'mvct', 60);
108 $result = $this->main->getBase()->_isMaxReachedForTickets(10);
109 $this->assertTrue($result, 'Counter within grace period should allow');
110 }
111
112 public function test_counter_brake_blocks_when_exceeding_grace(): void {
113 // Counter 300, current total 10 → 300 > (10+150)=160 → blocked
114 update_option($this->main->getPrefix() . 'mvct', 300);
115 $result = $this->main->getBase()->_isMaxReachedForTickets(10);
116 $this->assertFalse($result, 'Counter far exceeding total+grace should block');
117 }
118
119 public function test_counter_brake_does_not_block_premium(): void {
120 // Premium has codes_total=0 → first check returns true (unlimited), counter never reached
121 // Simulate by passing total=0 with codes_total=0 logic
122 $maxVal = $this->main->getBase()->getMaxValue('codes_total');
123 if ($maxVal === 0) {
124 // Premium: should always return true regardless of counter
125 update_option($this->main->getPrefix() . 'mvct', 999999);
126 $result = $this->main->getBase()->_isMaxReachedForTickets(0);
127 $this->assertTrue($result);
128 } else {
129 // Free version in test env: codes_total > 0, skip this test
130 $this->markTestSkipped('Only relevant for premium (codes_total=0)');
131 }
132 }
133
134 public function test_counter_brake_boundary_at_grace_limit(): void {
135 // Counter exactly at total+150 → NOT exceeded (needs to be greater than)
136 update_option($this->main->getPrefix() . 'mvct', 160);
137 $result = $this->main->getBase()->_isMaxReachedForTickets(10);
138 $this->assertTrue($result, 'Counter exactly at grace boundary should still allow');
139
140 // Counter one above → blocked
141 update_option($this->main->getPrefix() . 'mvct', 161);
142 $result = $this->main->getBase()->_isMaxReachedForTickets(10);
143 $this->assertFalse($result, 'Counter one above grace boundary should block');
144 }
145
146 // ── _isMaxReachedForAuthtokens ───────────────────────────────
147
148 public function test_isMaxReachedForAuthtokens_returns_bool(): void {
149 $result = $this->main->getBase()->_isMaxReachedForAuthtokens(0);
150 $this->assertIsBool($result);
151 }
152
153 public function test_isMaxReachedForAuthtokens_low_count(): void {
154 $result = $this->main->getBase()->_isMaxReachedForAuthtokens(0);
155 $this->assertTrue($result, 'Zero authtokens should not exceed limit');
156 }
157 }
158