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
FrontendCountConfirmedTest.php
106 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Tests for Frontend::countConfirmedStatus method. |
| 4 | */ |
| 5 | |
| 6 | class FrontendCountConfirmedTest extends WP_UnitTestCase { |
| 7 | |
| 8 | private $main; |
| 9 | |
| 10 | public function set_up(): void { |
| 11 | parent::set_up(); |
| 12 | $this->main = sasoEventtickets::Instance(); |
| 13 | |
| 14 | if (!class_exists('WC_Product_Simple')) { |
| 15 | $this->markTestSkipped('WooCommerce not available'); |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | private function createTicketCode(): array { |
| 20 | $listId = $this->main->getDB()->insert('lists', [ |
| 21 | 'name' => 'Confirmed List ' . uniqid(), |
| 22 | 'aktiv' => 1, |
| 23 | 'meta' => '{}', |
| 24 | ]); |
| 25 | |
| 26 | $product = new WC_Product_Simple(); |
| 27 | $product->set_name('Confirmed Product ' . uniqid()); |
| 28 | $product->set_regular_price('10.00'); |
| 29 | $product->set_status('publish'); |
| 30 | $product->save(); |
| 31 | |
| 32 | update_post_meta($product->get_id(), 'saso_eventtickets_is_ticket', 'yes'); |
| 33 | update_post_meta($product->get_id(), 'saso_eventtickets_list', $listId); |
| 34 | |
| 35 | $order = wc_create_order(); |
| 36 | $order->add_product($product, 1); |
| 37 | $order->calculate_totals(); |
| 38 | $order->set_status('completed'); |
| 39 | $order->save(); |
| 40 | |
| 41 | $om = $this->main->getWC()->getOrderManager(); |
| 42 | $order = wc_get_order($order->get_id()); |
| 43 | $tickets = $om->getTicketsFromOrder($order); |
| 44 | $ticketValues = array_values($tickets); |
| 45 | $codes = explode(',', $ticketValues[0]['codes']); |
| 46 | $code = trim($codes[0]); |
| 47 | |
| 48 | $codeObj = $this->main->getCore()->retrieveCodeByCode($code); |
| 49 | |
| 50 | return [ |
| 51 | 'codeObj' => $codeObj, |
| 52 | 'code' => $code, |
| 53 | ]; |
| 54 | } |
| 55 | |
| 56 | // ── countConfirmedStatus ─────────────────────────────────────── |
| 57 | |
| 58 | public function test_countConfirmedStatus_does_not_count_inactive(): void { |
| 59 | $data = $this->createTicketCode(); |
| 60 | $codeObj = $data['codeObj']; |
| 61 | $codeObj['aktiv'] = 0; // inactive |
| 62 | $this->main->getFrontend()->countConfirmedStatus($codeObj); |
| 63 | |
| 64 | // Re-fetch: should not have incremented |
| 65 | $freshObj = $this->main->getCore()->retrieveCodeByCode($data['code']); |
| 66 | $meta = json_decode($freshObj['meta'], true); |
| 67 | $confirmed = isset($meta['confirmedCount']) ? $meta['confirmedCount'] : 0; |
| 68 | $this->assertEquals(0, $confirmed); |
| 69 | } |
| 70 | |
| 71 | public function test_countConfirmedStatus_increments_with_force(): void { |
| 72 | $data = $this->createTicketCode(); |
| 73 | $codeObj = $data['codeObj']; |
| 74 | $this->main->getFrontend()->countConfirmedStatus($codeObj, true); |
| 75 | |
| 76 | $freshObj = $this->main->getCore()->retrieveCodeByCode($data['code']); |
| 77 | $meta = json_decode($freshObj['meta'], true); |
| 78 | $this->assertEquals(1, $meta['confirmedCount']); |
| 79 | } |
| 80 | |
| 81 | public function test_countConfirmedStatus_sets_first_success_on_first_call(): void { |
| 82 | $data = $this->createTicketCode(); |
| 83 | $codeObj = $data['codeObj']; |
| 84 | $this->main->getFrontend()->countConfirmedStatus($codeObj, true); |
| 85 | |
| 86 | $freshObj = $this->main->getCore()->retrieveCodeByCode($data['code']); |
| 87 | $meta = json_decode($freshObj['meta'], true); |
| 88 | $this->assertNotEmpty($meta['validation']['first_success']); |
| 89 | } |
| 90 | |
| 91 | public function test_countConfirmedStatus_increments_on_second_call(): void { |
| 92 | $data = $this->createTicketCode(); |
| 93 | $codeObj = $data['codeObj']; |
| 94 | |
| 95 | // First call |
| 96 | $this->main->getFrontend()->countConfirmedStatus($codeObj, true); |
| 97 | // Re-fetch for second call |
| 98 | $codeObj = $this->main->getCore()->retrieveCodeByCode($data['code']); |
| 99 | $this->main->getFrontend()->countConfirmedStatus($codeObj, true); |
| 100 | |
| 101 | $freshObj = $this->main->getCore()->retrieveCodeByCode($data['code']); |
| 102 | $meta = json_decode($freshObj['meta'], true); |
| 103 | $this->assertEquals(2, $meta['confirmedCount']); |
| 104 | } |
| 105 | } |
| 106 |