diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..8e4dd69 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,39 @@ +name: Lint + +on: + push: + branches: ["*"] + pull_request: + branches: ["*"] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-versions: [8.0", "8.1", "8.2"] + + steps: + - uses: actions/checkout@v2 + + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + + - name: Cache Composer dependencies + uses: actions/cache@v2 + with: + path: /tmp/composer-cache + key: ${{ runner.os }}-php${{ matrix.php-versions }}-${{ hashFiles('**/composer.lock') }} + + - name: Install dependencies + uses: php-actions/composer@v5 + with: + command: install + args: --prefer-dist --no-progress --no-suggest --verbose + php_version: ${{ matrix.php-versions }} + version: 1 + + - name: Run lint + run: make lint diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..56f8ec5 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,36 @@ +name: Tests + +on: [push, pull_request] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, windows-latest] + php: [8.2, 8.1, 8.0] + stability: [prefer-lowest, prefer-stable] + + name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + coverage: none + + - name: Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + - name: Install dependencies + run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..ea44de8 --- /dev/null +++ b/.php_cs @@ -0,0 +1,13 @@ +in(__DIR__ . '/src') + ->in(__DIR__ . '/tests'); + +return PhpCsFixer\Config::create() + ->setUsingCache(false) + ->setRules([ + '@PSR2' => true, + 'array_syntax' => ['syntax' => 'short'], + ]) + ->setFinder($finder); diff --git a/.phpunit.result.cache b/.phpunit.result.cache new file mode 100644 index 0000000..a0a8c40 --- /dev/null +++ b/.phpunit.result.cache @@ -0,0 +1 @@ +{"version":1,"defects":{"Axiostudio\\FatturaElettronica\\Tests\\AnagraficaTest::testConstructorWithNullValues":4},"times":{"Axiostudio\\FatturaElettronica\\Tests\\AnagraficaTest::testConstructor":0.002,"Axiostudio\\FatturaElettronica\\Tests\\AnagraficaTest::testConstructorWithNullValues":0.001}} \ No newline at end of file diff --git a/.styleci.yml b/.styleci.yml new file mode 100644 index 0000000..f4d3cbc --- /dev/null +++ b/.styleci.yml @@ -0,0 +1,4 @@ +preset: laravel + +disabled: + - single_class_element_per_statement diff --git a/CHANGELOG.md b/CHANGELOG.md index c746c9d..c3e03a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,6 @@ All notable changes to `fattura-elettronica` will be documented in this file -## beta - 2023-11-06 +## beta - Versione Bea -- initial release +- Versione iniziale "beta" con funzionalità base diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..b146003 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,55 @@ +# Contributing + +Contributions are welcome. + +Please read and understand the contribution guide before creating an issue or pull request. + +## Etiquette + +This project is open source, and as such, the maintainers give their free time to build and maintain the source code +held within. They make the code freely available in the hope that it will be of use to other developers. It would be +extremely unfair for them to suffer abuse or anger for their hard work. + +Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the +world that developers are civilized and selfless people. + +It's the duty of the maintainer to ensure that all submissions to the project are of sufficient +quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. + +## Viability + +When requesting or submitting new features, first consider whether it might be useful to others. Open +source projects are used by many developers, who may have entirely different needs to your own. Think about +whether or not your feature is likely to be used by other users of the project. + +## Procedure + +Before filing an issue: + +- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. +- Check to make sure your feature suggestion isn't already present within the project. +- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. +- Check the pull requests tab to ensure that the feature isn't already in progress. + +Before submitting a pull request: + +- Check the codebase to ensure that your feature doesn't already exist. +- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. + +## Requirements + +If the project maintainer has any additional requirements, you will find them listed here. + +- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). + +- **Add tests!** - Your patch won't be accepted if it doesn't have tests. + +- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. + +- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. + +- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. + +- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. + +**Happy coding**! diff --git a/composer.json b/composer.json index 6c782d4..60953d9 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,11 @@ "spatie/array-to-xml": "^3.2", "symfony/validator": "^6.3" }, + "require-dev": { + "phpunit/phpunit": "^9.0", + "phpmd/phpmd" : "@stable", + "friendsofphp/php-cs-fixer": "^2.6" + }, "autoload": { "psr-4": { "Axiostudio\\FatturaElettronica\\": "src" @@ -29,6 +34,11 @@ "Axiostudio\\FatturaElettronica\\Tests\\": "tests" } }, + "scripts": { + "test": "vendor/bin/phpunit", + "test-coverage": "vendor/bin/phpunit --coverage-html coverage" + + }, "config": { "sort-packages": true } diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..58f4c6c --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,13 @@ + + + + + ./src/ + + + + + ./tests/ + + + diff --git a/tests/AnagraficaTest.php b/tests/AnagraficaTest.php new file mode 100644 index 0000000..0360a54 --- /dev/null +++ b/tests/AnagraficaTest.php @@ -0,0 +1,23 @@ +assertInstanceOf(Anagrafica::class, $anagrafica); + $this->assertEquals($denominazione, $anagrafica->Denominazione); + $this->assertEquals($nome, $anagrafica->Nome); + $this->assertEquals($cognome, $anagrafica->Cognome); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..9669a5c --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,8 @@ +