All notable changes to code-distortion/adapt will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Added #[Before] attribute to the
initialiseAdapttrait, so Adapt is picked up properly in PHPUnit 12+ - Added #[Test] and #[DataProvider] attributes to tests where they were missing
- Fixed a bug causing an exception when building a database on behalf of a remote instance
- Added support for PHP 8.4
- Fixed a bug that caused a problem when auto-increment fields had a comment
- Added support for PHP 8.3
- Added support for Laravel 11
- Fixed issue when building databases for multiple connections, and none are specified as the default - thanks to manu144x for raising the problem
- Fixed an issue when using the databaseInit() method when using older versions of Laravel
- Fixed a bug that caused the Adapt storage directory to be resolved incorrectly when using absolute paths - thanks to manu144x for raising the problem
- Initial import and migration paths can be absolute
(incorrectly tagged release)
- Fixed a bug affecting use in Laravel 10
- Fixed a bug when handling a remote-build request
- Fixed a path resolution bug that broke some tests
- Fixed a bug in the
--repeat=xfix from 0.12.4, in older versions of Laravel
- Added support for Laravel 10
- Fixed a bug that stopped database/s from being prepared after the first run, when using the
--repeat=xoption - thanks to carltondickson for raising the issue - Fixed a bug that caused execution to stop, when running tests from outside the project root-dir - thanks to carltondickson for raising the issue
- Added support for PHP 8.2
- Added a more useful exception when a chosen connection doesn't exist
- Fixed bug when detecting which seeders to run
- Added the
getShareHeaders()method to replace thegetShareConnectionsHeaders()method added to test classes (which is now deprecated, but will still work)
- Minor tweaks to documentation
- Fix for calls to the
databaseInit(..)method
- Added the
default_connectionconfig setting - Added the
ADAPT_DEFAULT_CONNECTION.env value - Added the
ADAPT_CACHE_INVALIDATION_ENABLED.env value - Added the
cache_invalidation.locationsconfig setting to replacelook_for_changes_in(which is now deprecated, but will still work) - Added the
cache_invalidation.checksum_methodconfig setting to replacecache_invalidation_method(which is now deprecated, but will still work) - Added the
cache_invalidation.purge_staleconfig setting to replaceremove_stale_things(which is now deprecated, but will still work) - Added the
build_sources.initial_importsconfig setting to replaceinitial_imports(which is now deprecated, but will still work) - Added the
build_sources.migrationsconfig setting to replacemigrations(which is now deprecated, but will still work) - Added the
build_sources.seedersconfig setting to replaceseeders(which is now deprecated, but will still work) - Added the
$transactionsconfig setting to replace$reuseTransaction(which is now deprecated, but will still work) - Added the
$journalsconfig setting to replace$reuseJournal(which is now deprecated, but will still work) - Added the
transaction(..)DatabaseBuilder method to replacereuseTransaction(..)(which is now deprecated, but will still work) - Added the
noTransaction()DatabaseBuilder method to replacenoReuseTransaction()(which is now deprecated, but will still work) - Added the
journal(..)DatabaseBuilder method to replacereuseJournal(..)(which is now deprecated, but will still work) - Added the
noJournal()DatabaseBuilder method to replacenoReuseJournal()(which is now deprecated, but will still work) - Added a check to make sure that a connection isn't being prepared more than once
- Added detection for when a test rolls-back the wrapper-transaction - throws an exception - thanks to ibrunotome for raising the issue
- Improved the code that picks the default connection to use - it now happens after calling
databaseInit(..)(instead of just setting it as soon as ->makeDefault() is called) - Improved the logic that purges stale databases. It now only removes databases from connections that are being prepared (unused connections are ignored). Saves long connection time-outs - thanks to ibrunotome for raising the issue
- Changed the structure of the config file - Please review your copy to keep it up to date
- Deprecated the
noCacheInvalidationMethod(..)DatabaseBuilder method - Deprecated the
cacheInvalidationMethod()DatabaseBuilder method - Deprecated the
scenarios(..)DatabaseBuilder method - Deprecated the
noScenarios()DatabaseBuilder method - Seeders are now allowed to run when initial-imports exist but migrations don't
- Initial-imports are now considered when working out whether snapshots should be taken after running migrations.
- Replaced
DatabaseBuilderwithDatabaseDefinitionwhen calling the user-defineddatabaseInit(..)method (usingDatabaseBuilderis now deprecated, but will still work)
- Added the
ADAPT_CACHE_INVALIDATION_CHECKSUM_METHOD.env value to replaceADAPT_CACHE_INVALIDATION_METHOD - Added the
ADAPT_CACHE_INVALIDATION_PURGE_STALE.env value to replaceADAPT_REMOVE_STALE_THINGS - Removed the
$scenarios(and deprecated$scenarioTestDBs) test-class properties. It can be set at the config level
- Laravel connects to the database in some situations before Adapt runs (e.g. when using debug-bar during remote requests). Adapt now disconnects from these database connections first, so the correct database/s can be re-connected to - thanks to ibrunotome for raising the issue
- Added separate storage directories for file-based databases (i.e. SQLite), snapshot files, and share-config files
- Added a GitHub issue template
- To help with debugging - The version of PHP, Laravel, PHPUnit, Pest, Adapt, MySQL, PostgreSQL, SQLite are logged
- Included when Pest is being used in the logs
- Added
AdaptDatabasetrait to replaceLaravelAdapt(which is now deprecated, but will still work) - Added the
initial_importsconfig setting to replacepre_migration_imports(which is now deprecated, but will still work) - Added the
$initialImportstest-class property to replace$preMigrationImports(which is now deprecated, but will still work) - Added the
scenariosconfig setting to replacescenario_test_dbs(which is now deprecated, but will still work) - Added the
$scenariostest-class property to replace$scenarioTestDBs(which is now deprecated, but will still work) - Added the
cache_invalidation_methodconfig setting to replacecheck_for_source_changes(which is now deprecated, but will still work) - Added
$this->useAdapt(..)to replace$this->shareConfig(..)(which is now deprecated, but will still work), when browser testing - Added support for Laravel's
$seedertest-class property, to indicate which seeder class to run - Added support for
RefreshDatbase'sbeforeRefreshingDatabase()andafterRefreshingDatabase()test-class callbacks, which are now called before and after preparing the database, respectively - Added a new log verbosity setting (0 = minimal, 2 = most details)
- Improved logging output
- Added the option to create file checksums based on their modified times
- Adapt can't run at the same time as Laravel's
RefreshDatabase,DatabaseTransactionsandDatabaseMigrationstraits. Added detection for these, and when also present in a test, an exception is thrown - thanks to ibrunotome for raising the issue
- Disabled the snapshot setting for SQLite :memory: tests
- Renamed build-hash, snapshot-hash and scenario-hash to build-checksum, snapshot-checksum and scenario-checksum (appears in the logs)
- Changed the default method when checking for file changes from "content" to the new method "modified"
- Renamed the
adapt:list-db-cachescommand toadapt:list - Renamed the
adapt:remove-db-cachescommand toadapt:clear(to follow the convention from Laravel's other clearing commands) - Renamed the
ADAPT_SCENARIO_TEST_DBS.env value toADAPT_SCENARIOS - Renamed the
ADAPT_CHECK_FOR_SOURCE_CHANGES.env value toADAPT_CACHE_INVALIDATION_METHOD
- Added the reason why the database couldn't be reused to the logs
- Added (FORCE) when dropping a PostgreSQL database to drop it when other connections exist (falls back to the original query if FORCE isn't available in the current PostgreSQL version) - thanks to ibrunotome for raising the issue
- Support for PostgreSQL
- The database driver is now included in the list of databases when using adapt:list and adapt:remove
- Fixed a bug that stopped config files with a '.' in the filename to be re-initialised when reloading Laravel's config
- Updated logic so snapshot files won't be considered stale when the using a database that doesn't support reuse
- Disabled foreign-id checks in MySQL when reverting journaled changes
- Updated the MySQL journaling code to ignore views when looking for tables to watch
- Updated the MySQL verification code to ignore views when looking for tables to check
- Fixed a bug that stopped the
adapt:listandadapt:removecommands from working when the config isn't published - Fixed a bug stopping SQLite databases from being used when scenarios were enabled
- Improved logging output
- Improvements to the way SQLite :memory: databases are handled
- Updated the SQLite code to require that database filenames don't contain a directory part, just the filename. Now these databases are put into Adapt's
/database/adapt-test-storagedirectory automatically - to include them in the housekeeping
- Improved the way the service-provider registers the RemoteShareMiddelware - it's now applied it globally, instead of being added to each middleware group
- Updated the service-provider to detect requests from external instances of Adapt (instead of waiting for the middleware to run this check). When detected, it gets Laravel to use the testing environment
- Fixed a re-use Journal bug when determining if a table's structure has changed, after its auto-increment value increased
- Added EXPERIMENTAL journaling functionality for MySQL databases (needs documentation), a new way to re-use databases without using transactions
- Added EXPERIMENTAL database verification functionality for MySQL databases (needs documentation). This checks the database structure and content after each test has run, to ensure it hasn't changed. This is designed to be used as a safety-check if desired when reusing databases using journaling (above). This can be turned on using the
verify_databasesconfig setting - Added a check to make sure the
.env.testingfile exists. Laravel falls back to using the.envvalues for its testing environment when.env.testingdoesn't exist. This can cause unexpected results when wiping and re-building databases - Added the
check_for_source_changesconfig option which allows thelook_for_changes_inchecking to be turned off - Added a check to see if Laravel's
--recreate-databasesoption has been specified when parallel testing. If so, it throws an exception (asphp artisan adapt:removeshould be used instead) - Added the ability when building databases remotely, for the initial build-hash to be re-used, saving on it's re-calculation during each request
- When a database has been built (or reused) remotely earlier in the test run, this database can now be re-used locally without needing to send extra http requests to build / check it again
- Added the remote-build's error message, to the exception thrown locally when a remote-build fails
- When existing databases need to be rebuilt, they're now dropped and re-created (instead of having their contents removed by internally running Laravel's
php artisan db:wipe) - Tweaked the descriptions of config values
- Improved logging content, and updated durations to be rendered in milliseconds, seconds and minutes
- Renamed the remote-sharing cookie, which is used for sharing configuration settings between instances of Adapt (e.g. when browser testing), as it seems like it wasn't being passed anymore
- The test-class property
reuseTestDBshas been replaced with$reuseTransaction - The config
reuse_test_dbssetting has been replaced withreuse.transactions - The Builder
reuseTestDBs()andnoReuseTestDBs()methods (that you might call in a test'sdatabaseInit(..)method) have been replaced withreuseTransaction()andnoReuseTransaction()
- Added an exception when the migrations fail
- Added a check to make sure the local and remote Adapt installations have the same session.driver during browser tests. Otherwise, logins won't be respected by the remote codebase
- Added a check to make sure SQLite databases aren't built remotely - as it doesn't really make sense to do that
- Added a check to make sure SQLite :memory: databases aren't used when browser testing - as this won't work
- Made improvements to the logging output
- Added extra checking around the remote-build http request process
- Improvements to the data passed between Adapt installations and processes that handle them
- Now uses Laravel's process to reload Laravel's config (e.g. when switching to the testing environment)
- Improvements when acting as a remote and switching to the testing environment
- Removed the
--env-fileoption from the Adapt console commands - Changed the normal logging level from "info" to "debug"
- Laravel normally forces
session.driverto be "array" for tests, but not forphp artisan dusktests. To match this functionality, thesession.driverfrom the.env.testingenvironment is picked for browser tests (even when not explicitly runningphp artisan dusk) - Fixed the test-class name that's shown in the logs
- Fixed the code that imported new
.envvalues, to now properly populate theenv(…)helper with the new data - Updated the remote-build code to pick up any url, as long as it ends in the normal remote-build path
- Added support for Laravel 9
- Added EXPERIMENTAL remote-building functionality (needs documentation)
- Added config setting:
remove_stale_things(so the remote Adapt installation has a setting and can be told not to remove) - Added config setting:
remote_build_url - Added test property:
$remoteBuildUrl
- Added config setting:
- Added new helper method
initialiseAdaptIfNeeded($this)for when Adapt needs to be initialised inside thesetUp()method - Added support for Laravel's
$seed = trueproperty - Added support for Laravel's
$seeder = 'xyzSeeder'property (as a string)
- Renamed "invalid" databases + snapshot files to "stale"
- Removed deprecated method
$this->useCurrentConfig(…)
- Fix when using
$this->newBuilder(…)method inside a test's->databaseInit(…)method
Mis-tag - updates moved into 0.7.0
- Updated dependencies
- Added support for PHP 8.1
- Added custom exception to give more details when database access is denied
- Removed the "test_" prefix added to test-database names
- Fixed a bug that caused failure on new installations - as the storage-directory was used before being checked/created
- Updated the url shown in the exception thrown when the wrapper-transaction is committed
- Improved documentation
- Split the snapshot options out to be controllable when and when not reusing a database
- A exception is now thrown when a test runs in a wrapper-transaction, and commits it
- A mutex when removing invalid databases, snapshots and orphaned temp-config files
- A warning when a test commits its transaction unexpectedly - with details about the guilty test
- Write the re-use meta-data table earlier - to reduce the risk of a database not being recognised as a test-database (when the script building it exits early)
- MySQL dump files are now written to a temporary file first before being renamed
- Updated config file comments
- Renamed the browser testing method ->useCurrentConfig($browser) to ->shareConfig($browser) - useCurrentConfig is deprecated
- Removed the config value 'transaction_rollback' and test property $transactionRollback
- Merged the transaction functionality with reuse-test-dbs
- Stopped Adapt from running the "DatabaseSeeder" seeder by default - to make it a drop-in replacement for Laravel's traits
- Re-arranged the config values
- Removed internal use of Carbon
- Added a grace period before automatically deleting invalid databases and snapshots - so now, swapping your repo branch back and forth won't remove the old databases straight away
- Bug stopping a sql-dump from being created when browser testing is detected
- Renamed the .env value ADAPT_DYNAMIC_TEST_DBS to ADAPT_SCENARIO_TEST_DBS
- Renamed the .env value ADAPT_TRANSACTIONS to ADAPT_TRANSACTION_ROLLBACK
- Renamed the config value 'dynamic_test_dbs' to 'scenario_test_dbs'
- Renamed the config value 'transactions' to 'transaction_rollback'
- Renamed the test property $dynamicTestDBs to $scenarioTestDBs
- Renamed the test property $transactions to $transactionRollback
- Updated the ServiceProvider to add AdaptMiddleware to the middleware-groups that exist, instead of arbitrarily picking 'api' and 'web'
- Added a fix when the middleware re-sets cookies during browser testing.
- Added the ability to turn database-building off (useful for Dusk browser tests with no database)
- Allow Dusk tests to pass a config to the browser more than once
- Added the ability to change the connection a DatabaseBuilder connects to (e.g. to get the first Builder build for a non "default" connection)
- Improved documentation
- Added functionality for each test's config settings to be passed to the server via the browser during Dusk browser tests
- Added the ability for ParaTest to run Dusk browser testss
- Added prefix "test_" to test databases e.g. "test_your_database_name_17bd3c_d266ab43ac75"
- Changed the name of the config file from code-distortion.adapt.php to code_distortion.adapt.php to be consistent with Laravel
- Updated config keys to contain underscores instead of hyphens to be consistent with Laravel
- the wording of the log message when removing an old database
- Added support for PHP 8.0
- PSR12 formatting
- Documentation updates
- Bumped dependencies and added test coverage to include Laravel 8
- ParaTest's TEST_TOKEN is now detected so that separate databases are created for each para-test instance (see https://github.com/paratestphp/paratest#test-token)
- Refactored code and increased test coverage
- Improved test coverage
- Documentation for use with PEST
- Changed the name of the service provider class from LaravelServiceProvider to AdaptLaravelServiceProvider
- Migration paths can be absolute, or relative to the base of your project. Before, when using Laravel < 5.6 these directories had to be relative
- Adapt is booted automatically now when the LaravelAdapt trait is present in a test (removed the need to update the base TestCase class setUp() method to initialise Adapt)
- Added MacOS to the GitHub actions to provide better test coverage
- Updated the documentation to show that Laravel is supported as far back as 5.1 to match the test coverage
- Improvements to documentation
- Turned snapshots off by default in the config but turn on automatically when a browser test is detected
- The artisan command lists show the size of mysql databases
- Boot test code bug fix
- Beta release