From 70bf75361bd39afdfe2071e94600b1e427d66074 Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 12 Dec 2013 16:09:29 +0100 Subject: [PATCH 1/2] Added Travious, coveralls and psr checking --- .gitignore | 4 ++++ .travis.yml | 19 +++++++++++++++++++ README.md | 5 +++++ composer.json | 5 +++++ phpunit.xml | 29 +++++++++++++++++++++++++++++ tests/Bootstrap.php | 22 ++++++++++++++++++++++ 6 files changed, 84 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 phpunit.xml create mode 100644 tests/Bootstrap.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0ee1ad3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/build +/vendor +composer.lock +composer.phar \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4153969 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +language: php +php: + - 5.4 + - 5.5 + +before_script: + - composer self-update + - composer update --prefer-source; composer install --dev --prefer-source; + +script: + - ./vendor/bin/phpunit --coverage-clover ./build/logs/clover.xml + - ./vendor/bin/phpcs --standard=PSR2 ./src/ ./tests/ + +after_script: + - php vendor/bin/coveralls -v + +notifications: + irc: "irc.freenode.org#zftalk.modules" + email: false \ No newline at end of file diff --git a/README.md b/README.md index 43c6a44..7ec769a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # DoctrineDataFixture Module for Zend Framework 2 +[![Build Status](https://travis-ci.org/Hounddog/DoctrineDataFixtureModule.png)](https://travis-ci.org/Hounddog/DoctrineDataFixtureModule) +[![Coverage Status](https://coveralls.io/repos/Hounddog/DoctrineDataFixtureModule/badge.png?branch=master)](https://coveralls.io/r/Hounddog/DoctrineDataFixtureModule) + +## Introduction + The DoctrineDataFixtureModule module intends to integrate Doctrine 2 data-fixture with Zend Framework 2 quickly and easily. The following features are intended to work out of the box: diff --git a/composer.json b/composer.json index e1d44ff..2896488 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,11 @@ "doctrine/data-fixtures": "1.0.*", "doctrine/doctrine-orm-module": "~0.7" }, + "require-dev": { + "phpunit/phpunit" : "3.7.*", + "satooshi/php-coveralls": ">=0.6.0", + "squizlabs/php_codesniffer": "1.4.*" + }, "autoload": { "psr-0": { "DoctrineDataFixtureModule": "src/" diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..a088e40 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,29 @@ + + + + + ./tests/DoctrineDataFixtureTest + + + + ./src + + + + + + \ No newline at end of file diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php new file mode 100644 index 0000000..3ad8797 --- /dev/null +++ b/tests/Bootstrap.php @@ -0,0 +1,22 @@ +add('DoctrineDataFixtureTest\\', __DIR__); + +unset($files, $file, $loader); \ No newline at end of file From 29c5ab1f80182da03056387c376610878b7cf4d9 Mon Sep 17 00:00:00 2001 From: Martin Date: Thu, 12 Dec 2013 16:22:02 +0100 Subject: [PATCH 2/2] Fixed PSR issues --- Module.php | 4 +-- .../Command/ImportCommand.php | 25 ++++++++++--------- src/DoctrineDataFixtureModule/Module.php | 2 +- .../Service/FixtureFactory.php | 4 +-- tests/Bootstrap.php | 2 +- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Module.php b/Module.php index acd3fcc..30f860c 100644 --- a/Module.php +++ b/Module.php @@ -2,6 +2,6 @@ /** * This file is placed here for compatibility with Zendframework 2's ModuleManager. * It allows usage of this module even without composer. - * The original Module.php is in 'src/DoctrineORMModule' in order to respect PSR-0 + * The original Module.php is in 'src/DoctrineDataFixtureModule' in order to respect PSR-0 */ -require_once __DIR__ . '/src/DoctrineDataFixtureModule/Module.php'; \ No newline at end of file +require_once __DIR__ . '/src/DoctrineDataFixtureModule/Module.php'; diff --git a/src/DoctrineDataFixtureModule/Command/ImportCommand.php b/src/DoctrineDataFixtureModule/Command/ImportCommand.php index f944eda..829c377 100644 --- a/src/DoctrineDataFixtureModule/Command/ImportCommand.php +++ b/src/DoctrineDataFixtureModule/Command/ImportCommand.php @@ -19,17 +19,17 @@ namespace DoctrineDataFixtureModule\Command; -use Symfony\Component\Console\Command\Command, - Symfony\Component\Console\Input\InputInterface, - Symfony\Component\Console\Output\OutputInterface, - Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Doctrine\ORM\Tools\SchemaTool, - Doctrine\DBAL\Migrations\Configuration\Configuration; - +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Doctrine\ORM\Tools\SchemaTool; +use Doctrine\DBAL\Migrations\Configuration\Configuration; use Doctrine\Common\DataFixtures\Loader; use Doctrine\Common\DataFixtures\Executor\ORMExecutor; use Doctrine\Common\DataFixtures\Purger\ORMPurger; + /** * Command for generate migration classes by comparing your current database schema * to your mapping information. @@ -53,7 +53,8 @@ protected function configure() $this->setName('data-fixture:import') ->setDescription('Import Data Fixtures') - ->setHelp(<<setHelp( +<<getOption('purge-with-truncate')) { + if ($input->getOption('purge-with-truncate')) { $purger->setPurgeMode(self::PURGE_MODE_TRUNCATE); } $executor = new ORMExecutor($this->em, $purger); - foreach($this->paths as $key => $value) { + foreach ($this->paths as $key => $value) { $loader->loadFromDirectory($value); } $executor->execute($loader->getFixtures(), $input->getOption('append')); } - public function setPath($paths) + public function setPath($paths) { $this->paths=$paths; } diff --git a/src/DoctrineDataFixtureModule/Module.php b/src/DoctrineDataFixtureModule/Module.php index 13bfca4..dceb0a8 100644 --- a/src/DoctrineDataFixtureModule/Module.php +++ b/src/DoctrineDataFixtureModule/Module.php @@ -62,7 +62,7 @@ public function init(ModuleManager $e) $events = $e->getEventManager()->getSharedManager(); // Attach to helper set event and load the entity manager helper. - $events->attach('doctrine', 'loadCli.post', function(EventInterface $e) { + $events->attach('doctrine', 'loadCli.post', function (EventInterface $e) { /* @var $cli \Symfony\Component\Console\Application */ $cli = $e->getTarget(); diff --git a/src/DoctrineDataFixtureModule/Service/FixtureFactory.php b/src/DoctrineDataFixtureModule/Service/FixtureFactory.php index 17a7eb4..ee74528 100644 --- a/src/DoctrineDataFixtureModule/Service/FixtureFactory.php +++ b/src/DoctrineDataFixtureModule/Service/FixtureFactory.php @@ -52,7 +52,7 @@ public function createService(ServiceLocatorInterface $sl) public function getOptions(ServiceLocatorInterface $sl, $key) { $options = $sl->get('Configuration'); - if(!isset($options['data-fixture'])) { + if (!isset($options['data-fixture'])) { return array(); } @@ -61,6 +61,6 @@ public function getOptions(ServiceLocatorInterface $sl, $key) public function getOptionsClass() { - return 'DoctrineDataFixtureModule\Options\Fixture'; + return 'DoctrineDataFixtureModule\Options\Fixture'; } } diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index 3ad8797..066d35b 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -19,4 +19,4 @@ /* @var $loader \Composer\Autoload\ClassLoader */ $loader->add('DoctrineDataFixtureTest\\', __DIR__); -unset($files, $file, $loader); \ No newline at end of file +unset($files, $file, $loader);