Skip to content

Commit 3a0919c

Browse files
authored
Merge pull request #19 from tattersoftware/strict
Strict Database
2 parents d8e51ce + bae33c2 commit 3a0919c

File tree

14 files changed

+172
-90
lines changed

14 files changed

+172
-90
lines changed

.github/workflows/analyze.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ jobs:
3939
with:
4040
php-version: ${{ matrix.php-versions }}
4141
tools: composer, pecl, phpunit
42-
extensions: intl, json, mbstring, mysqlnd, xdebug, xml, sqlite3
42+
extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3
43+
env:
44+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4345

4446
- name: Get composer cache directory
4547
id: composer-cache
@@ -65,7 +67,12 @@ jobs:
6567
key: ${{ runner.os }}-phpstan-${{ github.sha }}
6668
restore-keys: ${{ runner.os }}-phpstan-
6769

68-
- name: Install dependencies
70+
- name: Install dependencies (limited)
71+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
72+
run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
73+
74+
- name: Install dependencies (authenticated)
75+
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
6976
run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
7077
env:
7178
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}

.github/workflows/compare.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# When a PR is opened or a push is made, compare
2+
# code for backwards compatibility.
3+
name: RoaveBC
4+
5+
on:
6+
pull_request:
7+
branches:
8+
- develop
9+
paths:
10+
- 'src/**'
11+
12+
jobs:
13+
compare:
14+
name: Compare for Backwards Compatibility
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Run comparison (limited)
22+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
23+
uses: docker://nyholm/roave-bc-check-ga
24+
25+
- name: Run comparison (authenticated)
26+
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
27+
uses: docker://nyholm/roave-bc-check-ga
28+
env:
29+
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}

.github/workflows/test.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ jobs:
2929
with:
3030
php-version: ${{ matrix.php-versions }}
3131
tools: composer, pecl, phpunit
32-
extensions: intl, json, mbstring, mysqlnd, xdebug, xml, sqlite3
32+
extensions: intl, json, mbstring, gd, mysqlnd, xdebug, xml, sqlite3
3333
coverage: xdebug
34+
env:
35+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3436

3537
- name: Get composer cache directory
3638
id: composer-cache
@@ -43,11 +45,19 @@ jobs:
4345
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
4446
restore-keys: ${{ runner.os }}-composer-
4547

46-
- name: Install dependencies
48+
- name: Install dependencies (limited)
49+
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
50+
run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
51+
52+
- name: Install dependencies (authenticated)
53+
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
4754
run: composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader
4855
env:
4956
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
5057

58+
- name: Enable Tachycardia
59+
run: echo "TACHYCARDIA_MONITOR_GA=enabled" >> $GITHUB_ENV
60+
5161
- name: Test with PHPUnit
5262
run: vendor/bin/phpunit --verbose --coverage-text
5363
env:

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"require-dev": {
3131
"codeigniter4/codeigniter4": "dev-develop",
3232
"myth/auth": "dev-develop",
33-
"tatter/tools": "^1.6"
33+
"tatter/tools": "^1.8"
3434
},
3535
"autoload": {
3636
"psr-4": {
@@ -55,7 +55,7 @@
5555
"prefer-stable": true,
5656
"scripts": {
5757
"analyze": "phpstan analyze",
58-
"mutate": "infection --threads=2 --coverage=build/phpunit",
58+
"mutate": "infection --threads=2 --skip-initial-tests --coverage=build/phpunit",
5959
"style": "phpcbf --standard=./vendor/codeigniter4/codeigniter4-standard/CodeIgniter4 tests/ src/",
6060
"test": "phpunit"
6161
}

phpstan.neon.dist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ parameters:
1010
- src/Config/Routes.php
1111
- src/Views/*
1212
ignoreErrors:
13-
- '#Unsafe usage of new static\(\)#'
13+
- '#Call to an undefined method CodeIgniter\\Database\\BaseBuilder::first\(\)#'
14+
- '#Unsafe usage of new static\(\)*#'
1415
universalObjectCratesClasses:
1516
- CodeIgniter\Entity
17+
- CodeIgniter\Entity\Entity
1618
- Faker\Generator
1719
scanDirectories:
1820
- vendor/codeigniter4/codeigniter4/system/Helpers

phpunit.xml.dist

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
34
bootstrap="vendor/codeigniter4/codeigniter4/system/Test/bootstrap.php"
45
backupGlobals="false"
6+
beStrictAboutCoversAnnotation="true"
7+
beStrictAboutOutputDuringTests="true"
8+
beStrictAboutTodoAnnotatedTests="true"
59
colors="true"
610
convertErrorsToExceptions="true"
711
convertNoticesToExceptions="true"
812
convertWarningsToExceptions="true"
913
executionOrder="random"
10-
stopOnError="false"
14+
failOnRisky="true"
15+
failOnWarning="true"
16+
stopOnError="true"
1117
stopOnFailure="false"
1218
stopOnIncomplete="false"
1319
stopOnSkipped="false"
14-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
20+
verbose="true">
1521

1622
<coverage includeUncoveredFiles="true" processUncoveredFiles="true">
1723
<include>
@@ -36,6 +42,30 @@
3642
</testsuite>
3743
</testsuites>
3844

45+
<extensions>
46+
<extension class="Nexus\PHPUnit\Extension\Tachycardia">
47+
<arguments>
48+
<array>
49+
<element key="timeLimit">
50+
<double>0.50</double>
51+
</element>
52+
<element key="reportable">
53+
<integer>30</integer>
54+
</element>
55+
<element key="precision">
56+
<integer>2</integer>
57+
</element>
58+
<element key="collectBare">
59+
<boolean>true</boolean>
60+
</element>
61+
<element key="tabulate">
62+
<boolean>true</boolean>
63+
</element>
64+
</array>
65+
</arguments>
66+
</extension>
67+
</extensions>
68+
3969
<logging>
4070
<testdoxHtml outputFile="build/phpunit/testdox.html"/>
4171
<testdoxText outputFile="build/phpunit/testdox.txt"/>
@@ -59,6 +89,7 @@
5989
<env name="COMPOSER_DISABLE_XDEBUG_WARN" value="1"/>
6090

6191
<!-- Database configuration -->
92+
<env name="database.tests.strictOn" value="true"/>
6293
<!-- Uncomment to use alternate testing database configuration
6394
<env name="database.tests.hostname" value="localhost"/>
6495
<env name="database.tests.database" value="tests"/>

roave-bc-check.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
parameters:
2+
ignoreErrors:
3+
- '#\[BC\] SKIPPED: .+ could not be found in the located source#'

src/Config/Events.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515

1616
// Create the email record
17-
if ($id = model(EmailModel::class)->insert($params))
17+
if ($id = model(EmailModel::class)->ignore()->insert($params))
1818
{
1919
// Add each recipient
2020
foreach ($params['recipients'] as $email)

tests/_support/DatabaseTestCase.php

Lines changed: 0 additions & 67 deletions
This file was deleted.

tests/_support/OutboxTestCase.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php namespace Tests\Support;
2+
3+
use CodeIgniter\Test\CIUnitTestCase;
4+
use CodeIgniter\Test\Mock\MockEmail;
5+
6+
class OutboxTestCase extends CIUnitTestCase
7+
{
8+
/**
9+
* @var boolean
10+
*/
11+
protected $refresh = true;
12+
13+
/**
14+
* @var string|array|null
15+
*/
16+
protected $namespace = 'Tatter\Outbox';
17+
18+
/**
19+
* Path to a file for attachments.
20+
*
21+
* @var string
22+
*/
23+
protected $file = SUPPORTPATH . 'cat.jpg';
24+
25+
/**
26+
* Email handler
27+
*
28+
* @var MockEmail
29+
*/
30+
protected $email;
31+
32+
public function setUp(): void
33+
{
34+
parent::setUp();
35+
36+
$this->email = service('email');
37+
}
38+
}

0 commit comments

Comments
 (0)