Skip to content

Commit

Permalink
Feature 1683 pipeline unittests (#114)
Browse files Browse the repository at this point in the history
* Fixed some tests

* implemented module tests

* module tests fix

* Combine actions workflow

* Combine actions workflow

* Combine actions workflow

* Set fail fast false for tests

* try zmsapi tests

* try zmsapi tests

* try zmsapi tests

* try zmsapi tests

* try zmsapi tests

* try zmsapi tests

* try zmsapi tests

* try zmsapi tests

* try zmsapi tests

* Add env var MYSQL_HOST to config

* Add env var MYSQL_HOST to config

* Add env var MYSQL_HOST to config

* REVERT Add env var MYSQL_HOST to config

* Change variables

* Add mysql alias

* Change mariadb alias

* some cleean up

* Fix sql syntax

* Fix sql syntax

* Add zmsdb

* Add zmsdb

* CI/CD Unit Tests

* CI/CD Unit Tests

* CI/CD Unit Tests

* CI/CD Unit Tests

* CI/CD Unit Tests

* CI/CD Unit Tests

* CI/CD Unit Tests

* Fixed two tests in zmsadmin

* resolve conflicts

* Fixed some calldisplay tests

* Add missing displayName to schema

* Add missing displayName to schema

* Revert "Add missing displayName to schema"

This reverts commit fcae1d9.

* Revert "Add missing displayName to schema"

This reverts commit f680fb1.

* Add display name to fixture

* Add display name to test

* Add display name to test

* revert to resolveReferences=1, make extra API call for provider

* Add display name to test

* Revert "Fixed some tests"

This reverts commit dc09a0f.

* fix zmsstatistic tests

* Fix some zmsentities tests

* Fix zmsentities tests

* Fix more calldisplay tests

* Set this getEntity to false and test works

* add first service to process

* add first service to process

* add first service process

* add first service process

* add first service process

* add first service process

* add first service process

* add first service process

* add requests to process

* add requests to process

* add requests to process

* add requests to process

* add requests to process

* add requests to process

* add requests to process

* update sql import test data

* update sql import test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* test data

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* fix zmsapi test

* Revert "fix zmsapi test"

This reverts commit 935563b.

* Revert "fix zmsapi test"

This reverts commit d2fe97c.

* fix zmsapi test

* fix zmsapi test

* comment out tests

* comment out tests

* comment out tests

* comment out tests

* comment out tests

* comment out tests

* comment out tests

* comment out tests

* comment out tests

* comment out tests

* comment out tests

* comment out tests

* Add zmsclient tests

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* Add zmsclient tests docker service

* zmsclient

* zmsclient

* zmsapi uncomment

* Fix zmsadmin unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* Add logging zmsapi unit tests

* zmsapi comment

* zmsapi uncomment

* zmsapi uncomment

* zmsapi uncomment

* zmsapi uncomment

* zmsapi uncomment

* zmsapi uncomment

* zmsapi uncomment

* zmsapi fix mail survey test

* zmsapi fix mail delete test

* uncomment tests

* uncomment tests

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* update test data

* error log

* error log

* error log

* error log

* error log

* error log

* error log

* error log

* Update combined-workflow.yaml

* Delete zmsdb/tests/Zmsdb/fixtures/mysql_mandantory_unittests_data.sql.gz:Zone.Identifier

* Delete zmsdb/tests/Zmsdb/fixtures/mysql_mandantory_unittests_data_2.sql.gz:Zone.Identifier

* Delete zmsdb/tests/Zmsdb/fixtures/mysql_mandantory_unittests_data_3.sql.gz:Zone.Identifier

* Delete zmsdb/tests/Zmsdb/fixtures/mysql_mandantory_unittests_data_4.sql.gz:Zone.Identifier

* Delete zmsdb/tests/Zmsdb/fixtures/mysql_mandantory_unittests_data_5.sql.gz:Zone.Identifier

* Delete zmsdb/tests/Zmsdb/fixtures/mysql_mandantory_unittests_data_6.sql.gz:Zone.Identifier

* Delete zmsdb/tests/Zmsdb/fixtures/mysql_zmsbo_2 (1).sql.gz:Zone.Identifier

* Delete zmsdb/tests/Zmsdb/fixtures/mysql_zmsbo_3.sql.gz:Zone.Identifier

---------

Co-authored-by: Tobias Gassmann <[email protected]>
Co-authored-by: Tobias Holler <[email protected]>
Co-authored-by: Igor Manjencic <[email protected]>
  • Loading branch information
4 people authored Jan 29, 2024
1 parent 1e5b025 commit 767eda9
Show file tree
Hide file tree
Showing 110 changed files with 27,047 additions and 18,493 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/build-images.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: build images

on:
push:
tags:
- '**'
branches:
- '**'
workflow_call:

jobs:
build:
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/combined-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Combined Workflow

on: [push]

jobs:
call-unit-tests:
uses: ./.github/workflows/unit-tests.yaml

call-build-images:
needs: call-unit-tests
uses: ./.github/workflows/build-images.yaml
168 changes: 168 additions & 0 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
name: unit tests

on:
workflow_call:

jobs:
module-test:
runs-on: ubuntu-latest
container:
image: "registry.gitlab.com/eappointment/php-base:${{ matrix.php_version }}-dev"
steps:
- name: Checkout GitHub Action
uses: actions/checkout@main
- name: Install Composer Dependencies
run: |
cd "${{ matrix.module }}"
composer install --no-progress --prefer-dist --optimize-autoloader
- name: Run Unit Tests
run: |
cd "${{ matrix.module }}"
./vendor/bin/phpunit
strategy:
fail-fast: false
matrix:
include:
- module: zmsadmin
php_version: "8.0"
- module: zmscalldisplay
php_version: "8.0"
- module: zmsdldb
php_version: "8.0"
- module: zmsentities
php_version: "8.0"
- module: zmsmessaging
php_version: "8.0"
- module: zmsslim
php_version: "8.0"
- module: zmsstatistic
php_version: "8.0"


zmsapi-test:
runs-on: ubuntu-latest
container:
image: "registry.gitlab.com/eappointment/php-base:8.0-dev"
services:
mariadb:
image: mariadb:10.6
env:
MYSQL_ROOT_PASSWORD: zmsapi
MYSQL_DATABASE: zmsbo
MYSQL_CHARACTER_SET: utf8mb4
MYSQL_COLLATION: utf8mb4_unicode_ci
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 10s
--health-retries 5
steps:
- name: Checkout GitHub Action
uses: actions/checkout@main
- name: Install python3
run: |
apt update
apt install -y python3 python3-click python3-git
- name: Referencing local Modules and Libraries
run: python3 ./cli modules reference-libraries --no-symlink
- name: Install Composer Dependencies
run: |
modules=('zmsapi' 'zmsdb')
for module in "${modules[@]}"; do
echo "Installing Composer dependencies for $module"
(cd "$module" && composer install --no-progress --prefer-dist --optimize-autoloader)
done
shell: bash
- name: Import Test Data and Run Unit Tests
env:
MYSQL_PORT: "tcp://mariadb:3306"
MYSQL_DATABASE: zmsbo
MYSQL_ROOT_PASSWORD: zmsapi
run: |
cd zmsapi
echo "Setup fixtures..."
rm -rf data
ln -s vendor/eappointment/zmsdb/tests/Zmsdb/fixtures data
echo "Importing test data..."
vendor/bin/importTestData --commit
php -dzend_extension=xdebug.so -dmemory_limit=-1 vendor/bin/phpunit \
-v --colors=never --coverage-text --coverage-html public/_tests/coverage/ --log-junit \
public/_tests/junit.xml
zmsdb-test:
runs-on: ubuntu-latest
container:
image: "registry.gitlab.com/eappointment/php-base:8.0-dev"
services:
mariadb:
image: mariadb:10.6
env:
MYSQL_ROOT_PASSWORD: zmsdb
MYSQL_DATABASE: zmsbo
MYSQL_CHARACTER_SET: utf8mb4
MYSQL_COLLATION: utf8mb4_unicode_ci
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 10s
--health-retries 5
steps:
- name: Checkout GitHub Action
uses: actions/checkout@main
- name: Install python3
run: |
apt update
apt install -y python3 python3-click python3-git
- name: Referencing local Modules and Libraries
run: python3 ./cli modules reference-libraries --no-symlink
- name: Install Composer Dependencies
run: |
modules=('zmsdb')
for module in "${modules[@]}"; do
echo "Installing Composer dependencies for $module"
(cd "$module" && composer install --no-progress --prefer-dist --optimize-autoloader)
done
shell: bash
- name: Import Test Data and Run Unit Tests
env:
MYSQL_PORT: "tcp://mariadb:3306"
MYSQL_DATABASE: zmsbo
MYSQL_ROOT_PASSWORD: zmsdb
run: |
cd zmsdb
bin/importTestData --commit
php -dzend_extension=xdebug.so -dmemory_limit=-1 vendor/bin/phpunit \
-v --colors=never --coverage-text --coverage-html public/_tests/coverage/ --log-junit \
public/_tests/junit.xml
zmsclient-test:
runs-on: ubuntu-latest
steps:
- name: Checkout GitHub Action
uses: actions/checkout@main

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.0"
extensions: mbstring, xml, ctype, iconv, intl, pdo_mysql
coverage: xdebug

- name: Install Composer Dependencies
run: |
modules=('zmsclient')
for module in "${modules[@]}"; do
echo "Installing Composer dependencies for $module"
(cd "$module" && composer install --no-progress --prefer-dist --optimize-autoloader)
done
- name: Run Unit Tests
run: |
/bin/bash -c "cd ./zmsclient && docker-compose up -d && docker-compose exec -T test ./vendor/bin/phpunit"
2 changes: 1 addition & 1 deletion zmsadmin/public/_js/reactcomponents.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion zmsadmin/public/_js/reactcomponents.js.map

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions zmsadmin/src/Zmsadmin/AppointmentForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function readResponse(
$validator = $request->getAttribute('validator');
$workstation = \App::$http->readGetResult('/workstation/', [
'resolveReferences' => 2,
'gql' => Helper\GraphDefaults::getWorkstation()
'gql' => Helper\GraphDefaults::getWorkstationWithProvider(),
])->getEntity();
$selectedProcess = Helper\AppointmentFormHelper::readSelectedProcess($request);
if ($selectedProcess && ! $workstation->hasSuperUseraccount()) {
Expand All @@ -40,15 +40,23 @@ public function readResponse(
? $selectedProcess->getFirstAppointment()->getStartTime()->format('H-i')
: $validator->getParameter('selectedtime')->isString()->getValue();

$selectedScope = Helper\AppointmentFormHelper::readSelectedScope($request, $workstation, $selectedProcess);
$selectedScope = Helper\AppointmentFormHelper::readSelectedScope($request, $workstation, $selectedProcess, 2);

$requestList = ($selectedScope && $selectedScope->hasId())
? Helper\AppointmentFormHelper::readRequestList($request, $workstation, $selectedScope)
: null;

$freeProcessList = ($selectedScope)
? Helper\AppointmentFormHelper::readFreeProcessList($request, $workstation)
? Helper\AppointmentFormHelper::readFreeProcessList($request, $workstation, 2)
: null;

$slotTimeInMinutes = null;
if ($selectedProcess && $selectedProcess->hasId()) {
$slotTimeInMinutes = $selectedProcess->getAppointments()->getFirst()->getAvailability()['slotTimeInMinutes'];
} else if ($selectedScope) {
$provider = $selectedScope->getProvider();
$slotTimeInMinutes = $provider->getSlotTimeInMinutes();
}

return \BO\Slim\Render::withHtml(
$response,
Expand All @@ -65,7 +73,8 @@ public function readResponse(
'selectedDate' => ($selectedDate) ? $selectedDate : \App::$now->format('Y-m-d'),
'selectedTime' => $selectedTime,
'freeProcessList' => $freeProcessList,
'requestList' => $requestList
'requestList' => $requestList,
'slotTimeInMinutes' => $slotTimeInMinutes,
)
);
}
Expand Down
8 changes: 4 additions & 4 deletions zmsadmin/src/Zmsadmin/Helper/AppointmentFormHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class AppointmentFormHelper
{
public static function readFreeProcessList($request, $workstation)
public static function readFreeProcessList($request, $workstation, $resolveReferences = 1)
{
$validator = $request->getAttribute('validator');
$selectedProcessId = $validator->getParameter('selectedprocess')->isNumber()->getValue();
Expand All @@ -24,7 +24,7 @@ public static function readFreeProcessList($request, $workstation)
])->getEntity()
: null;

$scope = static::readSelectedScope($request, $workstation, $selectedProcess);
$scope = static::readSelectedScope($request, $workstation, $selectedProcess, $resolveReferences);
$scopeList = ($scope) ? (new ScopeList)->addEntity($scope) : (new ClusterHelper($workstation))->getScopeList();

$slotType = static::setSlotType($validator);
Expand Down Expand Up @@ -59,7 +59,7 @@ public static function readRequestList($request, $workstation, $selectedScope =
return ($requestList) ? $requestList->sortByName() : new \BO\Zmsentities\Collection\RequestList;
}

public static function readSelectedScope($request, $workstation, $selectedProcess = null)
public static function readSelectedScope($request, $workstation, $selectedProcess = null, $resolveReferences = 1)
{
$validator = $request->getAttribute('validator');
$input = $request->getParsedBody();
Expand All @@ -76,7 +76,7 @@ public static function readSelectedScope($request, $workstation, $selectedProces
if ($selectedScopeId) {
$selectedScope = \App::$http
->readGetResult('/scope/'. $selectedScopeId .'/', [
'resolveReferences' => 1,
'resolveReferences' => $resolveReferences,
'gql' => GraphDefaults::getScope()
])
->getEntity();
Expand Down
43 changes: 43 additions & 0 deletions zmsadmin/src/Zmsadmin/Helper/GraphDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,48 @@ public static function getWorkstation()
return static::defaultFormat($default);
}

public static function getWorkstationWithProvider()
{
$default =<<< EOS
{
id,
name,
scope {
provider {
id
contact
name
data {
payment
slotTimeInMinutes
}
},
id,
shortName
source,
contact {
name
}
preferences {
appointment
client
workstation
ticketprinter
}
status
},
queue {
clusterEnabled
appointmentsOnly
}
useraccount {
rights
}
}
EOS;
return static::defaultFormat($default);
}

/**
* availability reduced response data
*/
Expand Down Expand Up @@ -127,6 +169,7 @@ public static function getScope()
name
data {
payment
slotTimeInMinutes
}
}
queue
Expand Down
2 changes: 1 addition & 1 deletion zmsadmin/src/Zmsadmin/WorkstationProcessNext.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace BO\Zmsadmin;

use \BO\Zmsentities\Collection\ProcessList;
use BO\Zmsentities\Collection\ProcessList;

class WorkstationProcessNext extends BaseController
{
Expand Down
8 changes: 5 additions & 3 deletions zmsadmin/templates/block/appointment/form.twig
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@
{% else %}
{% set selected = "" %}
{% endif %}
{% set slotCountOptions = slotCountOptions|merge([{ "value": slotCount, "name": slotCount, "selected":selected}]) %}
{% set duration = slotTimeInMinutes * slotCount %}
{% set slotCountOptions = slotCountOptions|merge([{ "value": slotCount, "name": duration, "selected":selected}]) %}
{% endfor %}
{{ formgroup(
{"label": "Slots"},
{"label": "Termindauer in Minuten"},
[{
"type":"select",
"parameter": {
Expand Down Expand Up @@ -297,8 +298,9 @@
{% endif %}

{% set requestName = request.name %}
{% set duration = slotTimeInMinutes * request.timeSlotCount %}
{% if scope.preferences.appointment.multipleSlotsEnabled or selectedProcess.scope.preferences.appointment.multipleSlotsEnabled %}
{% set requestName = request.name ~ " (" ~ request.timeSlotCount ~ ")" %}
{% set requestName = request.name ~ " (" ~ duration ~ " min)" %}
{% endif %}
{% set requestsOptions = requestsOptions|merge([{ "value": request.id, "name": requestName, "class": "service-checkbox", "data": {'slots': request.timeSlotCount}, "selected": checked }]) %}
{% endfor %}
Expand Down
4 changes: 2 additions & 2 deletions zmsadmin/tests/Zmsadmin/AppointmentFormMultipleSlotsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function testRendering()
'url' => '/workstation/',
'parameters' => [
'resolveReferences' => 2,
'gql' => \BO\Zmsadmin\Helper\GraphDefaults::getWorkstation()
'gql' => \BO\Zmsadmin\Helper\GraphDefaults::getWorkstationWithProvider()
],
'response' => $this->readFixture("GET_Workstation_scope_141_multipleSlotsEnabled.json")
],
Expand Down Expand Up @@ -57,6 +57,6 @@ public function testRendering()
]
);
$response = parent::testRendering();
$this->assertStringContainsString('Anmeldung einer Wohnung (0)', (string)$response->getBody());
$this->assertStringContainsString('Anmeldung einer Wohnung (0 min)', (string)$response->getBody());
}
}
Loading

0 comments on commit 767eda9

Please sign in to comment.