more tests and some fixes

This commit is contained in:
Dennis Eichhorn 2024-04-24 03:20:46 +00:00
parent a9fafe5b5e
commit 316b2b2345
12 changed files with 49 additions and 31 deletions

View File

@ -21,11 +21,3 @@
* [Application Sample]({%}?page=phpOMS/application)
* [Modules]({%}?page=application/module)
* [Packages]({%}?page=application/packages)
## phpOMS
## jsOMS
## cssOMS
## cOMS

View File

@ -20,8 +20,8 @@ Url parameters:
* `n` means that elements to the **right/below** of `id` should be shown
* `sort_by` defines the column which is used to sort the data
* `sort_order` defines what **left/above** and **right/below** mean
* `ASC` means ascending and therfore defines **left/above** as smaller elements and **right/below** as larger elements
* `DESC` means descending and therfore defines **left/above** as larger elements and **right/below** as smaller elements
* `ASC` means ascending and therefore defines **left/above** as smaller elements and **right/below** as larger elements
* `DESC` means descending and therefore defines **left/above** as larger elements and **right/below** as smaller elements
* `subid` defines the id of the `sort_by` column IFF `sort_by` is not the primary field.
> The maximum amount of elements returned depend on the defined limit.

View File

@ -51,7 +51,7 @@ All tests need to have the following docblocks:
#### Module documentation
Modules have a `Help` and a `Dev` documentation both are insifficient for most modules. Feel free to add some documentation. Consider to use images wherever helpful. Consider to add the used images to https://github.com/Karaka-Management/Build/blob/master/Js/createImages.js which will automatically create new images even if the style changes or minor layout changes are made.
Modules have a `Help` and a `Dev` documentation both are insufficient for most modules. Feel free to add some documentation. Consider to use images wherever helpful. Consider to add the used images to https://github.com/Karaka-Management/Build/blob/master/Js/createImages.js which will automatically create new images even if the style changes or minor layout changes are made.
```js
...

View File

@ -72,7 +72,7 @@ Additional tools and settings coming with the VM:
1. Download the latest trace from `http://vm_ip:82/Logs`
2. Drag and drop that downloaded `*.xt` file in the trace visualizer
5. `sitespeed.io ./Build/Helper/Scripts/sitespeedDemoUrls.txt -b chrome --outputFolder /var/www/html/sitespeed`
6. Slow sql query threashold is defined as 0.5s.
6. Slow sql query threshold is defined as 0.5s.
<p class="cT">
<img width="150px" tabindex="0" src="./Developer-Guide/general/img/webgrind.jpg"> <img width="150px" tabindex="0" src="./Developer-Guide/general/img/trace_visualizer.jpg"> <img width="150px" tabindex="0" src="./Developer-Guide/general/img/sitespeed.jpg"> <img width="150px" tabindex="0" src="./Developer-Guide/general/img/codecoverage.jpg"> <img width="150px" tabindex="0" src="./Developer-Guide/general/img/coverage_analysis.jpg"> <img width="150px" tabindex="0" src="./Developer-Guide/general/img/metrics.jpg">
@ -96,7 +96,7 @@ After the installation you'll have access to the following content:
* Application: `http://127.0.0.1`
Instead of calling `php demoSetup/setup.php` which only uses a single thread you may also run `php demoSetup/setup.php -a 0` which will execute the install script in multiple threads leading to most likely 100% CPU and storage usage but therfore significantly reduce the execution time.
Instead of calling `php demoSetup/setup.php` which only uses a single thread you may also run `php demoSetup/setup.php -a 0` which will execute the install script in multiple threads leading to most likely 100% CPU and storage usage but therefore significantly reduce the execution time.
> You may want to call the setup script as a different user to ensure the same permissions `sudo -u wwww-data php demoSetup/setup.php`
@ -138,7 +138,7 @@ This will only setup the application including some dummy data and also perform
After the installation you'll have access to the following content:
* Application: `http://127.0.0.1`
* Code Coverager: `http://127.0.0.1/tests/coverage/`
* Code Coverage: `http://127.0.0.1/tests/coverage/`
> During this process the database automatically gets dropped (if it exists) and re-created. If you don't have `xdebug` installed but `phpdbg` you can replace `php phpunit ...` with `phpdbg -qrr phpunit.phar ...` or use `pcov` for much faster code coverage generation.

View File

@ -14,7 +14,7 @@ The base view class contains the request as well as the response objects hence i
In the template you can simply use `$this->getText({TEXT_ID})` for localized text. All other localization elements can be accessed in a similar way e.g. `$this->l11n->getTemperature()`.
In html templates it's recommended to use `$this->getHtml({TEXT_ID})` as this will safely escape static/defined strings (see language files) for html output. By default the language file of the current module is used for the translation, if you would like to use a translation from another module you have to specify the module name and the template name e.g. `<?= $this->getHtml('Word', 'ModuleName', 'TemplateName'); ?>`. This only works if the specified module is available and therefore it is only recommended to use this if the current module has a dependency defined on the specified module which ensures its availability.
In html templates it's recommended to use `$this->getHtml({TEXT_ID})` as this will safely escape static/defined strings (see language files) for html output. By default the language file of the current module is used for the translation, if you would like to use a translation from another module you have to specify the module name and the template name e.g. `<?= $this->getHtml('Word', 'ModuleName', 'TemplateName'); ?>`. This only works if the specified module is available and therefore it is only recommended to use this if the current module has a dependency defined on the specified module which ensures its availability.
Furthermore there is also a global translation file for common translations, this can be accessed as follows `<?= $this->getHtml('Word', '0', '0'); ?>`. Common translations are for example `ID`, `Submit`, `Send`, `Cancel` etc.

View File

@ -1,6 +1,6 @@
# Cache
For caching the `CacheManager` provides access to the caching systems in place. Out of the box the CacheManager supports and automatically initializes either Redis or Memcached depending on the client configuration. The caching is not mandatory and therefor shouldn't be misused as in-memory database. It is not necessary to check if Redis or Memcached are available the CacheManager automatically handles the caching based on their existence.
For caching the `CacheManager` provides access to the caching systems in place. Out of the box the CacheManager supports and automatically initializes either Redis or Memcached depending on the client configuration. The caching is not mandatory and therefore shouldn't be misused as in-memory database. It is not necessary to check if Redis or Memcached are available the CacheManager automatically handles the caching based on their existence.
## HTTP Cache

View File

@ -8,4 +8,4 @@ The Http session will be saved automatically, there is no need to access the sup
## Socket & Console
The session will be stored and associated with the logged in user in memory. A disconnect or quit is considered as a logout and therefor results in the destruction of the session object of this user and will be empty for the next login.
The session will be stored and associated with the logged in user in memory. A disconnect or quit is considered as a logout and therefore results in the destruction of the session object of this user and will be empty for the next login.

View File

@ -16,7 +16,7 @@ or indirectly by calling the `getText()` in the view context.
$this->getText({TEXT})
```
The language that should be used for a response should always be depending on the requested language and therefore never be hard coded.
The language that should be used for a response should always be depending on the requested language and therefore never be hard coded.
The language code of the localization object is the 2 character ISO639 code. The corresponding enums are located in the localization directory and labeled with `ISO639`.
@ -58,7 +58,7 @@ $money->getCurrency(2, ',', '.', '$', 0);
### DateTime
The date/time is versatile and can have multiple formats. By default the localization object stores 5 different date/time formats depending on the degree of accuracy required.
The date/time is versatile and can have multiple formats. By default the localization object stores 5 different date/time formats depending on the degree of accuracy required.
* very_short
* short

View File

@ -15,7 +15,6 @@ The following automated tests must pass without errors, failures and warnings fo
* `npx eslint ./ -c Build/Config/.eslintrc.json`
* `npx jasmine-node ./`
* `./cOMS/tests/test.sh`
* see [other checks](#other-checks) below
<p class="cT">
<img width="150px" tabindex="0" src="./Developer-Guide/quality/img/webgrind.jpg"> <img width="150px" tabindex="0" src="./Developer-Guide/quality/img/trace_visualizer.jpg"> <img width="150px" tabindex="0" src="./Developer-Guide/quality/img/sitespeed.jpg"> <img width="150px" tabindex="0" src="./Developer-Guide/quality/img/sitespeed_waterfall.jpg"> <img width="150px" tabindex="0" src="./Developer-Guide/quality/img/codecoverage.jpg"> <img width="150px" tabindex="0" src="./Developer-Guide/quality/img/coverage_analysis.jpg"> <img width="150px" tabindex="0" src="./Developer-Guide/quality/img/metrics.jpg"> <img width="150px" tabindex="0" src="./Developer-Guide/quality/img/phpunit_html.jpg"> <img width="150px" tabindex="0" src="./Developer-Guide/quality/img/phpcs.jpg"> <img width="150px" tabindex="0" src="./Developer-Guide/quality/img/phpstan.jpg"> <img width="150px" tabindex="0" src="./Developer-Guide/quality/img/rector.jpg">
@ -56,7 +55,8 @@ When testing it makes sense to test for the happy path/branch of how a method sh
* C++ framework + tools: `cOMS/tests`
* Css framework: `cssOMS/tests`
* Configurations for tools: `Build/Config`
* Inspection script: `Build/php.sh` or `Builde/Helper/Scripts/inspectproject.sh`
* Inspection script: `Build/php.sh` or `Build/Helper/Scripts/inspectproject.sh`
* End-to-End: `tests/Web`
### Unit tests
@ -68,9 +68,9 @@ Integration tests are the second level or middle level of tests. These types of
For large controllers it can make sense to define a `*ControllerTest` which uses `Traits` in order to categorize different suits of tests. For example in the `Admin` ApiControllerTest we implemented different traits for group, account and module tests.
### System tests
### User/End-To-End
The system tests are the highest level of tests and test the overall functionality and if the implementation fulfills the specifications.
The User/End-To-End tests are the highest level of tests and test the overall functionality and if the implementation fulfills the specifications.
### Modules
@ -104,6 +104,14 @@ In some cases code changes may require changes to the demo setup script (e.g. ch
php demoSetup/setup.php -a 0
```
### End-To-End tests
End-To-End tests simulate the user interaction with the application in the browser. These tests can be found in `tests/Web` and can only be run on a machine with `Chrome` and a window manager installed (these tests don't run in a pure CLI environment).
```sh
node test/Web/Backend/Install.js
```
### UI tests
While UI tests can be part of unit, integration or system tests the `cssOMS` repository also includes a simple test suit at [http://127.0.0.1/cssOMS/tests/app](http://127.0.0.1/cssOMS/tests/app) which allows developers to test UI elements and check how they work.
@ -219,6 +227,8 @@ The javascript testing is done with jasmine. The javascript testing directory is
npx jasmine-node ./
```
Alternatively you can open `http://127.0.0.1/jsOMS/tests/SpecRunner.html` to run the tests in your browser.
### JS Eslint
The js code base has a defined code style standard. The easiest way to check for most rules is to run eslint.
@ -247,7 +257,7 @@ sitespeed.io ./Build/Helper/Scripts/sitespeedDemoUrls.txt -b chrome --outputFold
### SQL performance
With query profiling enabled you can inspect slow running queries that may need optimization. The threashold for slow running queries is defined at 0.5s.
With query profiling enabled you can inspect slow running queries that may need optimization. The threshold for slow running queries is defined at 0.5s.
```sh
mysqldumpslow -t 10 /var/log/mysql/mysql-slow.log
@ -304,10 +314,26 @@ The following checks should also be performed. If you use the git hooks from the
* Php files without strict_types
* Has logs
* Has whitespace at line end
##### Other manual checks
By adding the `?debug=1` query parameter to a url a css file gets loaded that can help finding missing html attributes (e.g. alt="", for="", ...) by drawing a red border around the element that possibly needs improving.
## Classification
```mermaid
quadrantChart;
x-axis Low Level --> High Level;
y-axis Low Importance --> High Importance;
PHPStan: [0.2, 0.5];
*UI tests: [0.8, 0.05];
PHPCS/CBF/Fixer/Rector/eslint: [0.1, 0.1];
PHPUnit: [0.5, 0.75];
cOMS/tests.sh: [0.2, 0.2];
Jasmine: [0.3, 0.5];
*Selenium: [0.9, 0.9];
*Sitespeed: [0.75, 0.25];
*Demo: [0.95, 0.95];
*Other: [0.3, 0.05];
```
\* Optional and/or manual
## References

View File

@ -43,7 +43,7 @@ Don't use C++ standard functions or C++ functions provided by other C++ header f
### Parameters
Generally, functions that thake pointers to non-scalar types should modify the data instead of allocating new memory **IF** reasonable. This forces programmers to consciously create copies before passing data **IF** they need the original data. To indicate that a reference/pointer is not modified by a function define them as const!
Generally, functions that take pointers to non-scalar types should modify the data instead of allocating new memory **IF** reasonable. This forces programmers to consciously create copies before passing data **IF** they need the original data. To indicate that a reference/pointer is not modified by a function define them as const!
We believe this approach provides a framework for better memory management and better performance in general.

View File

@ -32,7 +32,7 @@ Every module that has a database table must implement a UML diagram illustrating
## Php
The php documentation is based on PhpDocumentor, therefore only valid PhpDocumentor comments are valid for files, classes, functions/methods and (member) variables.
The php documentation is based on PhpDocumentor, therefore only valid PhpDocumentor comments are valid for files, classes, functions/methods and (member) variables.
### File
@ -111,7 +111,7 @@ Example:
## JavaScript
The javascript documentation is based on JsDoc, therefore only valid JsDoc comments are valid for all js files.
The javascript documentation is based on JsDoc, therefore only valid JsDoc comments are valid for all js files.
### File

View File

@ -32,7 +32,7 @@ Getters and setters for member variables should be kept at a absolute minimum an
### Why are we using public so much?
* Private/protected adds a huge amount of unneccessary typing without gaining much/anything
* Private/protected adds a huge amount of unnecessary typing without gaining much/anything
* Getters/setters may hide unsuspecting side effects
* Adding additional functionality afterwards if it becomes necessary is easy by changing the member to private and letting the static code inspection tools find the callers
* Performance overhead (function calls, data mappers)