From 4e13a0b79a2522c3bef499db6c6689a0062ee7e6 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Fri, 11 Nov 2022 11:30:45 +0100 Subject: [PATCH] Initial commit --- .php-cs-fixer.php | 13 ++++++++++ CHANGELOG.md | 11 ++++++++ LICENSE.md | 21 +++++++++++++++ README.en.md | 65 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++ composer.json | 39 ++++++++++++++++++++++++++++ phpstan.neon | 10 +++++++ phpunit.xml | 20 ++++++++++++++ 8 files changed, 245 insertions(+) create mode 100644 .php-cs-fixer.php create mode 100644 CHANGELOG.md create mode 100644 LICENSE.md create mode 100644 README.en.md create mode 100644 README.md create mode 100644 composer.json create mode 100644 phpstan.neon create mode 100644 phpunit.xml diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..f0512a0 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,13 @@ +in(__DIR__) +; + +$config = new PhpCsFixer\Config(); +return $config->setRules([ + '@PHP73Migration' => true, + '@PSR12' => true + ]) + ->setFinder($finder) +; \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ba1b494 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased](https://git.d3data.de/D3Public/TestingTools/compare/1.0.0.0...rel_1.x) + +## [1.0.0.0](https://git.d3data.de/D3Public/TestingTools/releases/tag/1.0.0.0) - 2022-11-11 +### Added +- implemented features \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..8ec303a --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 D3 Data Development (Inh. Thomas Dartsch) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000..b3b816b --- /dev/null +++ b/README.en.md @@ -0,0 +1,65 @@ +[![deutsche Version](https://logos.oxidmodule.com/de2_xs.svg)](README.md) +[![english version](https://logos.oxidmodule.com/en2_xs.svg)](README.en.md) + +# Tools for better testable code + +This package provides tools to circumvent difficulties when testing plug-in code from customisable frameworks (e.g. shop software). + +- Method bundles can be included as traits depending on the class. +- contains methods for the production code and prepared methods for own tests to validate the production code + +- `Production\IsMockable`: contains methods for mocking parent calls +- `Development\IsMockable`: contains test code for `Production\IsMockable`. +- `Development\IsTestable`: contains methods for better accessibility of protected code + +## Table of content + +- [Installation](#installation) +- [How to use](#how-to-use) +- [Changelog](#changelog) +- [Contributing](#contributing) +- [License](#license) +- [Further licences and terms of use](#further-licences-and-terms-of-use) + +## Installation + +This package requires a project installed with Composer. + +Open a command line and navigate to the root directory of the installation. Execute the following command. Adapt the path details to your installation environment. + +```bash +php composer require d3/testingtools:^1.0 +``` + +## How to use + +Include the respective trait in your class and use the desired method in your code: + +``` +use \D3\TestingTools\Production\IsMockable; +``` + +## Changelog + +See [CHANGELOG](CHANGELOG.md) for further informations. + +## Contributing + +If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue. Don't forget to give the project a star! Thanks again! + +- Fork the Project +- Create your Feature Branch (git checkout -b feature/AmazingFeature) +- Commit your Changes (git commit -m 'Add some AmazingFeature') +- Push to the Branch (git push origin feature/AmazingFeature) +- Open a Pull Request + +## License +(status: 2022-11-11) + +Distributed under the MIT license. + +``` +Copyright (c) D3 Data Development (Inh. Thomas Dartsch) +``` + +For full copyright and licensing information, please see the [LICENSE](LICENSE.md) file distributed with this source code. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..133a065 --- /dev/null +++ b/README.md @@ -0,0 +1,66 @@ +[![deutsche Version](https://logos.oxidmodule.com/de2_xs.svg)](README.md) +[![english version](https://logos.oxidmodule.com/en2_xs.svg)](README.en.md) + +# Hilfstools für besser testbaren Code + +Dieses Paket stellt Hilfstools bereit, um Schwierigkeiten beim Testen von Plugincode aus frei erweiterbaren Frameworks (z.B. Shopsoftware) zu umgehen. + +- Methodenbundles lassen sich als Trait klassenabhängig einbinden +- enthält Methoden für den Produktivcode und vorbereitete Methoden für eigene Tests, um den Produktivcode zu validieren + +- `Production\IsMockable`: enthält Methoden zum Mocken von Parentaufrufen +- `Development\IsMockable`: enthält Testcode für `Production\IsMockable` +- `Development\IsTestable`: enthält Methoden für bessere Zugänglichkeit von protected Code + +## Inhaltsverzeichnis + +- [Installation](#installation) +- [Verwendung](#verwendung) +- [Changelog](#changelog) +- [Beitragen](#beitragen) +- [Lizenz](#lizenz) +- [weitere Lizenzen und Nutzungsbedingungen](#weitere-lizenzen-und-nutzungsbedingungen) + +## Installation + +Dieses Paket erfordert ein mit Composer installiertes Projekt. + +Öffnen Sie eine Kommandozeile und navigieren Sie zum Stammverzeichnis Ihrer Installation. Führen Sie den folgenden Befehl aus. Passen Sie die Pfadangaben an Ihre Installationsumgebung an. + + +```bash +php composer require d3/d3/testingtools:^1.0 +``` + +## Verwendung + +Binden Sie den jeweiligen Trait in Ihre Klasse ein und verwenden die gewünschte Methode in Ihrem Code: + +``` +use \D3\TestingTools\Production\IsMockable; +``` + +## Changelog + +Siehe [CHANGELOG](CHANGELOG.md) für weitere Informationen. + +## Beitragen + +Wenn Sie eine Verbesserungsvorschlag haben, legen Sie einen Fork des Repositories an und erstellen Sie einen Pull Request. Alternativ können Sie einfach ein Issue erstellen. Fügen Sie das Projekt zu Ihren Favoriten hinzu. Vielen Dank. + +- Erstellen Sie einen Fork des Projekts +- Erstellen Sie einen Feature Branch (git checkout -b feature/AmazingFeature) +- Fügen Sie Ihre Änderungen hinzu (git commit -m 'Add some AmazingFeature') +- Übertragen Sie den Branch (git push origin feature/AmazingFeature) +- Öffnen Sie einen Pull Request + +## Lizenz +(Stand: 11.11.2022) + +Vertrieben unter der MIT Lizenz. + +``` +Copyright (c) D3 Data Development (Inh. Thomas Dartsch) +``` + +Die vollständigen Copyright- und Lizenzinformationen entnehmen Sie bitte der [LICENSE](LICENSE.md)-Datei, die mit diesem Quellcode verteilt wurde. \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..3133778 --- /dev/null +++ b/composer.json @@ -0,0 +1,39 @@ +{ + "name": "d3/testingtools", + "type": "library", + "description": "some tools to improve code tests", + "keywords": [ + "PHP Unit", + "Tests", + "tools" + ], + "homepage": "https://d3data.de/", + "authors": [ + { + "name": "D3 Data Development (Inh. Thomas Dartsch)", + "email": "info@shopmodule.com", + "homepage": "https://www.d3data.de", + "role": "Owner" + } + ], + "support": { + "email": "support@shopmodule.com" + }, + "license": [ + "MIT" + ], + "require": { + "php": "^7 || ^8" + }, + "require-dev": { + "phpunit/phpunit" : "^9.5", + "friendsofphp/php-cs-fixer": "^3.9", + "phpstan/phpstan": "^1.8" + }, + "autoload": { + "psr-4": { + "D3\\TestingTools\\": "src", + "D3\\TestingTools\\Tests\\": "Tests" + } + } +} \ No newline at end of file diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..b6e0779 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,10 @@ +parameters: + scanFiles: + - IntelliSenseHelper.php + - ../../oxid-esales/oxideshop-ce/source/oxfunctions.php + - ../../oxid-esales/oxideshop-ce/source/overridablefunctions.php + level: 9 + phpVersion: 70100 + checkMissingIterableValueType: false + ignoreErrors: + - '#Psr\\Container\\ContainerExceptionInterface is not subtype of Throwable#' diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..516e222 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,20 @@ + + + + + src + + + + + + + ./Tests + + +