Skip to content

Commit 9389000

Browse files
authored
More tests (#22)
1 parent 3ed58a8 commit 9389000

27 files changed

+90173
-870
lines changed

.devcontainer/devcontainer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// https://aka.ms/devcontainer.json
2+
{
3+
"name": "Existing Docker Compose (Extend)",
4+
"dockerComposeFile": [
5+
"../docker-compose.yml"
6+
],
7+
"service": "laravel.test",
8+
"workspaceFolder": "/var/www/html",
9+
"settings": {},
10+
"extensions": [
11+
"editorconfig.editorconfig",
12+
"ryannaddy.laravel-artisan",
13+
"amiralizadeh9480.laravel-extra-intellisense",
14+
"stef-k.laravel-goto-controller",
15+
"codingyu.laravel-goto-view",
16+
"mikestead.dotenv",
17+
"christian-kohler.path-intellisense",
18+
"esbenp.prettier-vscode",
19+
"CoenraadS.bracket-pair-colorizer"
20+
],
21+
"remoteUser": "sail",
22+
"postCreateCommand": "chown -R 1000:1000 /var/www/html && composer install && php artisan key:generate",
23+
"forwardPorts": [80]
24+
// "runServices": [],
25+
// "shutdownAction": "none",
26+
}

.github/workflows/php.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
services:
15+
mssql:
16+
image: mcr.microsoft.com/mssql/server:2022-latest
17+
env:
18+
ACCEPT_EULA: Y
19+
MSSQL_PID: Express
20+
MSSQL_SA_PASSWORD: P@ssword
21+
ports:
22+
- 1433:1433
23+
24+
mysql:
25+
image: mysql
26+
env:
27+
MYSQL_ROOT_PASSWORD: password
28+
MYSQL_USER: testing
29+
MYSQL_PASSWORD: password
30+
MYSQL_DATABASE: testing
31+
ports:
32+
- 3306:3306
33+
34+
postgres:
35+
image: postgres
36+
env:
37+
POSTGRES_USER: testing
38+
POSTGRES_PASSWORD: password
39+
POSTGRES_DB: testing
40+
ports:
41+
- 5432:5432
42+
43+
redis:
44+
image: redis
45+
ports:
46+
- 6379:6379
47+
48+
steps:
49+
- uses: actions/checkout@v2
50+
with:
51+
fetch-depth: 10
52+
53+
- name: Validate composer.json and composer.lock
54+
run: composer validate --strict
55+
56+
- name: Cache Composer packages
57+
id: composer-cache
58+
uses: actions/cache@v2
59+
with:
60+
path: vendor
61+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
62+
restore-keys: |
63+
${{ runner.os }}-php-
64+
65+
- name: Install dependencies
66+
run: composer install --prefer-dist --no-progress
67+
68+
- name: Create databases
69+
run: |
70+
/opt/mssql-tools/bin/sqlcmd -U "sa" -P "P@ssword" -Q "CREATE DATABASE testing;"
71+
72+
- name: Run test suite
73+
run: composer test
74+
env:
75+
DB_HOST: 127.0.0.1

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
/public/storage
55
/storage/*.key
66
/vendor
7-
.env
87
.env.backup
98
.env.production
109
.phpunit.result.cache

app/Http/Controllers/DashboardStatsController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public function index() {
6161
$maxDurationWorkflow->id = $maxDurationWorkflow->_id;
6262
} else {
6363
$maxDurationWorkflow = config('workflows.stored_workflow_model', StoredWorkflow::class)::select('*')
64+
->when($dbDriverName === 'sqlite', function ($q) {
65+
return $q->addSelect(DB::raw('julianday(created_at) - julianday(updated_at) as duration'));
66+
})
6467
->when($dbDriverName === 'mysql', function ($q) {
6568
return $q->addSelect(DB::raw('TIMEDIFF(created_at, updated_at) as duration'));
6669
})
@@ -93,6 +96,7 @@ public function index() {
9396
$maxExceptionsWorkflow->id = $maxExceptionsWorkflow->_id;
9497
} else {
9598
$maxExceptionsWorkflow = config('workflows.stored_workflow_model', StoredWorkflow::class)::withCount('exceptions')
99+
->has('exceptions')
96100
->orderByDesc('exceptions_count')
97101
->orderByDesc('updated_at')
98102
->first();

composer.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
],
1111
"require": {
1212
"php": "^8.0.2",
13-
"laravel-workflow/laravel-workflow": ">=0.0.19",
14-
"illuminate/support": "^9.0|^10.0"
13+
"illuminate/support": "^9.0|^10.0",
14+
"laravel-workflow/laravel-workflow": "^1.0"
1515
},
1616
"require-dev": {
1717
"fakerphp/faker": "^1.9.1",
1818
"mockery/mockery": "^1.4.4",
19+
"orchestra/testbench": "8.9.1",
1920
"phpunit/phpunit": "^9.5.10"
2021
},
2122
"autoload": {
@@ -28,6 +29,13 @@
2829
"Waterline\\Tests\\": "tests/"
2930
}
3031
},
32+
"scripts": {
33+
"test": "composer test-mssql && composer test-mysql && composer test-pgsql && composer test-sqlite",
34+
"test-mssql": "vendor/bin/phpunit --testdox --configuration=phpunit-mssql.xml",
35+
"test-mysql": "vendor/bin/phpunit --testdox --configuration=phpunit-mysql.xml",
36+
"test-pgsql": "vendor/bin/phpunit --testdox --configuration=phpunit-pgsql.xml",
37+
"test-sqlite": "vendor/bin/phpunit --testdox --configuration=phpunit-sqlite.xml"
38+
},
3139
"extra": {
3240
"laravel": {
3341
"providers": [

0 commit comments

Comments
 (0)