Skip to content

Commit

Permalink
Merge pull request #3 from softonic/Allow-null-parameter-values-in-En…
Browse files Browse the repository at this point in the history
…sureModelExists

Allow null parameter values in EnsureModelExists
  • Loading branch information
xaviapa authored Feb 21, 2025
2 parents 15b7912 + 9f55790 commit 93038fb
Show file tree
Hide file tree
Showing 18 changed files with 282 additions and 255 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/build.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/workflows/init.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-php-

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'

- name: Install dependencies
run: composer install --prefer-dist --no-progress
env:
COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}

- name: Run test suite
run: composer run-script tests
59 changes: 30 additions & 29 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests');
->in(__DIR__.'/src')
->in(__DIR__.'/tests');

return (new PhpCsFixer\Config())
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'new_with_braces' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'no_empty_comment' => true,
'no_leading_import_slash' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_unused_imports' => true,
'ordered_imports' => ['imports_order' => null, 'sort_algorithm' => 'alpha'],
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
'phpdoc_align' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_order' => true,
'phpdoc_scalar' => true,
'phpdoc_to_comment' => true,
'psr_autoloading' => true,
'return_type_declaration' => ['space_before' => 'none'],
'single_blank_line_before_namespace' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
'whitespace_after_comma_in_array' => true,
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'new_with_parentheses' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'no_empty_comment' => true,
'no_leading_import_slash' => true,
'no_trailing_comma_in_singleline' => true,
'no_unused_imports' => true,
'ordered_imports' => ['imports_order' => null, 'sort_algorithm' => 'alpha'],
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
'phpdoc_align' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_order' => true,
'phpdoc_scalar' => true,
'phpdoc_to_comment' => true,
'psr_autoloading' => true,
'return_type_declaration' => ['space_before' => 'none'],
'blank_lines_before_namespace' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
'whitespace_after_comma_in_array' => true,
])
->setFinder($finder);
->setFinder($finder);
30 changes: 30 additions & 0 deletions .travis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
language: php

sudo: false

matrix:
include:
- php: 8.3
env: COLLECT_COVERAGE=true VALIDATE_CODING_STYLE=true
- php: master
env: COLLECT_COVERAGE=true VALIDATE_CODING_STYLE=false
allow_failures:
- php: master
fast_finish: true

cache:
directories:
- $HOME/.composer/cache

before_install:
- travis_retry composer self-update

install:
- travis_retry composer update --no-interaction --prefer-source

script:
- composer phpunit

after_script:
- if [ "$COLLECT_COVERAGE" == "true" ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover build/clover.xml; fi
- if [ "$VALIDATE_CODING_STYLE" == "true" ]; then composer phpcs; fi
19 changes: 0 additions & 19 deletions Makefile

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ Testing

To run the tests, run the following command from the project folder.
``` bash
$ make tests
$ docker compose run test
```

To open a terminal in the dev environment:
``` bash
$ make debug
$ docker compose run --entrypoint=bash php
```

License
Expand Down
24 changes: 12 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"issues": "https://github.com/softonic/rest-api-nested-resources/issues"
},
"require": {
"php": ">=8.0"
"php": ">=8.3"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"friendsofphp/php-cs-fixer": "^3.0",
"laravel/framework": "^11.0",
"mockery/mockery": "^1.0",
"friendsofphp/php-cs-fixer": "^3.6",
"laravel/framework": "^8.0",
"squizlabs/php_codesniffer": "^3",
"rector/rector": "^0.11.20"
"phpunit/phpunit": "^11.0",
"rector/rector": "^1.0",
"squizlabs/php_codesniffer": "^3"
},
"autoload": {
"psr-4": {
Expand All @@ -30,20 +30,20 @@
}
},
"scripts": {
"test": [
"tests": [
"@checkstyle",
"@phpunit"
],
"phpunit": "phpunit --coverage-text",
"phpunit": "phpunit",
"checkstyle": [
"php-cs-fixer fix -v --diff --dry-run --allow-risky=yes",
"rector --dry-run"
"PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix -v --diff --allow-risky=yes",
"rector process"
],
"fix-checkstyle": [
"@php-cs-fixer",
"@rector"
],
"php-cs-fixer": "php-cs-fixer fix -v --diff --allow-risky=yes",
"rector": "rector"
"php-cs-fixer": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix -v --diff --allow-risky=yes",
"rector": "rector process"
}
}
38 changes: 33 additions & 5 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
version: '3.8'

services:
composer:
php:
volumes:
- ./:/app
image: composer:2.2

install:
volumes:
- ./:/app
image: composer:2.2
command: composer install --ignore-platform-req=ext-sockets

update:
volumes:
- ./:/app
image: composer:2.2
command: composer update --ignore-platform-req=ext-sockets

phpunit:
volumes:
- ./:/app
image: composer:2.2
command: composer phpunit

test:
volumes:
- ./:/app
image: composer:2.2
command: composer run tests

fix-cs:
volumes:
- ./:/app
image: softonic/composer-rector:latest
- ./:/app
image: composer:2.2
command: composer run fix-cs
42 changes: 12 additions & 30 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true">

<testsuites>
<testsuite name="softonic/rest-api-nested-resources">
<directory>tests</directory>
<testsuite name="All">
<directory>./tests</directory>
</testsuite>
</testsuites>

<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<clover outputFile="./build/clover.xml"/>
<html outputDirectory="./build/coverage"/>
<text outputFile="./build/coverage.txt" />
</report>
</coverage>

<logging>
<junit outputFile="./build/report.junit.xml"/>
</logging>

</phpunit>
</phpunit>
Loading

0 comments on commit 93038fb

Please sign in to comment.