Commit Graph

1892 Commits

Author SHA1 Message Date
Laurent Destailleur
c15627016a Fix bad test for disabling TCPDI. Add more phpunit 2024-01-10 21:51:32 +01:00
MDW
c41029d2d4 Fix: Invalid package.json (#27391)
# Fix: extra comma in package.json making it invalid

Remove the comma to make the file valid.
2024-01-10 16:25:48 +01:00
Laurent Destailleur
41516716d5 Fix duplicate example 2024-01-10 15:23:45 +01:00
MDW
96c469a45d spelling/dolibarr 2024-01-10 12:59:49 +01:00
Alexandre Janniaux
a0a3339eb9 DiscountTest: fix create when no societe exists
Fix the following error when running without the dataset.

    ✘ Discount create
    ┐
    ├ ERROR:  23503: insert or update on table "llx_societe_remise_except" violates foreign key constraint "fk_soc_remise_fk_soc"                                                                                                                                                                                                                                                                                                                                      
    ├ DETAIL:  Key (fk_soc)=(1) is not present in table "llx_societe".                                                                                                                                                                                                                                                                                                                                                                                                 
    ├ SCHEMA NAME:  public                                                                                                                                                                                                                                                                                                                                                                                                                                             
    ├ TABLE NAME:  llx_societe_remise_except                                                                                                                                                                                                                                                                                                                                                                                                                           
    ├ CONSTRAINT NAME:  fk_soc_remise_fk_soc                                                                                                                                                                                                                                                                                                                                                                                                                           
    ├ LOCATION:  ri_ReportViolation, ri_triggers.c:2596 - sql=INSERT INTO llx_societe_remise_except (entity, datec, fk_soc, discount_type, fk_user, description, amount_ht, amount_tva, amount_ttc, tva_tx, vat_src_code, multicurrency_amount_ht, multicurrency_amount_tva, multicurrency_amount_ttc, fk_facture_source, fk_invoice_supplier_source) VALUES (1, '2024-01-05 14:05:20', 1, 0, 1, 'Specimen discount', 10, 1.96, 11.96, 19.6, '', 0, 0, 0,  null, null),
    ├ Failed asserting that 0 is less than -1.                                                                                                                                                                                                                                                                                                                                                                                                                         
    │
    │ dolibarr/test/phpunit/DiscountTest.php:147
    ┴
2024-01-05 15:05:33 +01:00
Laurent Destailleur
bbf687da0c Fix warning 2024-01-05 03:08:16 +01:00
Laurent Destailleur
02183b473d Merge pull request #27294 from alexandre-janniaux/fichintertest-soc/1
FIX: FichinterTest: create Societe object in test
2024-01-05 02:05:17 +01:00
Alexandre Janniaux
0e58316050 FichinterTest: create Societe object
Fix the following error when running without the dataset.

    Fichinter
     ✘ Fichinter create
       ┐
       ├ ERROR:  23503: insert or update on table "llx_fichinter" violates foreign key constraint "fk_fichinter_fk_soc"
       ├ DETAIL:  Key (fk_soc)=(1) is not present in table "llx_societe".
       ├ SCHEMA NAME:  public
       ├ TABLE NAME:  llx_fichinter
       ├ CONSTRAINT NAME:  fk_fichinter_fk_soc
       ├ LOCATION:  ri_ReportViolation, ri_triggers.c:2596,
       ├ Failed asserting that 0 is less than -1.
       │
       │ dolibarr/test/phpunit/FichinterTest.php:147
       ┴
2024-01-04 17:04:45 +01:00
Alexandre Janniaux
a07ad0fe73 FichinterTest: add errorsToString()
Adding $localobject->errorsToString() as third argument to the assert
will allow to forward internal errors towards the tests and display them
accordingly.
2024-01-04 17:02:12 +01:00
Laurent Destailleur
482adfd7a0 Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into develop 2023-12-30 13:11:15 +01:00
Laurent Destailleur
a04b714d28 Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into 18.0 2023-12-30 13:10:42 +01:00
Laurent Destailleur
14cc6c0332 Fix phpunit 2023-12-30 13:09:41 +01:00
Laurent Destailleur
ef312e960c Merge branch '18.0' of git@github.com:Dolibarr/dolibarr.git into develop 2023-12-29 16:53:09 +01:00
Laurent Destailleur
d2b3920684 Merge 2023-12-29 16:51:05 +01:00
MDW
b5b8a2a874 Fix utf8_encoding/decoding (PHP8.2 deprecation)
Fix files that were missed in #27018
2023-12-27 19:45:37 +01:00
Laurent Destailleur
61c5c6f88d Fix regression 2023-12-27 13:09:25 +01:00
Laurent Destailleur
6386b02963 Fix phpunit for postgresql 2023-12-19 15:10:59 +01:00
Laurent Destailleur
97ae114265 FIX Universal search syntax accept string with ' in the IN 2023-12-19 15:01:21 +01:00
Laurent Destailleur
d423665551 Fix regression 2023-12-19 14:12:13 +01:00
Laurent Destailleur
e7c405425c Debug v19 2023-12-19 14:03:17 +01:00
Laurent Destailleur
b3762798a7 Merge pull request #27149 from alexandre-janniaux/commande-test-create-soc/1
FIX: CommandeTest: fix create when no company exists
2023-12-17 20:54:23 +01:00
Laurent Destailleur
a9bdab922b Merge pull request #27150 from alexandre-janniaux/companybankaccounttest-societe/1
FIX: CompanyBankAccountTest: fix create when no societe exists
2023-12-17 20:54:07 +01:00
Alexandre Janniaux
f728bda625 ContratTest: add more error context 2023-12-17 16:06:06 +01:00
Alexandre Janniaux
c2c99ab2b8 FIX: ContratTest: fix create when no societe exists
The testContratCreate() is using the default value for Contrat::socid,
which is defined by Contrat::initAsSpecimen to `0`. But if no companies
have been created, the test will fail with the following error:

    Failed asserting that 0 is less than -1.

Or with the additional logging:

    UnknownError: ERROR:  23503: insert or update on table "llx_contrat" violates foreign key constraint "fk_contrat_fk_soc"
    DETAIL:  Key (fk_soc)=(1) is not present in table "llx_societe".                                                        
    SCHEMA NAME:  public                                                                                                    
    TABLE NAME:  llx_contrat                                                                                                
    CONSTRAINT NAME:  fk_contrat_fk_soc                                                                                     
    LOCATION:  ri_ReportViolation, ri_triggers.c:2596 -,                                                                    
    Failed asserting that 0 is less than -1.

The test doesn't really depends on specific test data so we can create
the company directly instead.
2023-12-17 16:06:05 +01:00
Alexandre Janniaux
da3b4d10df FIX: CompanyBankAccountTest: fix create when no societe exists
The testCompanyBankAccountCreate() is using the default value for
CompanyBankAccount::socid, which is defined by
CompanyBankAccount::initAsSpecimen to `0`. But if no companies have been
created, the test will fail with the following error:

    Failed asserting that 0 is less than -1.

Or with the additional logging:

    ERROR:  23503: insert or update on table "llx_societe_rib" violates foreign key constraint "llx_societe_rib_fk_societe"                                                   
    DETAIL:  Key (fk_soc)=(1) is not present in table "llx_societe".                                                                                                          
    SCHEMA NAME:  public                                                                                                                                                      
    TABLE NAME:  llx_societe_rib                                                                                                                                              
    CONSTRAINT NAME:  llx_societe_rib_fk_societe                                                                                                                              
    LOCATION:  ri_ReportViolation, ri_triggers.c:2596, ERROR:  23503: insert or update on table "llx_societe_rib" violates foreign key constraint "llx_societe_rib_fk_societe"
    DETAIL:  Key (fk_soc)=(1) is not present in table "llx_societe".                                                                                                          
    SCHEMA NAME:  public                                                                                                                                                      
    TABLE NAME:  llx_societe_rib                                                                                                                                              
    CONSTRAINT NAME:  llx_societe_rib_fk_societe                                                                                                                              
    LOCATION:  ri_ReportViolation, ri_triggers.c:2596                                                                                                                         
    Failed asserting that 0 is less than -1.

The test doesn't really depends on specific test data so we can create
the company directly instead.
2023-12-17 15:55:26 +01:00
Alexandre Janniaux
0cc1cfc1ee FIX: CommandeTest: fix create when no company exists
The testCommandeCreate() is using the default value for Commande::socid,
which is defined by Command::initAsSpecimen to `0`. But if no companies
have been created, the test will fail with the following error:

    Failed asserting that 0 is less than -1.

Or with the additional logging:

    ERROR:  23503: insert or update on table "llx_commande" violates foreign key constraint "fk_commande_fk_soc"
    DETAIL:  Key (fk_soc)=(1) is not present in table "llx_societe".                                            
    SCHEMA NAME:  public                                                                                        
    TABLE NAME:  llx_commande                                                                                   
    CONSTRAINT NAME:  fk_commande_fk_soc                                                                        
    LOCATION:  ri_ReportViolation, ri_triggers.c:2596,                                                          
    Failed asserting that 0 is less than -1.

The test doesn't really depends on specific test data so we can create
the company directly instead.
2023-12-17 15:45:25 +01:00
Florian HENRY
8be0970a0c review test 2023-12-13 11:47:25 +01:00
Florian HENRY
82c49e62d1 add unit test for image in email with src=../media/ or src=base64 2023-12-13 11:31:42 +01:00
Laurent Destailleur
29dc12dd58 Option MAIN_DISALLOW_URL_INTO_DESCRIPTIONS accept 1 or 2 value.
Value 1 should be ready to be on by default in a next version.
Fix #yogosha18900
2023-12-10 16:19:05 +01:00
Laurent Destailleur
729451faa2 FIX To support domain names with TLD on 2 levels. 2023-12-06 00:46:00 +01:00
Laurent Destailleur
c9fc494796 FIX To support domain names with TLD on 2 levels. 2023-12-06 00:27:52 +01:00
Laurent Destailleur
de7d3c2bf8 Fix with php-cs-fixer 2023-12-04 11:22:28 +01:00
Laurent Destailleur
0d1983766e Fix order of param 2023-12-01 19:48:26 +01:00
Laurent Destailleur
da244466b7 Add phpunit on utf8_check and utf8_valid 2023-11-30 21:22:20 +01:00
Laurent Destailleur
c417949a7e Fix phpunit 2023-11-30 00:06:05 +01:00
Laurent Destailleur
3e1d5b1748 Fix for MAIN_RESTRICTHTML_ONLY_VALID_HTML 2023-11-29 23:17:22 +01:00
Laurent Destailleur
d809825c21 Fix phpunit 2023-11-29 22:02:10 +01:00
Laurent Destailleur
0d61ee74c7 Fix phpunit 2023-11-29 20:32:03 +01:00
Laurent Destailleur
43f9210ab4 SEC: Add option MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY 2023-11-29 20:19:21 +01:00
Laurent Destailleur
955ecd1c16 Fix params in phpunit 2023-11-28 15:35:31 +01:00
Laurent Destailleur
1d589fd74e Fix warnings 2023-11-27 13:26:44 +01:00
Laurent Destailleur
4ecab54c28 Fix phpunit 2023-11-14 12:02:09 +01:00
Laurent Destailleur
659cdfa975 Add a test with a german char 2023-11-06 20:35:41 +01:00
Laurent Destailleur
604b01e803 Show error message 2023-11-06 00:56:44 +01:00
Alexandre Janniaux
c3b3840f08 QUAL Refactor merging companies and fix #26272 with Reception objects (#26320)
* societe: add missing model_pdf field

The field is used by the class but wasn't declared.

* societe: expose Societe::mergeCompany

The code is directly copied from societe/card.php with as less changes
as possible.

The original code came from deb91ad7c1.

* societe: remove fields from property copy

$phone_pro and $fk_project are not existing for societe. This was added
from deb91ad7c1.

* SocieteTest: test the merge functionality

This test is a simple smoke test to check that the mergeCompany() will
work correctly on simple case and actually merge the details of the
company.

More complex deduplication pattern with objects referencing the deleted
Societe object, will be written for each of the different object class
in their respective test file.

* societe: card: use the new mergeCompany function

Since the code is almost the same, there should be no differences in
behaviour right now.

* societe: api_thirdparties: use Societe::mergeCompany()

* societe: fix issue when merging companies

When a Societe object is merged against another, its related objects are
supposed to reference the new Societe object so that the databse doesn't
raise foreign key errors.

The list references the objects that need to be transformed, and
Reception objects weren't part of this list.

Fix #26272

* ReceptionTest: check company merge hook

Before a Societe object is destroyed from the database, every object
referencing the FK should be destroyed or should reference another
object.

In the case of two companies being merged, the case arises and Reception
objects need to be moved to the new company. This commit brings a
non-regression test for this case.

Refs #26272

* Update societe.class.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2023-10-26 16:30:38 +02:00
Laurent Destailleur
96a90cf552 Add test file 2023-10-24 03:25:50 +02:00
Alexandre Janniaux
9fe9eee18a FIX|Fix some minor issues on Reception and add a new test for it (#26310)
* reception: reOpen: mirror $this->statut in $this->status

$this->statut is the deprecated variable, $this->status should also get
the correct value.

* reception: setDraft: mirror $this->statut in $this->status

$this->statut is the deprecated variable, $this->status should also get
the correct value.

* reception: add missing $weight field

Fix warning:

    Undefined property: Reception::$weight

* societe: add country_id field

* reception: use getDolGlobalInt when suitable

Using empty() implies that the value actually exists on the stdClass at
$conf->global, but it's not always the case. getDolGlobalInt will handle
this smoothly by checking first, which solves warnings like those:

    Undefined property: stdClass::$STOCK_CALCULATE_ON_RECEPTION

* ReceptionTest: add new test

The test checks the usual workflow of the Reception class, with, on the
one hand, the common CRUD operations:
 - create
 - fetch
 - update
 - delete

And on the other hand, the status handling for Reception:
 - valid: STATUS_DRAFT -> STATUS_VALID
 - setClosed: STATUS_VALID -> STATUS_CLOSED
 - reOpen: STATUS_CLOSED -> STATUS_VALID
 - setDraft: STATUS_VALID -> STATUS_DRAFT

The stocks lines are not tested yet, and the error cases, like any other
transition not described above, are not tested either. The permissions
for some of the operations are hardcoded for the test and there is no
failure check when the permission is not set yet.
2023-10-21 16:28:30 +02:00
Laurent Destailleur
7a694d3485 Fix phpunit 2023-10-20 03:59:02 +02:00
Laurent Destailleur
9a8db612b3 Fix phpunit error 2023-10-17 15:48:38 +02:00
Laurent Destailleur
c1b74f9338 Fix phpunit regression 2023-09-29 17:04:11 +02:00