dolibarr/test/phpunit
VIAL-GOUTEYRON Quentin 2d44fdf49c
CLOSE #29244 Feature to merge contacts (#39512)
Add the ability to merge two contacts, the same way third parties and members
can already be merged. The merged contact is absorbed by the current one, all
its satellite data is moved, then it is deleted.

Contact::mergeContact() orchestrates everything in a single transaction, using
the new CommonObject::commonReplaceContact() helper and the replaceContact()
static methods of Contact, ActionComm and User. A replaceContact hook lets the
external modules move their own data. No schema change, no migration.

Three specific traps of this table are handled:
- llx_element_contact.fk_socpeople references llx_socpeople only when
  c_type_contact.source is 'external', and llx_user when it is 'internal', so
  both queries filter on it. Without that filter the internal assignments of
  the users would silently be moved to the merged contact.
- Contact::updateRoles(), called by update(), deletes then reinserts every
  societe_contacts row of the contact from $this->roles. It is neutralised by
  setting roles to null, and update() is called before the links are moved.
- Every table having a unique index on the contact id is deduplicated before
  its update, so the update cannot violate it. $ignoreerrors is never used:
  the FIXME of commonReplaceThirdparty() documents the links it loses.

The files are moved after the commit and not before, unlike mergeCompany() and
mergeMembers(): a failure after the move leaves them with the database rolled
back but the files already gone. A name collision renames the file instead of
losing it, and a failure is reported to the user instead of being ignored.

Access guards live in the class and not in the page, so the REST API, the
scheduled jobs and the modules benefit from them too. They cover both contacts,
fetch() by rowid applying neither an entity nor a permission filter: entity,
private contact of another user, external user, sales representative perimeter,
absorbing a shared contact into a private one, and a contact linked to a user
account (moving llx_user.fk_socpeople would let the email of that user be
rewritten from the contact card, so it requires the permission to create users).

Form::select_contact() gets a one line fix on the way: it accepts a $filter
parameter, documents it, forwards it to the ajax branch, but dropped it when
building the combo, so the merge popup could not exclude the current contact.

Known limitations, out of the scope of this pull request: merging contacts of
different entities is refused, Contact::update() neither writes url, no_email,
fk_parent nor import_key while its $nosyncuser parameter is declared but never
read, and with CONTACT_USE_SEARCH_TO_SELECT set the current contact is still
offered in the popup, contact/ajax/contact.php overwriting the filter it gets.
2026-08-19 02:26:34 +02:00
..
functional Qual: Improve test messages to help locate errors + php-cs-fixer on tests (#28272) 2024-02-19 15:28:21 +01:00
.gitignore Ignore file to avoid commiting it 2025-10-18 11:56:07 +02:00
AbstractRestAPITest.php Debug v24 2026-06-21 15:20:14 +02:00
AccountancySystemTest.php test: phpunit: add AccountancySystemTest 2024-12-04 08:10:37 +01:00
AccountingAccountTest.php exit code must be >= 0 (#35311) 2025-09-12 02:29:23 +02:00
ActionCommTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
AdherentTest.php CI 2026-05-22 12:17:17 +02:00
AdminLibTest.php Fix comparison on version to show the warning to upgrade database 2025-08-20 16:02:46 +02:00
AllTests.php NEW Link manage extrafields and phpunit test for the class (#39514) 2026-08-19 02:18:46 +02:00
AssetModelTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
BankAccountTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
BarcodeTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
BlockedLogAndLNETest.php More robust phpunit 2026-01-29 11:25:33 +01:00
BOMTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
BonPrelevementTest.php FIX bon prelevement SEPA generation (#38998) 2026-07-04 13:27:58 +02:00
BonVirementTest.php FIX bon prelevement SEPA generation (#38998) 2026-07-04 13:27:58 +02:00
BookKeepingTest.php tests: add BookKeeping test (#34062) 2025-05-05 21:31:48 +02:00
BuildDocTest.php Fix CI 2026-03-02 15:15:44 +01:00
CategorieTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
CDavLibTest.php Revert "/imports/index.php wrongly shows access refused (#39379)" (#39386) 2026-08-04 22:23:57 +02:00
ChargeSocialesTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
CMailFileTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
CodingPhpTest.php Qual: Fix 'SqlInjection' notices (#39216) 2026-07-23 19:06:39 +02:00
CodingSqlTest.php Fix CI 2026-02-21 12:22:59 +01:00
CommandeFournisseurTest.php Clean code 2025-10-17 23:43:28 +02:00
CommandeTest.php add phpcs rule extension (#36561) 2026-01-15 16:05:06 +01:00
CommentTest.php NEW: Add phpunit test for Comment class (#39540) 2026-08-15 16:03:53 +02:00
CommonClassTest.class.php Revert "/imports/index.php wrongly shows access refused (#39379)" (#39386) 2026-08-04 22:23:57 +02:00
CommonInvoiceTest.php Fix CI 2026-01-08 13:06:30 +01:00
CommonObjectTest.php FIX isInt() does not detect sized integer types (tinyint, bigint) (#39236) 2026-07-20 15:30:28 +02:00
CompanyBankAccountTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
CompanyLibTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
ContactTest.php CLOSE #29244 Feature to merge contacts (#39512) 2026-08-19 02:26:34 +02:00
ContratTest.php Fix contract update method. Add phpunit for TDD. 2025-03-07 16:02:18 +01:00
CoreTest.php Qual: Improve test messages to help locate errors + php-cs-fixer on tests (#28272) 2024-02-19 15:28:21 +01:00
CronjobTest.php NEW: Add phpunit test for Cronjob class (#39541) 2026-08-15 18:22:45 +02:00
DateLibTest.php Automated merge from 22.0 to 23.0 by tool pullmerge.sh 2026-07-19 15:41:05 +02:00
DateLibTzFranceTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
DAVLibTest.php Revert "/imports/index.php wrongly shows access refused (#39379)" (#39386) 2026-08-04 22:23:57 +02:00
DiscountTest.php Merge branch '23.0' of git@github.com:Dolibarr/dolibarr.git into develop 2026-07-16 00:00:17 +02:00
DolDeprecationHandlerTest.php Update DolDeprecationHandlerTest 2025-02-19 15:53:56 +01:00
DoliDBTest.php Try to fix CI for pgsql 2025-12-22 03:45:20 +01:00
DolresourceTest.php NEW: Add phpunit test for Dolresource class (#39520) 2026-08-14 20:31:06 +02:00
DonTest.php NEW: Add phpunit tests for Don and PaymentDonation classes (#39539) 2026-08-19 01:40:33 +02:00
EmailCollectorTest.php Fix #39005 keep UTF-8 body extraction values (#39011) 2026-06-29 20:24:02 +02:00
EntrepotTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
EvalMathTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
ExampleTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
ExpeditionTest.php fix parameters (#35209) 2025-09-03 22:33:25 +02:00
ExpenseReportTest.php FIX Missing comma in ExpenseReportLine::fetch SQL (#38767) 2026-06-14 01:12:13 +02:00
ExportTest.php QUAL Move function csvClean into functions2.lib.php 2024-10-03 21:36:39 +02:00
ExtraFieldsTest.php FIX #30801 Filter a dependent select list of extrafields when the field is edited alone (#39488) 2026-08-15 03:04:31 +02:00
FactureFournisseurTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
FactureRecTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
FactureTest.php More robust phpunit 2026-01-29 11:25:33 +01:00
FactureTestRounding.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
FichinterTest.php Fix intervention update sql error (#33916) 2025-04-18 20:01:58 +02:00
file_import_company_1.csv Add phpunit to test the rename/move into a corrupted pdf file. 2024-02-17 18:59:57 +01:00
file_pdf_with_js.pdf.jpg Add phpunit to test the rename/move into a corrupted pdf file. 2024-02-17 18:59:57 +01:00
FilesLibMoveDirTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
FilesLibTest.php FIX accounting export: enhance file metadata return and secure access checks (#39218) 2026-07-20 02:50:31 +02:00
FormAdminTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
FormTest.php fix: keep full product label searchable in combo (#39057) 2026-07-06 23:42:58 +02:00
Functions2LibTest.php NEW Add function to manipulate emojis 2024-05-14 18:19:48 +02:00
FunctionsBELibTest.php Execute phpunit for functionsbe in all tests 2025-08-26 05:27:02 +02:00
FunctionsLibTest.php NEW Add PHPUnit tests for dol_print_size, dolGetFirstLastname, jsonOrUnserialize, picto_from_langcode (#39553) 2026-08-19 01:20:00 +02:00
FunctionsNumToWordTest.php FIX: French amount in words (cent/vingt agreement, et, hyphens, mille/million, centimes) (#38945) 2026-06-22 14:34:52 +02:00
GetUrlLibTest.php Fix use of numeric hostname 2026-07-29 12:16:48 +02:00
HolidayTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
ImagesLibTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
imap_header.txt
imap_htmlmsg.txt Clean files 2026-01-07 19:01:54 +01:00
imap_plaintext.txt Clean files 2026-01-07 19:01:54 +01:00
img250x20.png
img250x50.jpg
imgsvgwithjs.svg
ImportTest.php Qual: Improve test messages to help locate errors + php-cs-fixer on tests (#28272) 2024-02-19 15:28:21 +01:00
InventoryTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
JsonLibTest.php Merge branch '20.0' of git@github.com:Dolibarr/dolibarr.git into develop 2024-07-13 17:47:55 +02:00
KnowledgeRecordTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
LangTest.php fix french comments (#39019) 2026-06-30 12:25:04 +02:00
LesscTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
LinkTest.php NEW Link manage extrafields and phpunit test for the class (#39514) 2026-08-19 02:18:46 +02:00
LoanScheduleTest.php NEW: Add phpunit tests for LoanSchedule and PaymentLoan classes (#39537) 2026-08-19 01:37:51 +02:00
LoanTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
MarginsLibTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
ModuleBuilderLibTest.php NEW: ModuleBuilder - selectable object tabs (+ fixes for multi-object generation) (#38570) 2026-06-09 19:04:00 +02:00
ModuleBuilderShowOnComboboxTest.php FIX : ModuleBuilder apply showoncombobox to fields other than ref/code (#38904) 2026-06-21 23:30:54 +02:00
ModuleBuilderTemplateConventionsTest.php NEW: ModuleBuilder - consistent status labels and explicit trigger naming (#38883) 2026-08-17 21:41:18 +02:00
ModulesTest.php Try fix CI 2026-06-21 19:16:53 +02:00
MouvementStockTest.php FIX Stock balance truncated to int for fractional qty (#38806) 2026-06-15 14:18:44 +02:00
MultiCurrencyTest.php NEW: Add phpunit test for MultiCurrency class (#39534) 2026-08-15 16:03:41 +02:00
NamingContractTest.php don't take care of some french comments and fix false positive (#39007) 2026-06-29 19:28:28 +02:00
NumberingModulesTest.php Debug v23 2026-02-17 16:59:07 +01:00
ODFTest.php QUAL Add get_substitutionarray_each_var_object in phpunit 2025-02-06 12:04:41 +01:00
OpensurveysondageTest.php Add opensurveysondage phpunit test (#39522) 2026-08-14 14:57:48 +02:00
PaiementTest.php add new test (#39001) 2026-07-01 19:22:08 +02:00
PaymentDonationTest.php NEW: Add phpunit tests for Don and PaymentDonation classes (#39539) 2026-08-19 01:40:33 +02:00
PaymentLoanTest.php NEW: Add phpunit tests for LoanSchedule and PaymentLoan classes (#39537) 2026-08-19 01:37:51 +02:00
PaymentVATTest.php NEW: Add phpunit test for PaymentVAT class (#39544) 2026-08-15 18:21:48 +02:00
PaypalTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
PdfDocTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
PgsqlTest.php Try to fix CI for pgsql 2025-12-22 03:45:20 +01:00
phpunit.dtd
phpunittest.xml Update files after moving build into dev/ 2025-01-05 14:46:26 +01:00
PricesTest.php Qual: Fix french comments and improve detector (#39026) 2026-07-01 12:26:51 +02:00
ProductTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
ProfidLibTest.php FIX isValidTinForES() rejects almost every Spanish NIE starting with T (#39384) 2026-08-04 22:48:15 +02:00
ProjectTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
PropalTest.php Fix regression 2025-10-16 21:26:35 +02:00
ReceptionTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
RemiseChequeTest.php NEW: Add phpunit test for RemiseCheque class (#39543) 2026-08-19 01:39:35 +02:00
RepositoryTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
RestAPIContactTest.php Fix travis 2025-03-24 21:42:16 +01:00
RestAPIDocumentTest.php Fix travis 2025-03-24 21:43:38 +01:00
RestAPIMoTest.php Fix travis 2025-03-24 21:44:57 +01:00
RestAPIUserTest.php Fix travis 2025-03-24 18:23:31 +01:00
ScriptsTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
SecurityGETPOSTTest.php Adapt phpunit to the new sanitization of restricthtml 2026-07-29 01:14:59 +02:00
SecurityLoginTest.php Code comment 2025-12-18 15:07:54 +01:00
SecurityTest.php Complete #39546 and #39547 2026-08-15 16:53:30 +02:00
SocieteTest.php FIX #37826 country_code must be an ISO code, not a label (#39191) 2026-07-16 13:56:33 +02:00
StripeTest.php Fix round in stripe amount 2026-01-21 21:00:37 +01:00
SupplierProposalTest.php phpunit more complete 2025-10-17 19:39:45 +02:00
TargetTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
test.php fix CI v22 (#34902) 2025-08-09 14:55:11 +02:00
testemailing.txt Clean files 2026-01-07 19:01:54 +01:00
testvirus.txt
textiso.txt Clean files 2026-01-07 19:01:54 +01:00
textutf8.txt Clean files 2026-01-07 19:01:54 +01:00
TicketTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
TtcRoundingTest.php FIX #37658 - Add unit tests for TTC unit price rounding and add fixes for others objects (proposals, orders, invoices and contracts) (#39055) 2026-08-11 19:48:40 +02:00
UserGroupTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
UserTest.php fetch greatest tms for user and fix user creation and modification (#35145) 2025-09-01 19:21:54 +02:00
UtilsTest.php Test 2026-06-27 14:30:17 +02:00
WebservicesInvoicesTest.php Better error message 2026-06-21 13:10:56 +02:00
WebservicesOrdersTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
WebservicesOtherTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
WebservicesProductsTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
WebservicesThirdpartyTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
WebservicesUserTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00
WebsiteTest.php CI 2026-06-09 18:22:31 +02:00
WorkstationTest.php NEW: Add phpunit test for Workstation class (#39518) 2026-08-14 15:56:13 +02:00
XCalLibTest.php replace deprecated (#31803) 2024-11-14 00:16:43 +01:00