Skip to content

Commit

Permalink
Merge pull request #22 from Hounddog/travis
Browse files Browse the repository at this point in the history
Travis
  • Loading branch information
Ocramius committed Dec 12, 2013
2 parents a3d8a30 + 29c5ab1 commit 4f09fd9
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/build
/vendor
composer.lock
composer.phar
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
require_once __DIR__ . '/src/DoctrineDataFixtureModule/Module.php';
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
29 changes: 29 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<!-- works fine with PHPUnit-3.6.10 -->
<phpunit
bootstrap="./tests/Bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
verbose="true"
stopOnFailure="false"
processIsolation="false"
backupGlobals="false"
syntaxCheck="true"
>
<testsuite name="DoctrineDataFixture Module Tests">
<directory>./tests/DoctrineDataFixtureTest</directory>
</testsuite>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<logging>
<log
type="coverage-clover"
target="./clover.xml"
/>
</logging>
</phpunit>
25 changes: 13 additions & 12 deletions src/DoctrineDataFixtureModule/Command/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -53,7 +53,8 @@ protected function configure()

$this->setName('data-fixture:import')
->setDescription('Import Data Fixtures')
->setHelp(<<<EOT
->setHelp(
<<<EOT
The import command Imports data-fixtures
EOT
)
Expand All @@ -66,19 +67,19 @@ public function execute(InputInterface $input, OutputInterface $output)
$loader = new Loader();
$purger = new ORMPurger();

if($input->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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/DoctrineDataFixtureModule/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions src/DoctrineDataFixtureModule/Service/FixtureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -61,6 +61,6 @@ public function getOptions(ServiceLocatorInterface $sl, $key)

public function getOptionsClass()
{
return 'DoctrineDataFixtureModule\Options\Fixture';
return 'DoctrineDataFixtureModule\Options\Fixture';
}
}
22 changes: 22 additions & 0 deletions tests/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

ini_set('error_reporting', E_ALL | E_STRICT);

$files = array(__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php');

foreach ($files as $file) {
if (file_exists($file)) {
$loader = require $file;

break;
}
}

if (! isset($loader)) {
throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?');
}

/* @var $loader \Composer\Autoload\ClassLoader */
$loader->add('DoctrineDataFixtureTest\\', __DIR__);

unset($files, $file, $loader);

0 comments on commit 4f09fd9

Please sign in to comment.