From 740095eeb4773a675115c78dedaa6c8c70552728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Thu, 25 May 2017 11:45:34 +0200 Subject: [PATCH] Initial commit --- .codeclimate.yml | 18 +++++++++++ .editorconfig | 20 ++++++++++++ .gitattributes | 10 ++++++ .github/CONDUCT.md | 32 +++++++++++++++++++ .github/CONTRIBUTING.md | 39 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE.md | 13 ++++++++ .github/PULL_REQUEST_TEMPLATE.md | 9 ++++++ .gitignore | 3 ++ .php_cs | 22 +++++++++++++ .travis.yml | 53 ++++++++++++++++++++++++++++++++ .travis/xdebug.sh | 22 +++++++++++++ LICENSE | 16 ++++++++++ Makefile | 20 ++++++++++++ README.md | 32 +++++++++++++++++++ composer.json | 34 ++++++++++++++++++++ src/.gitkeep | 0 test/Unit/phpunit.xml | 29 +++++++++++++++++ 17 files changed, 372 insertions(+) create mode 100644 .codeclimate.yml create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/CONDUCT.md create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .gitignore create mode 100644 .php_cs create mode 100644 .travis.yml create mode 100644 .travis/xdebug.sh create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100644 composer.json create mode 100644 src/.gitkeep create mode 100644 test/Unit/phpunit.xml diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 0000000..457dec3 --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,18 @@ +engines: + duplication: + enabled: true + config: + languages: + - php + fixme: + enabled: true + phpmd: + enabled: true + +ratings: + paths: + - src/ + - test/ + +exclude_paths: + - vendor/ diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b0e92ec --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.json] +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false + +[*.yml] +indent_size = 2 + +[Makefile] +indent_style = tab diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8520167 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,10 @@ +/.travis/ export-ignore +/.github/ export-ignore +/test/ export-ignore +/.codeclimate.yml export-ignore +/.editorconfig export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.php_cs export-ignore +/.travis.yml export-ignore +/Makefile export-ignore diff --git a/.github/CONDUCT.md b/.github/CONDUCT.md new file mode 100644 index 0000000..1b1647f --- /dev/null +++ b/.github/CONDUCT.md @@ -0,0 +1,32 @@ +# Contributor Code of Conduct + +As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we +pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, +submitting pull requests or patches, and other activities. + +We are committed to making participation in this project a harassment-free experience for everyone, regardless of level +of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, +race, ethnicity, age, religion, or nationality. + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery +* Personal attacks +* Trolling or insulting/derogatory comments +* Public or private harassment +* Publishing other's private information, such as physical or electronic addresses, without explicit permission +* Other unethical or unprofessional conduct +* Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, + issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, + project maintainers commit themselves to fairly and consistently applying these principles to every aspect of + managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently + removed from the project team. + +This code of conduct applies both within project spaces and in public spaces when an individual is representing the +project or its community. + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting +one or more of the project maintainers. + +This Code of Conduct is adapted from the Contributor Covenant, version 1.2.0, available from +http://contributor-covenant.org/version/1/2/0/ diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..74aecc2 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,39 @@ +# CONTRIBUTING + +We're using [Travis CI](https://travis-ci.org) as a continuous integration system. + +For details, see [`.travis.yml`](../.travis.yml). + +## Tests + +We're using [`phpunit/phpunit`](https://github.com/sebastianbergmann/phpunit) to drive the development. + +Run + +``` +$ make test +``` + +to run all the tests. + +## Coding Standards + +We are using [`friendsofphp/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer) to enforce coding standards. + +Run + +``` +$ make cs +``` + +to automatically fix coding standard violations. + +## Extra lazy? + +Run + +``` +$ make +``` + +to run both coding standards check and tests! diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..1788742 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,13 @@ +#### Steps required to reproduce the problem + +1. +2. +3. + +#### Expected Result + +* + +#### Actual Result + +* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..e448c72 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,9 @@ +This PR + +* [x] +* [ ] +* [ ] + +Follows #. +Related to #. +Fixes #. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c0e1dc4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/vendor/ +/.php_cs.cache +composer.lock diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..77a9ebc --- /dev/null +++ b/.php_cs @@ -0,0 +1,22 @@ +getFinder()->in(__DIR__); + +$cacheDir = \getenv('TRAVIS') ? \getenv('HOME') . '/.php-cs-fixer' : __DIR__; + +$config->setCacheFile($cacheDir . '/.php_cs.cache'); + +return $config; diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..973d7b3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,53 @@ +language: php + +sudo: false + +env: + global: + - secure: "OC6E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MzIHSH1is3t+uuTZCkOoAyHtXqpywqeLl9TONbXYq2sHxlP5p2755AVyxk2YSHjkMDb4V6bIgalBAXg6Z/BttJIYAaTitp3r4Bs808n7rjXJdDA9IX7tBpdObKVKlnFG12bgYEF/G2OB0a1bIxnhIgdl8RMx7DAlzajbDmuTOnt6sYd6KC804E6+8gWCs8cpcYafRAInoByo7EQlk70hqQuJdiAhUTgxSH5tZb33Sn1KP4gQzPFvIoA35e6GR4GxrdDWP8/hSNbVOwSoZjOO0z5AGovsa53tD2jc=" + +matrix: + include: + - php: 5.6 + env: WITH_LOWEST=true + - php: 5.6 + env: WITH_HIGHEST=true WITH_CS=true + - php: 7.0 + env: WITH_LOWEST=true + - php: 7.0 + env: WITH_HIGHEST=true + - php: 7.1 + env: WITH_LOWEST=true + - php: 7.1 + env: WITH_HIGHEST=true WITH_COVERAGE=true + +cache: + directories: + - $HOME/.composer/cache + - $HOME/.php-cs-fixer + +before_install: + - source .travis/xdebug.sh + - xdebug-disable + - composer validate + - composer config github-oauth.github.com $GITHUB_TOKEN + +install: + - if [[ "$WITH_LOWEST" == "true" ]]; then composer update --prefer-lowest; else composer install; fi + +before_script: + - mkdir -p "$HOME/.php-cs-fixer" + - mkdir -p build/logs + +script: + - if [[ "$WITH_CS" == "true" ]]; then vendor/bin/php-cs-fixer fix --config=.php_cs --diff --dry-run --verbose; fi + - if [[ "$WITH_COVERAGE" == "true" ]]; then xdebug-enable; fi + - if [[ "$WITH_COVERAGE" == "true" ]]; then vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-clover=build/logs/clover.xml; else vendor/bin/phpunit --configuration=test/Unit/phpunit.xml; fi + - if [[ "$WITH_COVERAGE" == "true" ]]; then xdebug-disable; fi + +after_success: + - if [[ "$WITH_COVERAGE" == "true" ]]; then vendor/bin/test-reporter --coverage-report=build/logs/clover.xml; fi + +notifications: + email: false diff --git a/.travis/xdebug.sh b/.travis/xdebug.sh new file mode 100644 index 0000000..c3cebe3 --- /dev/null +++ b/.travis/xdebug.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# The problem is that we do not want to remove the configuration file, just disable it for a few tasks, then enable it +# +# For reference, see +# +# - https://docs.travis-ci.com/user/languages/php#Disabling-preinstalled-PHP-extensions +# - https://docs.travis-ci.com/user/languages/php#Custom-PHP-configuration + +config="/home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini" + +function xdebug-disable() { + if [[ -f $config ]]; then + mv $config "$config.bak" + fi +} + +function xdebug-enable() { + if [[ -f "$config.bak" ]]; then + mv "$config.bak" $config + fi +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..cb45728 --- /dev/null +++ b/LICENSE @@ -0,0 +1,16 @@ +The MIT License (MIT) + +Copyright (c) 2017 Andreas Möller + +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. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8fa510b --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +.PHONY: composer coverage cs it test + +it: cs test + +composer: + rm -rf composer.lock + composer self-update + composer validate + composer update + +coverage: composer + vendor/bin/phpunit --configuration=test/Unit/phpunit.xml --coverage-text + +cs: composer + vendor/bin/php-cs-fixer fix --config=.php_cs --diff --verbose + +test: composer + vendor/bin/phpunit --configuration=test/Unit/phpunit.xml + composer update --prefer-lowest + vendor/bin/phpunit --configuration=test/Unit/phpunit.xml diff --git a/README.md b/README.md new file mode 100644 index 0000000..1c9cc99 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# factory-girl-definition + +[![Build Status](https://travis-ci.org/localheinz/factory-girl-definition.svg?branch=master)](https://travis-ci.org/localheinz/factory-girl-definition) +[![Code Climate](https://codeclimate.com/github/localheinz/factory-girl-definition/badges/gpa.svg)](https://codeclimate.com/github/localheinz/factory-girl-definition) +[![Test Coverage](https://codeclimate.com/github/localheinz/factory-girl-definition/badges/coverage.svg)](https://codeclimate.com/github/localheinz/factory-girl-definition/coverage) +[![Issue Count](https://codeclimate.com/github/localheinz/factory-girl-definition/badges/issue_count.svg)](https://codeclimate.com/github/localheinz/factory-girl-definition) +[![Latest Stable Version](https://poser.pugx.org/localheinz/factory-girl-definition/v/stable)](https://packagist.org/packages/localheinz/factory-girl-definition) +[![Total Downloads](https://poser.pugx.org/localheinz/factory-girl-definition/downloads)](https://packagist.org/packages/localheinz/factory-girl-definition) + +## Installation + +Run + +``` +$ composer require localheinz/factory-girl-definition +``` + +## Usage + +:bulb: This is a great place for showing a few usage examples! + +## Contributing + +Please have a look at [`CONTRIBUTING.md`](.github/CONTRIBUTING.md). + +## Code of Conduct + +Please have a look at [`CONDUCT.md`](.github/CONDUCT.md). + +## License + +This package is licensed using the MIT License. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..7ae0411 --- /dev/null +++ b/composer.json @@ -0,0 +1,34 @@ +{ + "name": "localheinz/factory-girl-definition", + "description": "Provides an interface and a finder for definitions with breerly/factory-girl-php.", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Andreas Möller", + "email": "am@localheinz.com" + } + ], + "config": { + "preferred-install": "dist", + "sort-packages": true + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "codeclimate/php-test-reporter": "0.4.4", + "localheinz/php-cs-fixer-config": "1.2.1", + "phpunit/phpunit": "^5.7.20" + }, + "autoload": { + "psr-4": { + "Localheinz\\FactoryGirl\\Definition\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Localheinz\\FactoryGirl\\Definition\\Test\\": "test" + } + } +} diff --git a/src/.gitkeep b/src/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/Unit/phpunit.xml b/test/Unit/phpunit.xml new file mode 100644 index 0000000..a13b7ab --- /dev/null +++ b/test/Unit/phpunit.xml @@ -0,0 +1,29 @@ + + + + . + + + + + ../../src + + +