PluginProbe ʕ •ᴥ•ʔ
Event Tickets with Ticket Scanner / 2.9.3
Event Tickets with Ticket Scanner v2.9.3
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 / CoreMetaAndUrlTest.php
event-tickets-with-ticket-scanner / tests Last commit date
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
CoreMetaAndUrlTest.php
189 lines
1 <?php
2 /**
3 * Tests for Core methods: saveMetaObject, getQRCodeContent, getTicketScannerURL,
4 * getTicketURL, isCodeIsRegistered, getListById, getCodesByRegUserId,
5 * encodeMetaValuesAndFillObjectList, checkCodesSize, isCodeSizeExceeded.
6 */
7
8 class CoreMetaAndUrlTest 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 private function createCodeInList(): array {
18 $listId = $this->main->getDB()->insert('lists', [
19 'name' => 'CoreMeta Test ' . uniqid(),
20 'aktiv' => 1,
21 'meta' => '{}',
22 ]);
23
24 $metaObj = $this->main->getCore()->getMetaObject();
25 $metaJson = $this->main->getCore()->json_encode_with_error_handling($metaObj);
26
27 $code = 'CMT' . strtoupper(uniqid());
28 $this->main->getDB()->insert('codes', [
29 'code' => $code,
30 'code_display' => $code,
31 'cvv' => '',
32 'meta' => $metaJson,
33 'aktiv' => 1,
34 'redeemed' => 0,
35 'list_id' => $listId,
36 'order_id' => 0,
37 ]);
38
39 return ['code' => $code, 'list_id' => $listId];
40 }
41
42 // ── saveMetaObject ───────────────────────────────────────────
43
44 public function test_saveMetaObject_equivalent_persists_to_db(): void {
45 $data = $this->createCodeInList();
46 $codeObj = $this->main->getCore()->retrieveCodeByCode($data['code']);
47 $metaObj = $this->main->getCore()->encodeMetaValuesAndFillObject($codeObj['meta'], $codeObj);
48
49 $metaObj['confirmedCount'] = 42;
50 $metaJson = $this->main->getCore()->json_encode_with_error_handling($metaObj);
51 $this->main->getDB()->update('codes', ['meta' => $metaJson], ['id' => $codeObj['id']]);
52
53 // Re-read from DB and verify
54 $fresh = $this->main->getCore()->retrieveCodeByCode($data['code']);
55 $freshMeta = $this->main->getCore()->encodeMetaValuesAndFillObject($fresh['meta'], $fresh);
56 $this->assertEquals(42, intval($freshMeta['confirmedCount']));
57 }
58
59 // ── getQRCodeContent ─────────────────────────────────────────
60
61 public function test_getQRCodeContent_returns_ticket_id(): void {
62 $data = $this->createCodeInList();
63 $codeObj = $this->main->getCore()->retrieveCodeByCode($data['code']);
64
65 $qrContent = $this->main->getCore()->getQRCodeContent($codeObj);
66 $this->assertIsString($qrContent);
67 $this->assertNotEmpty($qrContent);
68 }
69
70 public function test_getQRCodeContent_with_metaObj(): void {
71 $data = $this->createCodeInList();
72 $codeObj = $this->main->getCore()->retrieveCodeByCode($data['code']);
73 $metaObj = $this->main->getCore()->encodeMetaValuesAndFillObject($codeObj['meta'], $codeObj);
74
75 $qrContent = $this->main->getCore()->getQRCodeContent($codeObj, $metaObj);
76 $this->assertIsString($qrContent);
77 $this->assertNotEmpty($qrContent);
78 }
79
80 // ── getTicketScannerURL ──────────────────────────────────────
81
82 public function test_getTicketScannerURL_contains_scanner_and_code(): void {
83 $url = $this->main->getCore()->getTicketScannerURL('TEST-ID-123');
84 $this->assertIsString($url);
85 $this->assertStringContainsString('scanner', $url);
86 $this->assertStringContainsString('TEST-ID-123', $url);
87 }
88
89 // ── getTicketURL ─────────────────────────────────────────────
90
91 public function test_getTicketURL_contains_ticket_id(): void {
92 $data = $this->createCodeInList();
93 $codeObj = $this->main->getCore()->retrieveCodeByCode($data['code']);
94 $metaObj = $this->main->getCore()->encodeMetaValuesAndFillObject($codeObj['meta'], $codeObj);
95
96 $url = $this->main->getCore()->getTicketURL($codeObj, $metaObj);
97 $this->assertIsString($url);
98 $this->assertStringContainsString('ticket', $url);
99 }
100
101 // ── isCodeIsRegistered ───────────────────────────────────────
102
103 public function test_isCodeIsRegistered_false_for_new_code(): void {
104 $data = $this->createCodeInList();
105 $codeObj = $this->main->getCore()->retrieveCodeByCode($data['code']);
106
107 $result = $this->main->getCore()->isCodeIsRegistered($codeObj);
108 $this->assertFalse($result);
109 }
110
111 public function test_isCodeIsRegistered_true_when_user_set(): void {
112 $data = $this->createCodeInList();
113 $codeObj = $this->main->getCore()->retrieveCodeByCode($data['code']);
114 $metaObj = $this->main->getCore()->encodeMetaValuesAndFillObject($codeObj['meta'], $codeObj);
115
116 $metaObj['user']['value'] = 'testuser@example.com';
117 $metaJson = $this->main->getCore()->json_encode_with_error_handling($metaObj);
118 $this->main->getDB()->update('codes', ['meta' => $metaJson], ['id' => $codeObj['id']]);
119
120 $fresh = $this->main->getCore()->retrieveCodeByCode($data['code']);
121 $result = $this->main->getCore()->isCodeIsRegistered($fresh);
122 $this->assertTrue($result);
123 }
124
125 // ── getListById ──────────────────────────────────────────────
126
127 public function test_getListById_returns_list(): void {
128 $listId = $this->main->getDB()->insert('lists', [
129 'name' => 'GetById Test ' . uniqid(),
130 'aktiv' => 1,
131 'meta' => '{}',
132 ]);
133
134 $list = $this->main->getCore()->getListById($listId);
135 $this->assertIsArray($list);
136 $this->assertEquals($listId, intval($list['id']));
137 }
138
139 public function test_getListById_invalid_throws(): void {
140 $this->expectException(Exception::class);
141 $this->main->getCore()->getListById(999999);
142 }
143
144 // ── getCodesByRegUserId ──────────────────────────────────────
145
146 public function test_getCodesByRegUserId_empty_for_zero(): void {
147 $result = $this->main->getCore()->getCodesByRegUserId(0);
148 $this->assertIsArray($result);
149 $this->assertEmpty($result);
150 }
151
152 public function test_getCodesByRegUserId_empty_for_nonexistent(): void {
153 $result = $this->main->getCore()->getCodesByRegUserId(999999);
154 $this->assertIsArray($result);
155 $this->assertEmpty($result);
156 }
157
158 // ── encodeMetaValuesAndFillObjectList ─────────────────────────
159
160 public function test_encodeMetaValuesAndFillObjectList_returns_array(): void {
161 $meta = json_encode(['desc' => 'Test Description']);
162 $result = $this->main->getCore()->encodeMetaValuesAndFillObjectList($meta);
163 $this->assertIsArray($result);
164 $this->assertEquals('Test Description', $result['desc']);
165 }
166
167 public function test_encodeMetaValuesAndFillObjectList_fills_defaults(): void {
168 $result = $this->main->getCore()->encodeMetaValuesAndFillObjectList('{}');
169 $this->assertIsArray($result);
170 $this->assertArrayHasKey('desc', $result);
171 $this->assertArrayHasKey('redirect', $result);
172 $this->assertArrayHasKey('formatter', $result);
173 }
174
175 // ── isCodeSizeExceeded / checkCodesSize ──────────────────────
176
177 public function test_isCodeSizeExceeded_returns_bool(): void {
178 $result = $this->main->getCore()->isCodeSizeExceeded();
179 $this->assertIsBool($result);
180 }
181
182 public function test_checkCodesSize_method_exists(): void {
183 $this->assertTrue(
184 method_exists($this->main->getCore(), 'checkCodesSize'),
185 'checkCodesSize method should exist'
186 );
187 }
188 }
189