Skip to content

Commit 03e088f

Browse files
authored
Test Suite Updates, Use GitHub Actions (#360)
* rm scrutinizer * update license * add GitHub test workflows * rm travis * rm nitpick * upgrade php-cs-fixer Fix styling * rm badges from readme * update phpunit config * namespace * update actions * update directory references in service provider Fix styling * simplify test setup try setting test user model instead Fix styling db config wip * dbal updates * cleanup fix php version adjust mysql remove dup setup * refactor users * alter database name for migrations wip wip wip users table switch env method default migrations try not setting user ids clean up Fix styling * move user model out of test * attempt retrying model creation * increase retry * try recreating users table * ignore laravel migrations * fix id * add back conditional * try removing retry * Fix styling * not random * users migration file * remove unused user * add back ids * rm docblocks * faker * rm ids again * rename user factory * seed only when needed * rm faktory, update factory methods * types, cleanup Co-authored-by: cmgmyr <[email protected]>
1 parent 9d6b544 commit 03e088f

25 files changed

+654
-501
lines changed

.github/workflows/php-cs-fixer.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Check & fix styling
2+
3+
on: [push]
4+
5+
jobs:
6+
php-cs-fixer:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v2
12+
with:
13+
ref: ${{ github.head_ref }}
14+
15+
- name: Run PHP CS Fixer
16+
uses: docker://oskarstark/php-cs-fixer-ga
17+
with:
18+
args: --config=.php-cs-fixer.php --allow-risky=yes
19+
20+
- name: Commit changes
21+
uses: stefanzweifel/git-auto-commit-action@v4
22+
with:
23+
commit_message: Fix styling

.github/workflows/run-tests-mysql.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Laravel Messenger - MySQL Tests
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- develop
7+
- feature/**
8+
pull_request:
9+
branches:
10+
- master
11+
- develop
12+
13+
jobs:
14+
laravel-tests:
15+
runs-on: ubuntu-latest
16+
# Service container Mysql mysql
17+
services:
18+
# Label used to access the service container
19+
mysql:
20+
# Docker Hub image (also with version)
21+
image: mysql:8.0
22+
env:
23+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
24+
MYSQL_DATABASE: db_test_laravel
25+
## map the "external" 33306 port with the "internal" 3306
26+
ports:
27+
- 33306:3306
28+
# Set health checks to wait until mysql database has started (it takes some seconds to start)
29+
options: >-
30+
--health-cmd="mysqladmin ping"
31+
--health-interval=10s
32+
--health-timeout=5s
33+
--health-retries=3
34+
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
operating-system: [ubuntu-latest]
39+
php-versions: [ '8.0' ]
40+
dependency-stability: [ prefer-stable ]
41+
42+
laravel: [ '8.*' ]
43+
include:
44+
- laravel: 8.*
45+
testbench: 6.*
46+
47+
name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
48+
49+
steps:
50+
- uses: actions/checkout@v2
51+
- name: Install PHP versions
52+
uses: shivammathur/setup-php@v2
53+
with:
54+
php-version: ${{ matrix.php-versions }}
55+
- name: Get Composer Cache Directory 2
56+
id: composer-cache
57+
run: |
58+
echo "::set-output name=dir::$(composer config cache-files-dir)"
59+
- uses: actions/cache@v2
60+
id: actions-cache
61+
with:
62+
path: ${{ steps.composer-cache.outputs.dir }}
63+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
64+
restore-keys: |
65+
${{ runner.os }}-composer-
66+
- name: Install Laravel Dependencies
67+
run: |
68+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
69+
composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction --no-suggest
70+
71+
# Code quality
72+
- name: Execute tests (Unit and Feature tests) via PHPUnit
73+
# Set environment
74+
env:
75+
DB_CONNECTION: mysql
76+
DB_DATABASE: db_test_laravel
77+
DB_PORT: 33306
78+
DB_USERNAME: root
79+
80+
run: vendor/bin/phpunit --testdox
+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Laravel Messenger - PostgreSQL Tests
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- develop
7+
- feature/**
8+
pull_request:
9+
branches:
10+
- master
11+
- develop
12+
13+
jobs:
14+
laravel-tests:
15+
runs-on: ubuntu-latest
16+
# Service container Postgresql postgresql
17+
services:
18+
# Label used to access the service container
19+
postgres:
20+
# Docker Hub image (also with version)
21+
image: postgres:latest
22+
env:
23+
POSTGRES_USER: postgres
24+
POSTGRES_PASSWORD: postgres
25+
POSTGRES_DB: db_test_laravel
26+
## map the "external" 55432 port with the "internal" 5432
27+
ports:
28+
- 55432:5432
29+
# Set health checks to wait until postgresql database has started (it takes some seconds to start)
30+
options: >-
31+
--health-cmd pg_isready
32+
--health-interval 10s
33+
--health-timeout 5s
34+
--health-retries 5
35+
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
operating-system: [ubuntu-latest]
40+
php-versions: [ '8.0' ]
41+
dependency-stability: [ prefer-stable ]
42+
43+
laravel: [ '8.*' ]
44+
include:
45+
- laravel: 8.*
46+
testbench: 6.*
47+
48+
name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
49+
50+
steps:
51+
- uses: actions/checkout@v2
52+
- name: Install PHP versions
53+
uses: shivammathur/setup-php@v2
54+
with:
55+
php-version: ${{ matrix.php-versions }}
56+
- name: Get Composer Cache Directory 2
57+
id: composer-cache
58+
run: |
59+
echo "::set-output name=dir::$(composer config cache-files-dir)"
60+
- uses: actions/cache@v2
61+
id: actions-cache
62+
with:
63+
path: ${{ steps.composer-cache.outputs.dir }}
64+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
65+
restore-keys: |
66+
${{ runner.os }}-composer-
67+
- name: Cache PHP dependencies
68+
uses: actions/cache@v2
69+
id: vendor-cache
70+
with:
71+
path: vendor
72+
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
73+
- name: Install Laravel Dependencies
74+
run: |
75+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
76+
composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction --no-suggest
77+
78+
79+
- name: Show dir
80+
run: pwd
81+
- name: PHP Version
82+
run: php --version
83+
84+
# Code quality
85+
- name: Execute tests (Unit and Feature tests) via PHPUnit
86+
# Set environment
87+
env:
88+
DB_CONNECTION: pgsql
89+
DB_DATABASE: db_test_laravel
90+
DB_PORT: 55432
91+
DB_USERNAME: postgres
92+
DB_PASSWORD: postgres
93+
94+
run: vendor/bin/phpunit --testdox

.github/workflows/run-tests.yml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Laravel Messenger - Tests
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- develop
7+
- feature/**
8+
pull_request:
9+
branches:
10+
- master
11+
- develop
12+
13+
jobs:
14+
laravel-tests:
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
operating-system: [ubuntu-latest]
21+
php-versions: [ '8.0','7.4','7.3','7.2' ]
22+
dependency-stability: [ prefer-stable ]
23+
laravel: [ '8.*','7.*','6.*' ]
24+
25+
include:
26+
- laravel: 8.*
27+
testbench: 6.*
28+
dbal: ^3.1.2|^2.13.3
29+
- laravel: 7.*
30+
testbench: 5.*
31+
dbal: ^2.6
32+
- laravel: 6.*
33+
testbench: 4.*
34+
dbal: ^2.6
35+
exclude:
36+
- laravel: 8.*
37+
php-versions: 7.3
38+
- laravel: 8.*
39+
php-versions: 7.2
40+
- laravel: 7.*
41+
php-versions: 8.0
42+
- laravel: 6.*
43+
php-versions: 8.0
44+
45+
name: P${{ matrix.php-versions }} - L${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
46+
47+
steps:
48+
- uses: actions/checkout@v2
49+
- name: Install PHP versions
50+
uses: shivammathur/setup-php@v2
51+
with:
52+
php-version: ${{ matrix.php-versions }}
53+
- name: Get Composer Cache Directory 2
54+
id: composer-cache
55+
run: |
56+
echo "::set-output name=dir::$(composer config cache-files-dir)"
57+
- uses: actions/cache@v2
58+
id: actions-cache
59+
with:
60+
path: ${{ steps.composer-cache.outputs.dir }}
61+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
62+
restore-keys: |
63+
${{ runner.os }}-composer-
64+
- name: Install Laravel Dependencies
65+
run: |
66+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "doctrine/dbal:${{ matrix.dbal }}" --no-interaction --no-update
67+
composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction --no-suggest
68+
69+
# Code quality
70+
- name: Execute tests (Unit and Feature tests) via PHPUnit
71+
# Set environment
72+
env:
73+
DB_CONNECTION: sqlite
74+
DB_DATABASE: ":memory:"
75+
76+
run: vendor/bin/phpunit --testdox

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.php_cs.cache
2+
.php-cs-fixer.cache
23
.phpunit.result.cache
34
build
45
composer.lock

.php_cs .php-cs-fixer.php

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
<?php
22

3-
return PhpCsFixer\Config::create()
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude('files')
5+
->exclude('vendor')
6+
->in(__DIR__)
7+
->name('*.php')
8+
->ignoreDotFiles(true)
9+
->ignoreVCS(true);
10+
11+
return (new PhpCsFixer\Config)
412
->setRiskyAllowed(true)
513
->setRules([
14+
'@PSR1' => false,
615
'@PSR2' => true,
716

817
/**
@@ -13,7 +22,7 @@
1322
// Remove duplicated semicolons.
1423
'no_empty_statement' => true,
1524
// PHP multi-line arrays should have a trailing comma.
16-
'trailing_comma_in_multiline_array' => true,
25+
'trailing_comma_in_multiline' => true,
1726
// There should be no empty lines after class opening brace.
1827
'no_blank_lines_after_class_opening' => true,
1928
// There should not be blank lines between docblock and the documented element.
@@ -23,19 +32,19 @@
2332
// Phpdocs should start and end with content, excluding the very first and last line of the docblocks.
2433
'phpdoc_trim' => true,
2534
// Removes line breaks between use statements.
26-
'no_extra_consecutive_blank_lines' => ['use'],
35+
'no_extra_blank_lines' => ['tokens' => ['use']],
2736
// An empty line feed should precede a return statement.
28-
'blank_line_before_return' => true,
37+
'blank_line_before_statement' => true,
2938
// There should be exactly one blank line before a namespace declaration.
3039
'single_blank_line_before_namespace' => true,
3140
// Convert double quotes to single quotes for simple strings.
3241
'single_quote' => true,
3342
// Unused use statements must be removed.
3443
'no_unused_imports' => true,
3544
// Methods must be separated with one blank line.
36-
'method_separation' => true,
45+
'class_attributes_separation' => true,
3746
// Binary operators should be surrounded by at least one space.
38-
'binary_operator_spaces' => ['align_double_arrow' => false],
47+
'binary_operator_spaces' => ['operators' => ['=>' => 'single_space']],
3948
// A single space should be between cast and variable.
4049
'cast_spaces' => true,
4150

@@ -49,13 +58,5 @@
4958
// PHP arrays should be declared using the configured syntax.
5059
'array_syntax' => ['syntax' => 'short']
5160
])
52-
->setFinder(
53-
PhpCsFixer\Finder::create()
54-
->exclude('files')
55-
->exclude('vendor')
56-
->in(__DIR__)
57-
->name('*.php')
58-
->ignoreDotFiles(true)
59-
->ignoreVCS(true)
60-
)
61+
->setFinder($finder)
6162
->setUsingCache(true);

.scrutinizer.yml

-34
This file was deleted.

0 commit comments

Comments
 (0)