From 383a4aed65544b773f4c078e7f62ba60fe73f271 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:05:53 +0400 Subject: [PATCH 01/15] setup database before running tests --- .github/workflows/test.yml | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3a01e8e..ed9c669 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,12 +11,33 @@ permissions: jobs: build: - runs-on: ubuntu-latest - + services: + mysql: + image: mysql:8.0 + env: + # The MySQL docker container requires these environment variables to be set + # so we can create and migrate the test database. + # See: https://hub.docker.com/_/mysql + MYSQL_DATABASE: cafe_test + MYSQL_ROOT_PASSWORD: password + ports: + # Opens port 3306 on service container and host + # https://docs.github.com/en/actions/using-containerized-services/about-service-containers + - 3306:3306 + # Before continuing, verify the mysql container is reachable from the ubuntu host + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 steps: - uses: actions/checkout@v3 + # - name: Install Ubuntu dependencies + # run: | + # sudo apt-get update + # sudo apt-get install libcurl4-openssl-dev libmysqlclient-dev libgirepository1.0-dev + + - name: Import SQL dump to cafe_test database + run: mysql -Dcafe_test -uroot -ppassword -h127.0.0.1 -P33306 < "resources/database/dump/cafe.sql" + - name: Validate composer.json and composer.lock run: composer validate --strict @@ -29,8 +50,16 @@ jobs: restore-keys: | ${{ runner.os }}-php- - - name: Install dependencies + - name: Install Composer dependencies run: composer install --prefer-dist --no-progress + # - name: Start database service + # run: sudo systemctl start mysql.service + - name: Run test suite + env: + DB_HOST: 127.0.0.1 + DB_USERNAME: root + DB_PASSWORD: password + TEST_DB_NAME: cafe_test run: composer test From 3ff1b726c6bf0b47bec176f54bf2987433c41fdd Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:10:14 +0400 Subject: [PATCH 02/15] fix mysql port number --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ed9c669..5d6a09e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,7 +36,7 @@ jobs: # sudo apt-get install libcurl4-openssl-dev libmysqlclient-dev libgirepository1.0-dev - name: Import SQL dump to cafe_test database - run: mysql -Dcafe_test -uroot -ppassword -h127.0.0.1 -P33306 < "resources/database/dump/cafe.sql" + run: mysql -Dcafe_test -uroot -ppassword -h127.0.0.1 -P3306 < "resources/database/dump/cafe.sql" - name: Validate composer.json and composer.lock run: composer validate --strict From 2f0f54632ecb4ddc1daca3efd4582baab5b11dcb Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:15:59 +0400 Subject: [PATCH 03/15] attempt to fix duplicate check constraint name error for city_length --- resources/database/dump/cafe.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/database/dump/cafe.sql b/resources/database/dump/cafe.sql index e445546..b44ab03 100644 --- a/resources/database/dump/cafe.sql +++ b/resources/database/dump/cafe.sql @@ -57,8 +57,8 @@ CREATE TABLE `client` ( KEY `client_district_district_id_fk` (`district_id`), CONSTRAINT `client_district_district_id_fk` FOREIGN KEY (`district_id`) REFERENCES `district` (`district_id`) ON UPDATE CASCADE, CONSTRAINT `client_fk` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `city_length` CHECK (char_length(`city`) > 2), - CONSTRAINT `street_length` CHECK (char_length(`street`) > 3) + CONSTRAINT `street_length` CHECK (char_length(`street`) > 3), + CONSTRAINT `client_city_length` CHECK (char_length(`city`) > 2) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -330,4 +330,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-04-09 11:14:04 +-- Dump completed on 2024-04-18 13:13:42 From 04fd34fafc10ced33840ccfa72cdbd1d7078e1f7 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:19:51 +0400 Subject: [PATCH 04/15] fix: Duplicate check constraint name 'street_length'. --- resources/database/dump/cafe.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/database/dump/cafe.sql b/resources/database/dump/cafe.sql index b44ab03..a4e1ae7 100644 --- a/resources/database/dump/cafe.sql +++ b/resources/database/dump/cafe.sql @@ -57,8 +57,8 @@ CREATE TABLE `client` ( KEY `client_district_district_id_fk` (`district_id`), CONSTRAINT `client_district_district_id_fk` FOREIGN KEY (`district_id`) REFERENCES `district` (`district_id`) ON UPDATE CASCADE, CONSTRAINT `client_fk` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `street_length` CHECK (char_length(`street`) > 3), - CONSTRAINT `client_city_length` CHECK (char_length(`city`) > 2) + CONSTRAINT `client_city_length` CHECK (char_length(`city`) > 2), + CONSTRAINT `client_street_length` CHECK (char_length(`street`) > 3) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -330,4 +330,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-04-18 13:13:42 +-- Dump completed on 2024-04-18 13:18:52 From 08515ab3f0e64dea8d051f754bee86c6c0e761d6 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:20:38 +0400 Subject: [PATCH 05/15] create `.env` file before running tests --- .github/workflows/test.yml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5d6a09e..867e29a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,14 +30,18 @@ jobs: steps: - uses: actions/checkout@v3 - # - name: Install Ubuntu dependencies - # run: | - # sudo apt-get update - # sudo apt-get install libcurl4-openssl-dev libmysqlclient-dev libgirepository1.0-dev - - name: Import SQL dump to cafe_test database run: mysql -Dcafe_test -uroot -ppassword -h127.0.0.1 -P3306 < "resources/database/dump/cafe.sql" + - name: Create environment file + env: + ENV: | + DB_HOST="127.0.0.1" + DB_USERNAME="root" + DB_PASSWORD="password" + TEST_DB_NAME="cafe_test" + run: echo "$ENV" > src/core/.env + - name: Validate composer.json and composer.lock run: composer validate --strict @@ -53,13 +57,5 @@ jobs: - name: Install Composer dependencies run: composer install --prefer-dist --no-progress - # - name: Start database service - # run: sudo systemctl start mysql.service - - name: Run test suite - env: - DB_HOST: 127.0.0.1 - DB_USERNAME: root - DB_PASSWORD: password - TEST_DB_NAME: cafe_test run: composer test From 50efeb88ac4c5568cda915f8800cef59f8455d98 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:23:55 +0400 Subject: [PATCH 06/15] add 3 more variables to env file --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 867e29a..9a47cd3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,10 +36,13 @@ jobs: - name: Create environment file env: ENV: | + PUBLIC_ROOT="http://localhost/steamy-sips/public" DB_HOST="127.0.0.1" DB_USERNAME="root" DB_PASSWORD="password" TEST_DB_NAME="cafe_test" + BUSINESS_GMAIL="" + BUSINESS_GMAIL_PASSWORD="" run: echo "$ENV" > src/core/.env - name: Validate composer.json and composer.lock From 41aade8dcafdc8372493cbfc0a96a47873f0710c Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:28:56 +0400 Subject: [PATCH 07/15] update the following actions to use Node.js 20: actions/checkout@v3, actions/cache@v3. --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9a47cd3..e7d53dd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: # Before continuing, verify the mysql container is reachable from the ubuntu host options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Import SQL dump to cafe_test database run: mysql -Dcafe_test -uroot -ppassword -h127.0.0.1 -P3306 < "resources/database/dump/cafe.sql" @@ -50,7 +50,7 @@ jobs: - name: Cache Composer packages id: composer-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: vendor key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} From 8e7845a4e4fe104908dd451c5f7ff2d177920fbf Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:39:22 +0400 Subject: [PATCH 08/15] for debugging, print pdo error --- src/core/Database.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/Database.php b/src/core/Database.php index 2b42963..b741b05 100644 --- a/src/core/Database.php +++ b/src/core/Database.php @@ -18,12 +18,13 @@ trait Database private static function connect(): PDO { $string = "mysql:hostname=" . DB_HOST . ";dbname=" . DB_NAME; + $pdo_object = new PDO($string, DB_USERNAME, DB_PASSWORD); + try { - $pdo_object = new PDO($string, DB_USERNAME, DB_PASSWORD); } catch (PDOException $e) { // TODO: Create a page to display the error Utility::show( - "Error establishing a connection to the database." + $e ); die(); } From ca45677bac9a4890071c6292f789fb85e2bc4b6a Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:39:38 +0400 Subject: [PATCH 09/15] output contents of .env for debugging --- .github/workflows/test.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e7d53dd..2e0ee7f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: mysql: image: mysql:8.0 env: - # The MySQL docker container requires these environment variables to be set + # The MySQL docker container requires these environment variables to be set, # so we can create and migrate the test database. # See: https://hub.docker.com/_/mysql MYSQL_DATABASE: cafe_test @@ -33,7 +33,7 @@ jobs: - name: Import SQL dump to cafe_test database run: mysql -Dcafe_test -uroot -ppassword -h127.0.0.1 -P3306 < "resources/database/dump/cafe.sql" - - name: Create environment file + - name: Create .env file env: ENV: | PUBLIC_ROOT="http://localhost/steamy-sips/public" @@ -45,6 +45,9 @@ jobs: BUSINESS_GMAIL_PASSWORD="" run: echo "$ENV" > src/core/.env + - name: Output contents of .env + run: cat src/core/.env + - name: Validate composer.json and composer.lock run: composer validate --strict From b6a8ab92a5b3b7fc090dcdf1780b2c8af902ccf2 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Apr 2024 15:28:37 +0400 Subject: [PATCH 10/15] try using pre-installed mysql instead of docker image --- .github/workflows/test.yml | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2e0ee7f..8e1dec1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,26 +12,20 @@ permissions: jobs: build: runs-on: ubuntu-latest - services: - mysql: - image: mysql:8.0 - env: - # The MySQL docker container requires these environment variables to be set, - # so we can create and migrate the test database. - # See: https://hub.docker.com/_/mysql - MYSQL_DATABASE: cafe_test - MYSQL_ROOT_PASSWORD: password - ports: - # Opens port 3306 on service container and host - # https://docs.github.com/en/actions/using-containerized-services/about-service-containers - - 3306:3306 - # Before continuing, verify the mysql container is reachable from the ubuntu host - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + env: + TEST_DB_NAME: cafe_test + DB_USER: root # do not change + DB_PASSWORD: root # do not change + steps: - uses: actions/checkout@v4 - - name: Import SQL dump to cafe_test database - run: mysql -Dcafe_test -uroot -ppassword -h127.0.0.1 -P3306 < "resources/database/dump/cafe.sql" + - name: Setup database + run: | + sudo /etc/init.d/mysql start + mysql -e "CREATE DATABASE IF NOT EXISTS $TEST_DB_NAME;" -u$DB_USER -p$DB_PASSWORD + mysql -D$TEST_DB_NAME -u$DB_USER -p$DB_PASSWORD -h127.0.0.1 -P3306 < "resources/database/dump/cafe.sql" - name: Create .env file env: @@ -39,15 +33,12 @@ jobs: PUBLIC_ROOT="http://localhost/steamy-sips/public" DB_HOST="127.0.0.1" DB_USERNAME="root" - DB_PASSWORD="password" + DB_PASSWORD="root" TEST_DB_NAME="cafe_test" BUSINESS_GMAIL="" BUSINESS_GMAIL_PASSWORD="" run: echo "$ENV" > src/core/.env - - name: Output contents of .env - run: cat src/core/.env - - name: Validate composer.json and composer.lock run: composer validate --strict From 4321df025d47141ea6a794437256a537ca77dd54 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Apr 2024 15:33:03 +0400 Subject: [PATCH 11/15] use localhost instead of 127.0.0.1 --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8e1dec1..b4ecf2d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,13 +25,13 @@ jobs: run: | sudo /etc/init.d/mysql start mysql -e "CREATE DATABASE IF NOT EXISTS $TEST_DB_NAME;" -u$DB_USER -p$DB_PASSWORD - mysql -D$TEST_DB_NAME -u$DB_USER -p$DB_PASSWORD -h127.0.0.1 -P3306 < "resources/database/dump/cafe.sql" + mysql -D$TEST_DB_NAME -u$DB_USER -p$DB_PASSWORD -hlocalhost -P3306 < "resources/database/dump/cafe.sql" - name: Create .env file env: ENV: | PUBLIC_ROOT="http://localhost/steamy-sips/public" - DB_HOST="127.0.0.1" + DB_HOST="localhost" DB_USERNAME="root" DB_PASSWORD="root" TEST_DB_NAME="cafe_test" From 351a23a59d12b6b9c3d152496b5ff6096e9c5a28 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Apr 2024 15:38:43 +0400 Subject: [PATCH 12/15] output database tables and .env file --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b4ecf2d..d439a56 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,6 +26,7 @@ jobs: sudo /etc/init.d/mysql start mysql -e "CREATE DATABASE IF NOT EXISTS $TEST_DB_NAME;" -u$DB_USER -p$DB_PASSWORD mysql -D$TEST_DB_NAME -u$DB_USER -p$DB_PASSWORD -hlocalhost -P3306 < "resources/database/dump/cafe.sql" + mysql -e "USE cafe_test; SHOW TABLES;" -u$DB_USER -p$DB_PASSWORD - name: Create .env file env: @@ -37,7 +38,9 @@ jobs: TEST_DB_NAME="cafe_test" BUSINESS_GMAIL="" BUSINESS_GMAIL_PASSWORD="" - run: echo "$ENV" > src/core/.env + run: | + echo "$ENV" > src/core/.env + cat src/core/.env - name: Validate composer.json and composer.lock run: composer validate --strict From fc20dd2f8ec15a1f67e29a7053950ddb4083645a Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Apr 2024 16:33:26 +0400 Subject: [PATCH 13/15] setup php with variables_order="EGPCS" --- .github/workflows/test.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d439a56..f40a28e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,15 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + extensions: mbstring, intl + ini-values: post_max_size=256M, max_execution_time=180, variables_order="EGPCS" + coverage: xdebug + tools: php-cs-fixer, phpunit + - name: Setup database run: | sudo /etc/init.d/mysql start From f778b45f50d1bf1b071623d22ced7a63d1176b41 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:02:47 +0400 Subject: [PATCH 14/15] add a note on PHP setup, merge instructions for test db and production db --- docs/INSTALLATION_GUIDE.md | 44 ++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/docs/INSTALLATION_GUIDE.md b/docs/INSTALLATION_GUIDE.md index dabc519..4631ff3 100644 --- a/docs/INSTALLATION_GUIDE.md +++ b/docs/INSTALLATION_GUIDE.md @@ -10,8 +10,9 @@ some commands may differ. Please adapt accordingly. - MySQL (v15.1 preferred) - Composer with its executable on your $PATH - Git +- NPM (optional) -## Setup project +## Project setup Navigate to the document root of your server: @@ -56,14 +57,14 @@ BUSINESS_GMAIL_PASSWORD="" Some important notes: - Update the values assigned to `DB_USERNAME` and `DB_PASSWORD` with your MySQL login details. -- If your Apache server is serving from a port other than the default one, add the new port number to `PUBLIC_ROOT` ( +- If your Apache server is serving from a port other than the default one, include the port number to `PUBLIC_ROOT` ( e.g., `http://localhost:443/steamy-sips/public`) . - `BUSINESS_GMAIL` and `BUSINESS_GMAIL_PASSWORD` are the credentials of the Gmail account from which emails will be sent whenever a client places an order. It is recommended to use a [Gmail App password](https://knowledge.workspace.google.com/kb/how-to-create-app-passwords-000009237) for `BUSINESS_GMAIL_PASSWORD` instead of your actual gmail account password. -## Setup production database +## Database setup Start your MySQL server and connect to its monitor: @@ -76,32 +77,37 @@ mysql -u -p Create a database `cafe`: -```bash +```sql create database cafe; -``` - -Select the database: - -``` use cafe; +source resources/database/dump/cafe.sql; +exit; ``` -Import data to the database from the SQL dump: +The path to the SQL dump might must be modified if you are not in the root directory of the project. -```bash -source resources/database/dump/cafe.sql -``` +If you want to run unit tests with composer, you must first set up a separate database for testing. To do so, repeat the +same +instructions as above except name the testing database `cafe_test`: -The path to the SQL dump might must be modified if you are not in the root directory of the project. +```sql +create database cafe_test; +use cafe_test; +source resources/database/dump/cafe.sql; +exit; +``` -## Setup testing database +## PHP setup -If you want to run tests for the application, you must set up a database for testing. To do so, repeat the same -instructions as the setup for the production database except name the testing database `cafe_test`. +Ensure that the [`variables_order`](https://www.php.net/manual/en/ini.core.php#ini.variables-) directive in +your `php.ini` +file is set to `"EGPCS"`. Without this, the application will +not be able to load environment variables properly in `src/core/config.php` and you will get an array key error. +You can use `php --ini` to find the location of your `php.ini` file. -## Setup linting and formatting +## Linting and formatting setup -This step is optional if you do not plan on editing the JS and CSS files. Node.js is required to install the linter and +This step is optional if you do not plan on editing the JS and CSS files. NPM is required to install the linter and formatter for JS and CSS files. For more details on the linters and formatters used, see our [coding standards](CODING_STANDARDS.md). From 94e10f849292c55b67f1022e734128f063485290 Mon Sep 17 00:00:00 2001 From: creme332 <65414576+creme332@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:19:38 +0400 Subject: [PATCH 15/15] do not catch PDOException when phpunit is running --- src/core/Database.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/core/Database.php b/src/core/Database.php index b741b05..410fe56 100644 --- a/src/core/Database.php +++ b/src/core/Database.php @@ -18,17 +18,19 @@ trait Database private static function connect(): PDO { $string = "mysql:hostname=" . DB_HOST . ";dbname=" . DB_NAME; - $pdo_object = new PDO($string, DB_USERNAME, DB_PASSWORD); - try { + return new PDO($string, DB_USERNAME, DB_PASSWORD); } catch (PDOException $e) { - // TODO: Create a page to display the error - Utility::show( - $e - ); - die(); + // if PHPUnit is not running, handle the exception + if (!defined('PHPUNIT_STEAMY_TESTSUITE')) { + // TODO: Display a user-friendly error message + Utility::show("Sorry, we're unable to process your request at the moment. Please try again later."); + die(); + } else { + // if PHPUnit is running, re-throw the exception to allow it to propagate + throw $e; + } } - return $pdo_object; } /**