Skip to content

Commit

Permalink
Merge pull request #224 from creme332/guz
Browse files Browse the repository at this point in the history
API testing and JSON validator setup
  • Loading branch information
creme332 authored Jun 6, 2024
2 parents d859777 + bbebed9 commit bed832c
Show file tree
Hide file tree
Showing 40 changed files with 1,847 additions and 784 deletions.
24 changes: 11 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,17 @@ jobs:
mysql -u$DB_USER -p$DB_PASSWORD -hlocalhost -P3306 -Dcafe_test < "resources/database/cafe_test_data.sql"
mysql -e "USE cafe_test; SHOW TABLES;" -u$DB_USER -p$DB_PASSWORD
- name: Create .env file
- name: Create .env.testing file
env:
ENV: |
PUBLIC_ROOT="http://localhost/steamy-sips/public"
DB_HOST="localhost"
DB_USERNAME="root"
DB_PASSWORD="root"
TEST_DB_NAME="cafe_test"
BUSINESS_GMAIL=""
BUSINESS_GMAIL_PASSWORD=""
ENV: |
DB_HOST="localhost"
DB_USERNAME="root"
DB_PASSWORD="root"
DB_NAME="cafe_test"
API_BASE_URI="http://steamy.localhost/api/v1/"
run: |
echo "$ENV" > .env
cat .env
echo "$ENV" > .env.testing
cat .env.testing
- name: Validate composer.json and composer.lock
run: composer validate --strict
Expand All @@ -66,5 +64,5 @@ jobs:
- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer test
- name: Run model test suite
run: composer modeltest
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/vendor/
.vscode
.idea
.env
node_modules
.phpunit.result.cache
public/js

.env
.env.testing
16 changes: 1 addition & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,4 @@ Attribution-ShareAlike
- https://youtu.be/q0JhJBYi4sw?si=cTdEzzGijlG41ix8
- https://github.com/kevinisaac/php-mvc
4. The filesystem was inspired by https://github.com/php-pds/sklseleton
5. Additional references are included within the code itself.

# Todo

Add `X-TEST-ENV` to the header of your request and set its value to `testing` if you want to use the testing database.
This is required when running tests for API. Without this key-value pair, the production database will be used.

USE DOCKER PHP

- read guzzle documentation. read base_uri
- test database is being used
- add variable to .env

line 18 in Reviews API is redundant
use correct namespace
5. Additional references are included within the code itself.
16 changes: 11 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,28 @@
"vlucas/phpdotenv": "^5.6",
"phpmailer/phpmailer": "^6.9",
"opis/json-schema": "^2.3",
"nesbot/carbon": "^3.3",
"fakerphp/faker": "^1.23"
"nesbot/carbon": "^3.3"
},
"scripts": {
"test": "phpunit tests"
"test": "phpunit tests",
"modeltest": "phpunit --testsuite models",
"apitest": "phpunit --testsuite api"
},
"autoload": {
"psr-4": {
"Steamy\\": "src/",
"Steamy\\Core\\": "src/core/",
"Steamy\\Controller\\": "src/controllers/",
"Steamy\\Controller\\API\\": "src/controllers/api/",
"Steamy\\Model\\": "src/models/"
"Steamy\\Model\\": "src/models/",
"Steamy\\Tests\\": "tests/",
"Steamy\\Tests\\Model\\": "tests/models/",
"Steamy\\Tests\\Api\\": "tests/api/"
}
},
"require-dev": {
"phpunit/phpunit": "^10.5"
"phpunit/phpunit": "^10.5",
"guzzlehttp/guzzle": "^7.0",
"fakerphp/faker": "^1.23"
}
}
Loading

0 comments on commit bed832c

Please sign in to comment.