Adds DatabaseBootstrapTrait and OsposConfigFixtureTrait to replace
duplicated per-file setUp()/tearDown() bootstrap and OSPOS config mock
boilerplate across test classes, bringing them in line with the
ItemsControllerTest gold-standard shape.
Fixes the real root cause of tabular_helperTest's suite-order-dependent
failure: dropAllForeignKeyConstraints()/foreignKeyExists()/
dropColumnIfExists() temporarily blank the shared connection's DBPrefix
via overridePrefix() but never restored it if the query between the two
calls threw (e.g. migration_helperTest's mocked-failure tests) -
permanently corrupting prefixed table lookups for the rest of the
process. Wrapped each in try/finally. Also widens executeScript() to
accept an explicit connection so migration SQL can't silently run
against the wrong DB group.
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
These landed on master by accident via a local branch that was
mistakenly created tracking OpensourcePOS/master directly, rather than
pushed as its own branch. Reverting to restore master to its prior
state; the reverted work will come back through a proper PR instead.
This reverts commit 00bf4cb8af.
This reverts commit 37cc1b15e7.
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Adds DatabaseBootstrapTrait and OsposConfigFixtureTrait to replace
duplicated per-file setUp()/tearDown() bootstrap and OSPOS config mock
boilerplate across test classes, bringing them in line with the
ItemsControllerTest gold-standard shape.
Fixes the real root cause of tabular_helperTest's suite-order-dependent
failure: dropAllForeignKeyConstraints()/foreignKeyExists()/
dropColumnIfExists() temporarily blank the shared connection's DBPrefix
via overridePrefix() but never restored it if the query between the two
calls threw (e.g. migration_helperTest's mocked-failure tests) -
permanently corrupting prefixed table lookups for the rest of the
process. Wrapped each in try/finally. Also widens executeScript() to
accept an explicit connection so migration SQL can't silently run
against the wrong DB group.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(appconfig): refresh cached settings once and avoid stale same-request reads
Addresses issue #3693, which has two related problems:
1. Repeated cache refreshes. Appconfig::batch_save() called save() per key,
and save() unconditionally deleted + reloaded + re-cached the settings after
every single write. A settings page with dozens of keys therefore refreshed
the cache dozens of times in one request. batch_save() now persists all keys
in the transaction and refreshes the cached settings exactly once after it
commits successfully. save() keeps refreshing so direct single saves still
work.
2. Stale same-request reads. Controllers copy config(OSPOS::class)->settings at
construction time, so after a save in the same request the local copy is out
of date. Config::postSaveInvoice() read the stale invoice_enable /
default_register_mode values and sent the user to the wrong screen (e.g.
opening a new sale instead of the invoice form after saving an enabled
invoice). It now reads the freshly refreshed settings.
Adds tests/Models/AppconfigTest.php covering batch_save() and save() refreshing
the cached settings after a successful write.
* test(3693): adopt test{Method}_{Purpose} naming convention
Align AppconfigTest method names with the convention from #4730
(testBatchSave_PersistsAllKeysAndRefreshesCachedSettings, etc.), per review.
* style(config): remove inline comments per review feedback
---------
Co-authored-by: objecttothis <17935339+objecttothis@users.noreply.github.com>