@@ -69,6 +69,80 @@ This is also important for the Utopia-php lead developers to be able to give tec
6969
7070You can follow our [ Adding new Database Adapter] ( docs/add-new-adapter.md ) tutorial to add new database support in this library.
7171
72+ ## Tests
73+
74+ To run tests, you first need to bring up the example Docker stack with the following command:
75+
76+ ``` bash
77+ docker compose up -d --build
78+ ```
79+
80+ To run all unit tests, use the following Docker command:
81+
82+ ``` bash
83+ docker compose exec tests vendor/bin/phpunit --configuration phpunit.xml tests
84+ ```
85+
86+ To run tests for a single file, use the following Docker command structure:
87+
88+ ``` bash
89+ docker compose exec tests vendor/bin/phpunit --configuration phpunit.xml tests/Database/[FILE_PATH]
90+ ```
91+
92+ To run static code analysis, use the following phpstan command:
93+
94+ ``` bash
95+ composer check
96+ ```
97+
98+ ### Load testing
99+
100+ Three commands have been added to ` bin/ ` to fill, index, and query the DB to test changes:
101+
102+ - ` bin/load ` invokes ` bin/tasks/load.php `
103+ - ` bin/index ` invokes ` bin/tasks/index.php `
104+ - ` bin/query ` invokes ` bin/tasks/query.php `
105+
106+ To test your DB changes under load:
107+
108+ #### Load the database
109+
110+ ``` bash
111+ docker compose exec tests bin/load --adapter=[adapter] --limit=[limit] [--name= [name]]
112+
113+ # [adapter]: either 'mongodb' or 'mariadb', no quotes
114+ # [limit]: integer of total documents to generate
115+ # [name]: (optional) name for new database
116+ ` ` `
117+
118+ # ### Create indexes
119+
120+ ` ` ` bash
121+ docker compose exec tests bin/index --adapter= [adapter] --name= [name]
122+
123+ # [adapter]: either 'mongodb' or 'mariadb', no quotes
124+ # [name]: name of filled database by bin/load
125+ ` ` `
126+
127+ # ### Run Query Suite
128+
129+ ` ` ` bash
130+ docker compose exec tests bin/query --adapter= [adapter] --limit= [limit] --name= [name]
131+
132+ # [adapter]: either 'mongodb' or 'mariadb', no quotes
133+ # [limit]: integer of query limit (default 25)
134+ # [name]: name of filled database by bin/load
135+ ` ` `
136+
137+ # ### Visualize Query Results
138+
139+ ` ` ` bash
140+ docker compose exec tests bin/compare
141+ ` ` `
142+
143+ Navigate to ` localhost:8708` to visualize query results.
144+
145+
72146# # Other Ways to Help
73147
74148Pull requests are great, but there are many other areas where you can help Utopia-php.
0 commit comments