File tree Expand file tree Collapse file tree
pfSense-pkg-RESTAPI/files/usr/local/pkg/RESTAPI/Core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -85,8 +85,7 @@ class TestCase {
8585 break ;
8686 } catch (Error | Exception $ e ) {
8787 # Tear down any resources created by this test before retrying or exiting
88- $ config = $ original_config ;
89- write_config ("Restored config after API test ' $ method' " );
88+ $ this ->restore_config ($ original_config );
9089 $ this ->teardown ();
9190
9291 # If we have retries left, wait the configured delay and try again
@@ -101,15 +100,26 @@ class TestCase {
101100 }
102101
103102 # Restore the config as it was when the test began.
104- $ config = $ original_config ;
105- write_config ("Restored config after API test ' $ method' " );
103+ $ this ->restore_config ($ original_config );
106104 }
107105 }
108106
109107 # Teardown the test case now that all tests are completed
110108 $ this ->teardown ();
111109 }
112110
111+ /**
112+ * Restores the configuration to its original state and clears the Model object cache.
113+ *
114+ * @param array $original_config The original configuration to restore.
115+ */
116+ protected function restore_config (array $ original_config ): void {
117+ global $ config ;
118+ $ config = $ original_config ;
119+ Model::clear_object_cache ();
120+ write_config ("Restored config after API test ' {$ this ->method }' " );
121+ }
122+
113123 /**
114124 * Installs the required packages for this TestCase.
115125 */
You can’t perform that action at this time.
0 commit comments