@@ -608,8 +608,13 @@ jobs:
608608
609609 class Test_Free_Gift_Bulk_Coupon_Generator extends WP_UnitTestCase {
610610 public function test_plugin_loaded() {
611+ // Test the helper function exists and returns true
611612 $this->assertTrue(function_exists('wc_free_gift_bulk_coupons_is_loaded'), 'Plugin helper function should exist');
612- $this->assertTrue(wc_free_gift_bulk_coupons_is_loaded(), 'Plugin was not loaded correctly');
613+ $this->assertTrue(wc_free_gift_bulk_coupons_is_loaded(), 'Plugin class should be loaded');
614+ }
615+
616+ public function test_plugin_class_exists() {
617+ $this->assertTrue(class_exists('WooCommerceFreeGiftBulkCoupons'), 'Main plugin class should exist');
613618 }
614619
615620 public function test_wordpress_version_compatibility() {
@@ -622,25 +627,20 @@ jobs:
622627 "WordPress version {$wp_version} should be >= {$min_wp_version}");
623628 }
624629
625- public function test_woocommerce_loaded() {
626- $this->assertTrue(class_exists('WooCommerce'), 'WooCommerce should be loaded');
627- $this->assertTrue(function_exists('WC'), 'WooCommerce WC() function should be available');
630+ public function test_plugin_constants() {
631+ $this->assertTrue(defined('SCG_PLUGIN_VERSION'), 'Plugin version constant should be defined');
632+ $this->assertTrue(defined('SCG_PLUGIN_URL'), 'Plugin URL constant should be defined');
633+ $this->assertTrue(defined('SCG_PLUGIN_PATH'), 'Plugin path constant should be defined');
634+ $this->assertEquals('1.4.0', SCG_PLUGIN_VERSION, 'Plugin version should match expected version');
628635 }
629636
630- public function test_woocommerce_version_compatibility() {
631- if (class_exists('WooCommerce')) {
632- $wc_version = WC()->version ?? null;
633- if ($wc_version) {
634- $min_wc_version = '5.0';
635- $this->assertTrue(version_compare($wc_version, $min_wc_version, '>='),
636- "WooCommerce version {$wc_version} should be >= {$min_wc_version}");
637- }
638- }
639- }
640-
641- public function test_plugin_dependencies() {
642- // Test that our plugin recognizes WooCommerce dependency
643- $this->assertTrue(class_exists('WooCommerceFreeGiftBulkCoupons'), 'Main plugin class should exist');
637+ public function test_plugin_instance() {
638+ $instance = WooCommerceFreeGiftBulkCoupons::get_instance();
639+ $this->assertInstanceOf('WooCommerceFreeGiftBulkCoupons', $instance, 'Plugin should return valid instance');
640+
641+ // Test singleton pattern
642+ $instance2 = WooCommerceFreeGiftBulkCoupons::get_instance();
643+ $this->assertSame($instance, $instance2, 'Plugin should use singleton pattern');
644644 }
645645 }
646646 EOF
0 commit comments