diff --git a/.travis.yml b/.travis.yml index b369b288..dcaefcf5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ install: before_script: - cp config/autoload/travis.php.local.dist config/autoload/travis.local.php - mysql -uroot -e 'create database modules_test;' - - mysql -uroot modules_test < data/sql/0.sql + - php public/index.php migrations:migrate --no-interaction --verbose script: - vendor/bin/php-cs-fixer fix --config-file=./.php_cs --dry-run --diff -v diff --git a/Makefile b/Makefile index 7593e94d..b4f11655 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,6 @@ test: composer cp config/autoload/travis.php.local.dist config/autoload/travis.local.php mysql -uroot -e 'DROP DATABASE IF EXISTS modules_test;' mysql -uroot -e 'CREATE DATABASE modules_test;' - mysql -uroot modules_test < data/sql/0.sql + php public/index.php migrations:migrate --no-interaction --verbose vendor/bin/phpunit --configuration phpunit.xml rm config/autoload/travis.local.php diff --git a/build.xml b/build.xml index 2c466b8b..34518724 100644 --- a/build.xml +++ b/build.xml @@ -22,7 +22,12 @@ - + + + diff --git a/composer.json b/composer.json index aa17b02b..819be16f 100644 --- a/composer.json +++ b/composer.json @@ -4,12 +4,15 @@ "license": "BSD-3-Clause", "homepage": "https://zfmodules.com", "require": { - "evandotpro/edp-github": "0.2.*", + "php": "~5.5", "ext-intl": "*", + "doctrine/doctrine-module": "^0.9.0", + "doctrine/doctrine-orm-module": "^0.9.1", + "doctrine/migrations": "^1.1", + "evandotpro/edp-github": "0.2.*", "ezyang/htmlpurifier": "4.6.*", "monolog/monolog": "~1.12", "phing/phing": "~2.10", - "php": "~5.5", "socalnick/scn-social-auth": "1.14.1", "zendframework/zendframework": "~2.3.0", "zf-commons/zfc-user": "1.0.*", diff --git a/composer.lock b/composer.lock index 7704687d..faee489e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,832 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "20515c2c7353798b7f39a326e3ea95da", - "content-hash": "b19e31ca7d86a53a73da2e8c3ff1e494", + "hash": "352f7f1b2ce7cd85628f4d51fd027dd6", + "content-hash": "e3cd828fa33a790b035b1a5a65555d01", "packages": [ + { + "name": "doctrine/annotations", + "version": "v1.2.7", + "source": { + "type": "git", + "url": "https://github.com/doctrine/annotations.git", + "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/f25c8aab83e0c3e976fd7d19875f198ccf2f7535", + "reference": "f25c8aab83e0c3e976fd7d19875f198ccf2f7535", + "shasum": "" + }, + "require": { + "doctrine/lexer": "1.*", + "php": ">=5.3.2" + }, + "require-dev": { + "doctrine/cache": "1.*", + "phpunit/phpunit": "4.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Annotations\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Docblock Annotations Parser", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "docblock", + "parser" + ], + "time": "2015-08-31 12:32:49" + }, + { + "name": "doctrine/cache", + "version": "v1.4.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/8c434000f420ade76a07c64cbe08ca47e5c101ca", + "reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "phpunit/phpunit": ">=3.7", + "predis/predis": "~1.0", + "satooshi/php-coveralls": "~0.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Cache\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Caching library offering an object-oriented API for many cache backends", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "cache", + "caching" + ], + "time": "2015-08-31 12:36:41" + }, + { + "name": "doctrine/collections", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/collections.git", + "reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/collections/zipball/6c1e4eef75f310ea1b3e30945e9f06e652128b8a", + "reference": "6c1e4eef75f310ea1b3e30945e9f06e652128b8a", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Collections\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Collections Abstraction library", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "array", + "collections", + "iterator" + ], + "time": "2015-04-14 22:21:58" + }, + { + "name": "doctrine/common", + "version": "v2.5.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/common.git", + "reference": "0009b8f0d4a917aabc971fb089eba80e872f83f9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/common/zipball/0009b8f0d4a917aabc971fb089eba80e872f83f9", + "reference": "0009b8f0d4a917aabc971fb089eba80e872f83f9", + "shasum": "" + }, + "require": { + "doctrine/annotations": "1.*", + "doctrine/cache": "1.*", + "doctrine/collections": "1.*", + "doctrine/inflector": "1.*", + "doctrine/lexer": "1.*", + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~3.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common Library for Doctrine projects", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "collections", + "eventmanager", + "persistence", + "spl" + ], + "time": "2015-08-31 13:00:22" + }, + { + "name": "doctrine/dbal", + "version": "v2.5.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "01dbcbc5cd0a913d751418e635434a18a2f2a75c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/01dbcbc5cd0a913d751418e635434a18a2f2a75c", + "reference": "01dbcbc5cd0a913d751418e635434a18a2f2a75c", + "shasum": "" + }, + "require": { + "doctrine/common": ">=2.4,<2.6-dev", + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "4.*", + "symfony/console": "2.*" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\DBAL\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Database Abstraction Layer", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database", + "dbal", + "persistence", + "queryobject" + ], + "time": "2015-09-16 16:29:33" + }, + { + "name": "doctrine/doctrine-module", + "version": "0.9.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/DoctrineModule.git", + "reference": "81fd6a95609d88c2a059117ba18346240f2cc8d2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/DoctrineModule/zipball/81fd6a95609d88c2a059117ba18346240f2cc8d2", + "reference": "81fd6a95609d88c2a059117ba18346240f2cc8d2", + "shasum": "" + }, + "require": { + "doctrine/common": ">=2.4,<2.6-dev", + "php": ">=5.4", + "symfony/console": "~2.3|~3.0", + "zendframework/zend-authentication": "~2.3", + "zendframework/zend-cache": "~2.3", + "zendframework/zend-mvc": "~2.3", + "zendframework/zend-paginator": "~2.3", + "zendframework/zend-servicemanager": "~2.3", + "zendframework/zend-stdlib": "~2.3", + "zendframework/zend-validator": "~2.3" + }, + "require-dev": { + "doctrine/coding-standard": "dev-master", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2", + "zendframework/zendframework": "~2.3" + }, + "suggest": { + "doctrine/data-fixtures": "Data Fixtures if you want to generate test data or bootstrap data for your deployments" + }, + "bin": [ + "bin/doctrine-module" + ], + "type": "library", + "autoload": { + "psr-0": { + "DoctrineModule\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kyle Spraggs", + "email": "theman@spiffyjr.me", + "homepage": "http://www.spiffyjr.me/" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@hotmail.com" + }, + { + "name": "Michaƫl Gallego", + "email": "mic.gallego@gmail.com", + "homepage": "http://www.michaelgallego.fr" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://marco-pivetta.com/" + } + ], + "description": "Zend Framework 2 Module that provides Doctrine basic functionality required for ORM and ODM modules", + "homepage": "http://www.doctrine-project.org/", + "keywords": [ + "doctrine", + "module", + "zf2" + ], + "time": "2015-07-14 16:36:19" + }, + { + "name": "doctrine/doctrine-orm-module", + "version": "0.9.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/DoctrineORMModule.git", + "reference": "847db36f0f7ef8d940414e433e8b241aa601a6a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/DoctrineORMModule/zipball/847db36f0f7ef8d940414e433e8b241aa601a6a7", + "reference": "847db36f0f7ef8d940414e433e8b241aa601a6a7", + "shasum": "" + }, + "require": { + "doctrine/dbal": ">=2.4,<2.7", + "doctrine/doctrine-module": "~0.8", + "doctrine/orm": ">=2.5,<2.7", + "php": ">=5.4", + "symfony/console": "~2.5|~3.0", + "zendframework/zend-mvc": "~2.3", + "zendframework/zend-servicemanager": "~2.3", + "zendframework/zend-stdlib": "~2.3" + }, + "require-dev": { + "doctrine/data-fixtures": "1.0.*", + "doctrine/migrations": "1.0.*@dev", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2", + "zendframework/zend-developer-tools": "*", + "zendframework/zendframework": "~2.3" + }, + "suggest": { + "doctrine/migrations": "doctrine migrations if you want to keep your schema definitions versioned", + "zendframework/zend-developer-tools": "zend-developer-tools if you want to profile operations executed by the ORM during development", + "zendframework/zend-form": "if you want to use form elements backed by Doctrine" + }, + "type": "library", + "autoload": { + "psr-0": { + "DoctrineORMModule\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kyle Spraggs", + "email": "theman@spiffyjr.me", + "homepage": "http://www.spiffyjr.me/" + }, + { + "name": "Evan Coury", + "email": "me@evancoury.com", + "homepage": "http://blog.evan.pro/" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@hotmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://marco-pivetta.com/" + } + ], + "description": "Zend Framework 2 Module that provides Doctrine ORM functionality", + "homepage": "http://www.doctrine-project.org/", + "keywords": [ + "doctrine", + "module", + "orm", + "zf2" + ], + "time": "2015-10-05 23:06:08" + }, + { + "name": "doctrine/inflector", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/0bcb2e79d8571787f18b7eb036ed3d004908e604", + "reference": "0bcb2e79d8571787f18b7eb036ed3d004908e604", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "4.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Inflector\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common String Manipulations with regard to casing and singular/plural rules.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "inflection", + "pluralize", + "singularize", + "string" + ], + "time": "2014-12-20 21:24:13" + }, + { + "name": "doctrine/instantiator", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2015-06-14 21:17:01" + }, + { + "name": "doctrine/lexer", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/lexer.git", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", + "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Common\\Lexer\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "lexer", + "parser" + ], + "time": "2014-09-09 13:34:57" + }, + { + "name": "doctrine/migrations", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/migrations.git", + "reference": "d196ddc229f50c66c5a015c158adb78a2dfb4351" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/migrations/zipball/d196ddc229f50c66c5a015c158adb78a2dfb4351", + "reference": "d196ddc229f50c66c5a015c158adb78a2dfb4351", + "shasum": "" + }, + "require": { + "doctrine/dbal": "~2.2", + "php": ">=5.4.0", + "symfony/console": "~2.3", + "symfony/yaml": "~2.3" + }, + "require-dev": { + "doctrine/coding-standard": "dev-master", + "doctrine/orm": "2.*", + "johnkary/phpunit-speedtrap": "~1.0@dev", + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "~4.7", + "satooshi/php-coveralls": "0.6.*" + }, + "suggest": { + "symfony/console": "to run the migration from the console" + }, + "bin": [ + "bin/doctrine-migrations" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "v1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\DBAL\\Migrations\\": "lib/Doctrine/DBAL/Migrations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1" + ], + "authors": [ + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Database Schema migrations using Doctrine DBAL", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database", + "migrations" + ], + "time": "2015-09-29 11:13:06" + }, + { + "name": "doctrine/orm", + "version": "v2.5.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/doctrine2.git", + "reference": "e6a83bedbe67579cb0bfb688e982e617943a2945" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/doctrine2/zipball/e6a83bedbe67579cb0bfb688e982e617943a2945", + "reference": "e6a83bedbe67579cb0bfb688e982e617943a2945", + "shasum": "" + }, + "require": { + "doctrine/cache": "~1.4", + "doctrine/collections": "~1.2", + "doctrine/common": ">=2.5-dev,<2.6-dev", + "doctrine/dbal": ">=2.5-dev,<2.6-dev", + "doctrine/instantiator": "~1.0.1", + "ext-pdo": "*", + "php": ">=5.4", + "symfony/console": "~2.5" + }, + "require-dev": { + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "dev-master", + "symfony/yaml": "~2.1" + }, + "suggest": { + "symfony/yaml": "If you want to use YAML Metadata Mapping Driver" + }, + "bin": [ + "bin/doctrine", + "bin/doctrine.php" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.6.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\ORM\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Object-Relational-Mapper for PHP", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database", + "orm" + ], + "time": "2015-08-31 12:59:39" + }, { "name": "evandotpro/edp-github", "version": "0.2.0", @@ -340,8 +1163,118 @@ }, "type": "library", "autoload": { - "psr-0": { - "Psr\\Log\\": "" + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2012-12-21 11:40:51" + }, + { + "name": "socalnick/scn-social-auth", + "version": "1.14.1", + "source": { + "type": "git", + "url": "https://github.com/SocalNick/ScnSocialAuth.git", + "reference": "cbb85fe49355eb76148e1b62b3cc41fd6b7d98ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/SocalNick/ScnSocialAuth/zipball/cbb85fe49355eb76148e1b62b3cc41fd6b7d98ea", + "reference": "cbb85fe49355eb76148e1b62b3cc41fd6b7d98ea", + "shasum": "" + }, + "require": { + "hybridauth/hybridauth": "2.2.*", + "php": ">=5.3.3", + "zendframework/zendframework": "2.*", + "zf-commons/zfc-base": "0.1.*", + "zf-commons/zfc-user": "1.0.*" + }, + "require-dev": { + "mockery/mockery": "0.8.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "ScnSocialAuth": "src/", + "ScnSocialAuthTest": "test/" + }, + "classmap": [ + "./" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nicholas Calugar", + "email": "njcalugar@gmail.com", + "homepage": "http://socalnick.github.com/", + "role": "Developer" + } + ], + "description": "Uses the HybridAuth PHP library to Enable authentication via Google, Facebook, Twitter, Yahoo!, etc for the ZfcUser ZF2 module.", + "homepage": "https://github.com/SocalNick/ScnSocialAuth", + "keywords": [ + "zf2" + ], + "time": "2014-06-06 01:43:05" + }, + { + "name": "symfony/console", + "version": "v2.7.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "9ff9032151186bd66ecee727d728f1319f52d1d8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/9ff9032151186bd66ecee727d728f1319f52d1d8", + "reference": "9ff9032151186bd66ecee727d728f1319f52d1d8", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.1", + "symfony/phpunit-bridge": "~2.7", + "symfony/process": "~2.1" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -350,70 +1283,66 @@ ], "authors": [ { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Common interface for logging libraries", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2012-12-21 11:40:51" + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2015-09-03 11:40:38" }, { - "name": "socalnick/scn-social-auth", - "version": "1.14.1", + "name": "symfony/yaml", + "version": "v2.7.4", "source": { "type": "git", - "url": "https://github.com/SocalNick/ScnSocialAuth.git", - "reference": "cbb85fe49355eb76148e1b62b3cc41fd6b7d98ea" + "url": "https://github.com/symfony/Yaml.git", + "reference": "2dc7b06c065df96cc686c66da2705e5e18aef661" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SocalNick/ScnSocialAuth/zipball/cbb85fe49355eb76148e1b62b3cc41fd6b7d98ea", - "reference": "cbb85fe49355eb76148e1b62b3cc41fd6b7d98ea", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/2dc7b06c065df96cc686c66da2705e5e18aef661", + "reference": "2dc7b06c065df96cc686c66da2705e5e18aef661", "shasum": "" }, "require": { - "hybridauth/hybridauth": "2.2.*", - "php": ">=5.3.3", - "zendframework/zendframework": "2.*", - "zf-commons/zfc-base": "0.1.*", - "zf-commons/zfc-user": "1.0.*" + "php": ">=5.3.9" }, "require-dev": { - "mockery/mockery": "0.8.0" + "symfony/phpunit-bridge": "~2.7" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7-dev" + } + }, "autoload": { - "psr-0": { - "ScnSocialAuth": "src/", - "ScnSocialAuthTest": "test/" - }, - "classmap": [ - "./" - ] + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { - "name": "Nicholas Calugar", - "email": "njcalugar@gmail.com", - "homepage": "http://socalnick.github.com/", - "role": "Developer" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Uses the HybridAuth PHP library to Enable authentication via Google, Facebook, Twitter, Yahoo!, etc for the ZfcUser ZF2 module.", - "homepage": "https://github.com/SocalNick/ScnSocialAuth", - "keywords": [ - "zf2" - ], - "time": "2014-06-06 01:43:05" + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2015-08-24 07:13:45" }, { "name": "zendframework/zendframework", @@ -819,78 +1748,25 @@ ], "time": "2014-03-11 13:42:24" }, - { - "name": "doctrine/instantiator", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", - "shasum": "" - }, - "require": { - "php": ">=5.3,<8.0-DEV" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2015-06-14 21:17:01" - }, { "name": "fabpot/php-cs-fixer", - "version": "v1.5", + "version": "v1.10.1", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "2d6851520bf0250f668307ab2fd28cbb0b35d2b9" + "reference": "12dbcd1462f1e3a5a96c6c7398af26b28e092a8a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/2d6851520bf0250f668307ab2fd28cbb0b35d2b9", - "reference": "2d6851520bf0250f668307ab2fd28cbb0b35d2b9", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/12dbcd1462f1e3a5a96c6c7398af26b28e092a8a", + "reference": "12dbcd1462f1e3a5a96c6c7398af26b28e092a8a", "shasum": "" }, "require": { + "ext-tokenizer": "*", "php": ">=5.3.6", "sebastian/diff": "~1.1", - "symfony/console": "~2.1", + "symfony/console": "~2.3", "symfony/event-dispatcher": "~2.1", "symfony/filesystem": "~2.1", "symfony/finder": "~2.1", @@ -923,8 +1799,8 @@ "email": "fabien@symfony.com" } ], - "description": "A script to automatically fix Symfony Coding Standard", - "time": "2015-02-18 19:35:59" + "description": "A tool to automatically fix PHP code style", + "time": "2015-10-12 20:13:46" }, { "name": "fzaninotto/faker", @@ -1822,74 +2698,17 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2015-06-21 13:59:46" }, - { - "name": "symfony/console", - "version": "v2.7.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/Console.git", - "reference": "9ff9032151186bd66ecee727d728f1319f52d1d8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/9ff9032151186bd66ecee727d728f1319f52d1d8", - "reference": "9ff9032151186bd66ecee727d728f1319f52d1d8", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1", - "symfony/phpunit-bridge": "~2.7", - "symfony/process": "~2.1" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Console Component", - "homepage": "https://symfony.com", - "time": "2015-09-03 11:40:38" - }, { "name": "symfony/event-dispatcher", "version": "v2.7.4", "source": { "type": "git", - "url": "https://github.com/symfony/EventDispatcher.git", + "url": "https://github.com/symfony/event-dispatcher.git", "reference": "b58c916f1db03a611b72dd702564f30ad8fe83fa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/b58c916f1db03a611b72dd702564f30ad8fe83fa", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b58c916f1db03a611b72dd702564f30ad8fe83fa", "reference": "b58c916f1db03a611b72dd702564f30ad8fe83fa", "shasum": "" }, @@ -1942,12 +2761,12 @@ "version": "v2.7.4", "source": { "type": "git", - "url": "https://github.com/symfony/Filesystem.git", + "url": "https://github.com/symfony/filesystem.git", "reference": "f079e9933799929584200b9a926f72f29e291654" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/f079e9933799929584200b9a926f72f29e291654", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/f079e9933799929584200b9a926f72f29e291654", "reference": "f079e9933799929584200b9a926f72f29e291654", "shasum": "" }, @@ -2133,55 +2952,6 @@ "homepage": "https://symfony.com", "time": "2015-08-24 07:13:45" }, - { - "name": "symfony/yaml", - "version": "v2.7.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "2dc7b06c065df96cc686c66da2705e5e18aef661" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/2dc7b06c065df96cc686c66da2705e5e18aef661", - "reference": "2dc7b06c065df96cc686c66da2705e5e18aef661", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.7-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2015-08-24 07:13:45" - }, { "name": "zendframework/zend-developer-tools", "version": "dev-master", @@ -2381,8 +3151,8 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "ext-intl": "*", - "php": "~5.5" + "php": "~5.5", + "ext-intl": "*" }, "platform-dev": [] } diff --git a/config/application.config.php b/config/application.config.php index 10b10a35..29180189 100644 --- a/config/application.config.php +++ b/config/application.config.php @@ -2,6 +2,8 @@ return [ 'modules' => [ + 'DoctrineModule', + 'DoctrineORMModule', 'ZF\DevelopmentMode', 'ZfcBase', 'ZfcUser', diff --git a/config/autoload/global.php b/config/autoload/global.php index e3aaec48..8bc724c1 100644 --- a/config/autoload/global.php +++ b/config/autoload/global.php @@ -14,4 +14,25 @@ 'username' => 'modules', 'password' => 'modules', ], + 'doctrine' => [ + 'connection' => [ + 'orm_default' => [ + 'params' => [ + 'host' => 'localhost', + 'port' => '3306', + 'user' => 'modules', + 'password' => 'modules', + 'dbname' => 'modules', + ], + ], + ], + 'migrations_configuration' => [ + 'orm_default' => [ + 'directory' => 'module/Application/src/Application/Doctrine/DBAL/Migration', + 'name' => 'ZFModules DBAL Migrations', + 'namespace' => 'Application\Doctrine\DBAL\Migration', + 'table' => 'doctrine_migration_versions', + ], + ], + ], ]; diff --git a/config/autoload/travis.php.local.dist b/config/autoload/travis.php.local.dist index d9bfa9e1..51111494 100644 --- a/config/autoload/travis.php.local.dist +++ b/config/autoload/travis.php.local.dist @@ -7,4 +7,17 @@ return [ 'username' => 'root', 'password' => '', ], + 'doctrine' => [ + 'connection' => [ + 'orm_default' => [ + 'params' => [ + 'host' => 'localhost', + 'port' => '3306', + 'user' => 'root', + 'password' => '', + 'dbname' => 'modules_test', + ], + ], + ], + ], ]; diff --git a/data/sql/0.sql b/data/sql/0.sql deleted file mode 100644 index 8cdba07d..00000000 --- a/data/sql/0.sql +++ /dev/null @@ -1,102 +0,0 @@ --- --- Database: `modules` --- - --- -------------------------------------------------------- - --- --- Table structure for table `module` --- - -CREATE TABLE IF NOT EXISTS `module` ( - `module_id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(255) NOT NULL, - `description` text NOT NULL, - `url` varchar(500) NOT NULL, - `meta_data` blob, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT NULL, - `photo_url` varchar(255) DEFAULT NULL, - `owner` varchar(255) NOT NULL, - PRIMARY KEY(`module_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- -------------------------------------------------------- - --- --- Table structure for table `module_admin` --- - -CREATE TABLE IF NOT EXISTS `module_admin` ( - `user_id` int(11) NOT NULL, - `module_id` int(11) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- -------------------------------------------------------- - --- --- Table structure for table `user` --- - -CREATE TABLE IF NOT EXISTS `user` ( - `user_id` int(11) NOT NULL AUTO_INCREMENT, - `username` varchar(255) DEFAULT NULL, - `email` varchar(255) DEFAULT NULL, - `display_name` varchar(50) DEFAULT NULL, - `password` varchar(128) NOT NULL, - `photo_url` varchar(255) DEFAULT NULL, - `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, - `state` int(2) DEFAULT NULL, - PRIMARY KEY(`user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; - --- -------------------------------------------------------- - --- --- Table structure for table `user_provider` --- - -CREATE TABLE IF NOT EXISTS `user_provider` ( - `user_id` int(11) NOT NULL, - `provider_id` varchar(50) NOT NULL, - `provider` varchar(255) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- --- Indexes for dumped tables --- - --- --- Indexes for table `module_admin` --- -ALTER TABLE `module_admin` - ADD PRIMARY KEY (`user_id`,`module_id`), ADD KEY `module_id` (`module_id`); - --- --- Indexes for table `user` --- -ALTER TABLE `user` - ADD UNIQUE KEY `username` (`username`), ADD UNIQUE KEY `email` (`email`); - --- --- Indexes for table `user_provider` --- -ALTER TABLE `user_provider` - ADD PRIMARY KEY (`user_id`,`provider_id`), ADD UNIQUE KEY `provider_id` (`provider_id`,`provider`); - --- --- Constraints for dumped tables --- - --- --- Constraints for table `module_admin` --- -ALTER TABLE `module_admin` -ADD CONSTRAINT `module_admin_ibfk_2` FOREIGN KEY (`module_id`) REFERENCES `module` (`module_id`) ON DELETE CASCADE, -ADD CONSTRAINT `module_admin_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE; - --- --- Constraints for table `user_provider` --- -ALTER TABLE `user_provider` -ADD CONSTRAINT `user_provider_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`); diff --git a/module/Application/src/Application/Doctrine/DBAL/Migration/Version20150926125836.php b/module/Application/src/Application/Doctrine/DBAL/Migration/Version20150926125836.php new file mode 100644 index 00000000..d9cdfff4 --- /dev/null +++ b/module/Application/src/Application/Doctrine/DBAL/Migration/Version20150926125836.php @@ -0,0 +1,125 @@ +addSql(' + CREATE TABLE IF NOT EXISTS `module` ( + `module_id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `description` text NOT NULL, + `url` varchar(500) NOT NULL, + `meta_data` blob, + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NULL DEFAULT NULL, + `photo_url` varchar(255) DEFAULT NULL, + `owner` varchar(255) NOT NULL, + PRIMARY KEY (`module_id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + '); + + $this->addSql(' + CREATE TABLE IF NOT EXISTS `module_admin` ( + `user_id` int(11) NOT NULL, + `module_id` int(11) NOT NULL, + PRIMARY KEY (`user_id`,`module_id`), + KEY `module_id` (`module_id`), + CONSTRAINT `module_admin_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE, + CONSTRAINT `module_admin_ibfk_2` FOREIGN KEY (`module_id`) REFERENCES `module` (`module_id`) ON DELETE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + '); + + $this->addSql(' + CREATE TABLE IF NOT EXISTS `user` ( + `user_id` int(11) NOT NULL AUTO_INCREMENT, + `username` varchar(255) DEFAULT NULL, + `email` varchar(255) DEFAULT NULL, + `display_name` varchar(50) DEFAULT NULL, + `password` varchar(128) NOT NULL, + `photo_url` varchar(255) DEFAULT NULL, + `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `state` int(2) DEFAULT NULL, + PRIMARY KEY (`user_id`), + UNIQUE KEY `username` (`username`), + UNIQUE KEY `email` (`email`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + '); + + $this->addSql(' + CREATE TABLE IF NOT EXISTS `user_provider` ( + `user_id` int(11) NOT NULL, + `provider_id` varchar(50) NOT NULL, + `provider` varchar(255) NOT NULL, + PRIMARY KEY (`user_id`,`provider_id`), + UNIQUE KEY `provider_id` (`provider_id`,`provider`), + CONSTRAINT `user_provider_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + '); + } + + public function down(Schema $schema) + { + $tables = [ + 'module', + 'module_admin', + 'user', + 'user_provider', + ]; + + foreach ($tables as $table) { + $schema->dropTable($table); + } + } + + public function preUp(Schema $schema) + { + $this->pre(); + } + + public function postUp(Schema $schema) + { + $this->post(); + } + + public function preDown(Schema $schema) + { + $this->pre(); + } + + public function postDown(Schema $schema) + { + $this->post(); + } + + private function pre() + { + $this->addSql('SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT'); + $this->addSql('SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS'); + $this->addSql('SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION'); + $this->addSql('SET NAMES utf8'); + $this->addSql('SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0'); + $this->addSql("SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'"); + $this->addSql('SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0'); + } + + private function post() + { + $this->addSql('SET SQL_NOTES=@OLD_SQL_NOTES'); + $this->addSql('SET SQL_MODE=@OLD_SQL_MODE'); + $this->addSql('SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS'); + $this->addSql('SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT'); + $this->addSql('SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS'); + $this->addSql('SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION'); + } +} diff --git a/module/Application/test/ApplicationTest/Integration/DBAL/Migration/MigrationTest.php b/module/Application/test/ApplicationTest/Integration/DBAL/Migration/MigrationTest.php new file mode 100644 index 00000000..a5259be4 --- /dev/null +++ b/module/Application/test/ApplicationTest/Integration/DBAL/Migration/MigrationTest.php @@ -0,0 +1,130 @@ +migrateUpTo(); + } + + /** + * @dataProvider providerMigration + * + * @param string $identifier + * @param string $previousIdentifier + */ + public function testMigration($identifier, $previousIdentifier) + { + $this->migrateUpTo($previousIdentifier); + + $this->assertCanMigrateUpTo($identifier); + $this->assertCanMigrateDownFrom($identifier, $previousIdentifier); + } + + /** + * @return \Generator + */ + public function providerMigration() + { + $previousIdentifier = '0'; + + foreach ($this->getMigrationConfiguration()->getAvailableVersions() as $identifier) { + yield [ + $identifier, + $previousIdentifier, + ]; + + $previousIdentifier = $identifier; + }; + } + + /** + * Asserts that the migration with the specified version can be rolled back. + * + * @param string $identifier + * @param string $previousIdentifier + * + * @throws \Exception + */ + private function assertCanMigrateDownFrom($identifier, $previousIdentifier) + { + $version = $this->getMigrationConfiguration()->getVersion($identifier); + + try { + $version->execute('down'); + } catch (\Exception $exception) { + $this->fail(sprintf( + 'Failed asserting that the version "%s" can be rolled back from - %s', + $identifier, + $exception->getMessage() + )); + + throw $exception; + } + + $this->assertSame($previousIdentifier, $this->getMigrationConfiguration()->getCurrentVersion()); + } + + /** + * Asserts that the migration with the specified version can be rolled to. + * + * @param string $identifier + * + * @throws DBAL\Migrations\MigrationException + * @throws \Exception + */ + private function assertCanMigrateUpTo($identifier) + { + $version = $this->getMigrationConfiguration()->getVersion($identifier); + + try { + $version->execute('up'); + } catch (\Exception $exception) { + $this->fail(sprintf( + 'Failed asserting that the version "%s" can be rolled up to - %s', + $identifier, + $exception->getMessage() + )); + + throw $exception; + } + + $this->assertSame($identifier, $this->getMigrationConfiguration()->getCurrentVersion()); + } + + /** + * Ensure that the migration with the specified version has been migrated up to. + * + * @param string $identifier + */ + private function migrateUpTo($identifier = null) + { + $migration = new DBAL\Migrations\Migration($this->getMigrationConfiguration()); + $migration->migrate($identifier); + } + + /** + * @return DBAL\Migrations\Configuration\Configuration + */ + private function getMigrationConfiguration() + { + if ($this->configuration === null) { + $serviceManager = Bootstrap::getServiceManager(); + + /* @var DBAL\Migrations\Configuration\Configuration $migrationConfiguration */ + $this->configuration = $serviceManager->get('doctrine.migrations_configuration.orm_default'); + } + + return $this->configuration; + } +}