@@ -85,4 +85,66 @@ public function test_pre_update_option_bootstrap_version() {
8585 $ bootstrap_version_option_value = get_option ( Settings::BOOTSTRAP_VERSION_OPTION_NAME );
8686 $ this ->assertEquals ( $ constant_value , $ bootstrap_version_option_value );
8787 }
88+
89+ /**
90+ * Tests pre_update_option_enable_css_grid() filter. Option should be saved to constant value if set and always be false if Bootstrap < 5.
91+ *
92+ * This test must run in a separate process as it defines constants!
93+ *
94+ * @runInSeparateProcess
95+ * @preserveGlobalState disabled
96+ */
97+ public function test_pre_update_option_enable_css_grid () {
98+ // Option value should always be set to false if Bootstrap version < 5
99+ update_option ( Settings::BOOTSTRAP_VERSION_OPTION_NAME , '4 ' );
100+ update_option ( Settings::ENABLE_CSS_GRID_OPTION_NAME , true );
101+ $ this ->assertEquals ( false , get_option ( Settings::ENABLE_CSS_GRID_OPTION_NAME ) );
102+
103+ // Option value should be set if constant is not set and Bootstrap version is >= 5
104+ update_option ( Settings::BOOTSTRAP_VERSION_OPTION_NAME , '5 ' );
105+ $ option_value = true ;
106+ update_option ( Settings::ENABLE_CSS_GRID_OPTION_NAME , $ option_value );
107+ $ enable_css_grid_option_value = get_option ( Settings::ENABLE_CSS_GRID_OPTION_NAME );
108+ $ this ->assertEquals ( $ option_value , $ enable_css_grid_option_value );
109+
110+ // Constant value should be saved as option value if available.
111+ $ constant_value = true ;
112+ define ( Settings::ENABLE_CSS_GRID_CONSTANT_NAME , $ constant_value );
113+ $ option_value = false ;
114+ update_option ( Settings::ENABLE_CSS_GRID_OPTION_NAME , $ option_value );
115+ $ enable_css_grid_option_value = get_option ( Settings::ENABLE_CSS_GRID_OPTION_NAME );
116+ $ this ->assertEquals ( $ constant_value , $ enable_css_grid_option_value );
117+
118+ // Option value should be set to false if Bootstrap version < 5 even if constant is set to true
119+ update_option ( Settings::BOOTSTRAP_VERSION_OPTION_NAME , '4 ' );
120+ $ this ->assertEquals ( false , get_option ( Settings::ENABLE_CSS_GRID_OPTION_NAME ) );
121+ }
122+
123+ /**
124+ * Tests test_is_bootstrap_5_active() helper function.
125+ *
126+ * This test must run in a separate process as it defines constants!
127+ *
128+ * @runInSeparateProcess
129+ * @preserveGlobalState disabled
130+ */
131+ public function test_is_css_grid_enabled () {
132+ // CSS grid shouldn't be enabled by default
133+ $ this ->assertEquals ( false , Settings::is_css_grid_enabled () );
134+
135+ // Should be true if Bootstrap version 5 is selected and css grid option is enabled.
136+ update_option ( Settings::BOOTSTRAP_VERSION_OPTION_NAME , '5 ' );
137+ update_option ( Settings::ENABLE_CSS_GRID_OPTION_NAME , true );
138+ $ this ->assertEquals ( true , Settings::is_css_grid_enabled () );
139+
140+ // Should be true if Bootstrap version 5 is selected and css grid constant is set to true even if option is set to false.
141+ define ( Settings::ENABLE_CSS_GRID_CONSTANT_NAME , true );
142+ update_option ( Settings::ENABLE_CSS_GRID_OPTION_NAME , false );
143+ $ this ->assertEquals ( true , Settings::is_css_grid_enabled () );
144+
145+ // Should be always false when Bootstrap version is < 5
146+ update_option ( Settings::BOOTSTRAP_VERSION_OPTION_NAME , '4 ' );
147+ update_option ( Settings::ENABLE_CSS_GRID_OPTION_NAME , true );
148+ $ this ->assertEquals ( false , Settings::is_css_grid_enabled () );
149+ }
88150}
0 commit comments