Skip to content

Commit 2aafdc8

Browse files
committed
Merge branch 'release/1.3.0'
2 parents 73523d1 + 5f6ee07 commit 2aafdc8

File tree

17 files changed

+133
-118
lines changed

17 files changed

+133
-118
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,8 @@ on:
1616

1717
jobs:
1818

19-
test:
20-
21-
strategy:
22-
fail-fast: false
23-
matrix:
24-
include:
25-
- operating-system: 'ubuntu-latest'
26-
silverstripe-version: '5.0'
27-
php-version: '8.1'
28-
- operating-system: 'ubuntu-latest'
29-
silverstripe-version: '4.0'
30-
php-version: '8.0'
31-
- operating-system: 'ubuntu-latest'
32-
silverstripe-version: '4.0'
33-
php-version: '7.4'
34-
35-
name: SS ${{ matrix.silverstripe-version }}, PHP ${{ matrix.php-version }}
36-
runs-on: ${{ matrix.operating-system }}
37-
steps:
38-
- uses: actions/checkout@v3
39-
- uses: php-actions/composer@v6
40-
with:
41-
command: update
42-
--with silverstripe/framework:^${{ matrix.silverstripe-version }}
43-
php_version: ${{ matrix.php-version }}
44-
php_extensions: intl
45-
- run: |
46-
./vendor/bin/phpunit -c phpunit.xml.dist
47-
48-
tidy:
49-
50-
name: "Annotate & Tidy"
51-
needs: [test]
19+
latest:
20+
name: "Build & Verify"
5221
runs-on: 'ubuntu-latest'
5322
steps:
5423
- uses: actions/checkout@v3
@@ -65,30 +34,56 @@ jobs:
6534
--coverage-clover ./coverage.xml
6635
- name: Annotate with Metrics
6736
run: |
68-
find src -name "*.php" | xargs ./vendor/bin/metrics annotate ./coverage.xml
37+
find src -name "*.php" | xargs -n 1 ./vendor/bin/metrics annotate ./coverage.xml
6938
- name: Refactor with Rector
7039
run: |
7140
./vendor/bin/rector process src
7241
- name: Tidy Source Code
7342
run: |
74-
find tests -name "*.php" | xargs ./vendor/bin/phptidy.php replace
75-
find src -name "*.php" | xargs ./vendor/bin/phptidy.php replace
43+
find tests -name "*.php" | xargs -n 1 ./vendor/bin/phptidy.php replace
44+
find src -name "*.php" | xargs -n 1 ./vendor/bin/phptidy.php replace
7645
- name: Push Back Changes
7746
run: |
7847
git diff --exit-code src || ( \
7948
git config user.name github-actions && \
8049
git config user.email github-actions@github.com && \
81-
git add src && \
50+
git add . && \
8251
git commit -m "tidy" && \
8352
git fetch --unshallow origin ${{ github.head_ref || github.ref_name }} && \
8453
git push origin HEAD:${{ github.head_ref || github.ref_name }} \
8554
)
8655
87-
merge:
56+
matrix:
57+
strategy:
58+
fail-fast: false
59+
matrix:
60+
include:
61+
- operating-system: 'ubuntu-latest'
62+
silverstripe-version: '5.0'
63+
php-version: '8.1'
64+
- operating-system: 'ubuntu-latest'
65+
silverstripe-version: '4.0'
66+
php-version: '8.0'
67+
- operating-system: 'ubuntu-latest'
68+
silverstripe-version: '4.0'
69+
php-version: '7.4'
70+
name: "Matrix: SS ${{ matrix.silverstripe-version }}, PHP ${{ matrix.php-version }}"
71+
runs-on: ${{ matrix.operating-system }}
72+
steps:
73+
- uses: actions/checkout@v3
74+
- uses: php-actions/composer@v6
75+
with:
76+
command: update
77+
--with silverstripe/framework:^${{ matrix.silverstripe-version }}
78+
php_version: ${{ matrix.php-version }}
79+
php_extensions: intl
80+
- run: |
81+
./vendor/bin/phpunit -c phpunit.xml.dist
8882
83+
merge:
8984
name: "Merge Changes"
9085
if: github.event_name == 'push'
91-
needs: [test]
86+
needs: [latest,matrix]
9287
runs-on: 'ubuntu-latest'
9388
steps:
9489
- uses: actions/checkout@v3

.gitignore

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
resources
1+
.phptidy-cache
2+
.phpunit.result.cache
3+
*.log
4+
*~
5+
app
26
composer.lock
7+
coverage.xml
8+
DOCKER_ENV
9+
docker_tag
10+
resources
311
vendor
4-
*~

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ These include:
88
- a *shortcode* with which to insert a user form into any content area;
99
- a *form widget* that presents a user form (requires
1010
[silverstripe/widgets](https://github.com/silverstripe/silverstripe-widgets));
11-
- various new *form fields*.
11+
- various *additional validations* for existing form fields;
12+
- various *new form fields*.
1213

1314
## Installation
1415

@@ -43,7 +44,14 @@ You have the ability to customize display with the following options:
4344
- **Show form content?** - Chose whether to display the content of the form
4445
page.
4546
46-
## Form Fields
47+
## Additional Field Validations
48+
49+
### Maximum File Size
50+
51+
The maximum file size for a form fields will now be checked prior to submission.
52+
This is much more responsive for the user.
53+
54+
## New Form Fields
4755
4856
This module provides a selection of new field types to use with your user forms.
4957

_config/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
---
22
Name: userforms-utils
3-
---
3+
After: 'userforms/*'
4+
---

phpunit.xml.dist

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
1-
<?xml version="1.0"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/silverstripe/cms/tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<coverage includeUncoveredFiles="true">
4-
<include>
5-
<directory suffix=".php">src/</directory>
6-
</include>
7-
<exclude>
8-
<directory suffix=".php">tests/</directory>
9-
</exclude>
10-
<report>
11-
<clover outputFile="clover.xml"/>
12-
</report>
13-
</coverage>
14-
<testsuite name="Default">
15-
<directory>tests/</directory>
16-
</testsuite>
17-
<logging/>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
4+
bootstrap="vendor/silverstripe/cms/tests/bootstrap.php"
5+
executionOrder="depends,defects"
6+
forceCoversAnnotation="false"
7+
beStrictAboutCoversAnnotation="true"
8+
beStrictAboutOutputDuringTests="true"
9+
beStrictAboutTodoAnnotatedTests="true"
10+
failOnRisky="true"
11+
failOnWarning="true"
12+
verbose="true">
13+
<testsuites>
14+
<testsuite name="default">
15+
<directory>tests</directory>
16+
</testsuite>
17+
</testsuites>
18+
19+
<coverage processUncoveredFiles="true">
20+
<include>
21+
<directory suffix=".php">src</directory>
22+
</include>
23+
<exclude>
24+
<file>src/bootstrap.php</file>
25+
</exclude>
26+
</coverage>
1827
<php>
1928
<includePath>app/code</includePath>
2029
<env name="SS_DATABASE_CLASS" value="SQLite3Database"/>

rector.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
<?php
2-
/**
3-
*
4-
* @package default
5-
*/
62

73

84
declare( strict_types = 1 );
95

6+
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
107
use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
118
use Rector\Config\RectorConfig;
129
use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector;
10+
use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector;
1311
use Rector\Set\ValueObject\LevelSetList;
1412
use Rector\Set\ValueObject\SetList;
1513

@@ -22,8 +20,10 @@
2220
] );
2321

2422
$rectorConfig->skip( [
25-
RemoveUnusedPrivatePropertyRector::class,
23+
CompleteDynamicPropertiesRector::class,
2624
ExplicitBoolCompareRector::class,
25+
RemoveParentCallWithoutParentRector::class,
26+
RemoveUnusedPrivatePropertyRector::class,
2727
] );
2828

2929
$rectorConfig->importShortClasses();

src/FormFields/EditableHTML5DateField.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
<?php
2-
/**
3-
* src/FormFields/EditableHTML5DateField.php
4-
*
5-
* @package default
6-
*/
72

83

94
namespace Logicbrush\UserFormsUtils\FormFields;
@@ -15,8 +10,9 @@
1510
/**
1611
* An HTML5 date field.
1712
*
18-
* @package userform-utils
1913
*/
14+
15+
2016
class EditableHTML5DateField extends EditableFormField {
2117

2218
private static $singular_name = 'HTML5 Date Field';
@@ -25,6 +21,7 @@ class EditableHTML5DateField extends EditableFormField {
2521

2622
/**
2723
*
24+
* @Metrics( crap = 6, uncovered = true )
2825
* @return unknown
2926
*/
3027
public function getFormField() {

src/FormFields/EditableSignatureField.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
<?php
2-
/**
3-
* src/FormFields/EditableSignatureField.php
4-
*
5-
* @package default
6-
*/
72

83

94
namespace Logicbrush\UserFormsUtils\FormFields;
@@ -22,8 +17,11 @@ class EditableSignatureField extends EditableFormField {
2217

2318
/**
2419
*
20+
* @Metrics( crap = 6, uncovered = true )
2521
* @return unknown
2622
*/
23+
24+
2725
public function getFormField() {
2826
$field = TextField::create( $this->Name, $this->Title ?: false )
2927
->setFieldHolderTemplate( EditableFormField::class . '_holder' )
@@ -38,6 +36,8 @@ public function getFormField() {
3836
* Returns an image field, so the signature can be viewed in the CMS and in
3937
* reports.
4038
*
39+
*
40+
* @Metrics( crap = 2, uncovered = true )
4141
* @return unknown
4242
*/
4343
public function getSubmittedFormField() : SubmittedFormField

src/FormFields/EditableUSStateDropdownField.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
<?php
2-
/**
3-
* src/FormFields/EditableUSStateDropdownField.php
4-
*
5-
* @package default
6-
*/
72

83

94
namespace Logicbrush\UserFormsUtils\FormFields;
@@ -23,8 +18,9 @@
2318
*
2419
* @property bool $UseEmptyString
2520
* @property string $EmptyString
26-
* @package userform-utils
2721
*/
22+
23+
2824
class EditableUSStateDropdownField extends EditableFormField {
2925

3026
private static $singular_name = 'US State Dropdown';
@@ -90,6 +86,7 @@ class EditableUSStateDropdownField extends EditableFormField {
9086

9187
/**
9288
*
89+
* @Metrics( crap = 2, uncovered = true )
9390
* @return FieldList
9491
*/
9592
public function getCMSFields() {
@@ -120,6 +117,7 @@ public function getCMSFields() {
120117

121118
/**
122119
*
120+
* @Metrics( crap = 30, uncovered = true )
123121
* @return unknown
124122
*/
125123
public function getFormField() {
@@ -147,6 +145,7 @@ public function getFormField() {
147145

148146
/**
149147
*
148+
* @Metrics( crap = 6, uncovered = true )
150149
* @param unknown $data
151150
* @return unknown
152151
*/
@@ -161,6 +160,7 @@ public function getValueFromData( $data ) {
161160

162161
/**
163162
*
163+
* @Metrics( crap = 6, uncovered = true )
164164
* @return unknown
165165
*/
166166
public function getIcon() {
@@ -176,6 +176,7 @@ public function getIcon() {
176176

177177
/**
178178
*
179+
* @Metrics( crap = 2, uncovered = true )
179180
* @param unknown $forOnLoad (optional)
180181
* @return unknown
181182
*/

src/FormFields/Impl/HTML5DateField.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
<?php
2-
/**
3-
* src/FormFields/Impl/HTML5DateField.php
4-
*
5-
* @package default
6-
*/
72

83

94
namespace Logicbrush\UserFormsUtils\FormFields\Impl;
@@ -14,10 +9,13 @@ class HTML5DateField extends DateField {
149

1510
/**
1611
*
12+
* @Metrics( crap = 2, uncovered = true )
1713
* @param unknown $name
1814
* @param unknown $title (optional)
1915
* @param unknown $value (optional)
2016
*/
17+
18+
2119
public function __construct( $name, $title = null, $value = "" ) {
2220
parent::__construct( $name, $title, $value );
2321
$this->setHTML5( true );
@@ -26,6 +24,7 @@ public function __construct( $name, $title = null, $value = "" ) {
2624

2725
/**
2826
*
27+
* @Metrics( crap = 2, uncovered = true )
2928
* @return unknown
3029
*/
3130
public function getAttributes() {

0 commit comments

Comments
 (0)