Skip to content

Commit

Permalink
use composer to load test lib, and run test with SF 2.3 and 2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Girard committed Feb 10, 2014
1 parent 0f0184f commit a5f982c
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 123 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ phpunit.xml
.project
.buildpath
.settings
vendor
vendor
composer.lock
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ php:
- 5.3

env:
- SYMFONY_VERSION=v2.2
- SYMFONY_VERSION=v2.3
- SYMFONY_VERSION=2.3.*
- SYMFONY_VERSION=2.4.*

before_script:
- php Tests/vendors.php
before_script:
- composer require symfony/framework-bundle:${SYMFONY_VERSION} --no-update
- composer require symfony/validator:${SYMFONY_VERSION} --no-update
- composer require symfony/doctrine-bridge:${SYMFONY_VERSION} --no-update
- composer require doctrine/orm:2.4.* --no-update
- composer require doctrine/data-fixtures:1.0.* --no-update
- composer update --dev

script: phpunit
2 changes: 1 addition & 1 deletion Entity/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;

use Lexik\Bundle\MailerBundle\Model\Header;
use Symfony\Bridge\Doctrine\Validator\Constraints as DoctrineAssert;
use Symfony\Component\Validator\Constraints as Assert;

use Lexik\Bundle\MailerBundle\Model\Header;
use Lexik\Bundle\MailerBundle\Model\EmailInterface;
use Lexik\Bundle\MailerBundle\Exception\NoTranslationException;

Expand Down
13 changes: 7 additions & 6 deletions Tests/Unit/BaseUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ protected function loadFixtures(EntityManager $em)
$purger = new ORMPurger();
$executor = new ORMExecutor($em, $purger);

$fixtures = new TestData();
$executor->execute(array($fixtures), false);
$executor->execute(array(new TestData()), false);
}

/**
Expand All @@ -53,10 +52,9 @@ protected function getMockSqliteEntityManager()
$cache = new \Doctrine\Common\Cache\ArrayCache();

// annotation driver
$reader = new AnnotationReader($cache);
$annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array(
$annotationDriver = \Doctrine\ORM\Configuration::newDefaultAnnotationDriver(array(
__DIR__.'/../../Entity',
));
), false);

// configuration mock
$config = $this->getMock('Doctrine\ORM\Configuration');
Expand All @@ -83,7 +81,10 @@ protected function getMockSqliteEntityManager()
->will($this->returnValue('Doctrine\ORM\Mapping\ClassMetadataFactory'));
$config->expects($this->any())
->method('getDefaultRepositoryClassName')
->will($this->returnValue('Doctrine\\ORM\\EntityRepository'));
->will($this->returnValue('Doctrine\ORM\EntityRepository'));
$config->expects($this->any())
->method('getRepositoryFactory')
->will($this->returnValue(new \Doctrine\ORM\Repository\DefaultRepositoryFactory()));
$config->expects($this->any())
->method('getQuoteStrategy')
->will($this->returnValue(new DefaultQuoteStrategy()));
Expand Down
22 changes: 22 additions & 0 deletions Tests/autoload.php.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use Doctrine\Common\Annotations\AnnotationRegistry;

if (!$loader = include __DIR__.'/../vendor/autoload.php') {
$nl = PHP_SAPI === 'cli' ? PHP_EOL : '<br />';
echo "$nl$nl";
die('You must set up the project dependencies.'.$nl.
'Run the following commands in '.dirname(__DIR__).':'.$nl.$nl.
'curl -s http://getcomposer.org/installer | php'.$nl.
'php composer.phar install'.$nl);
}

AnnotationRegistry::registerAutoloadNamespace(
'Symfony\Component\Validator\Constraints',
__DIR__.'/../vendor/symfony/validator'
);

AnnotationRegistry::registerAutoloadNamespace(
'Symfony\Bridge\Doctrine\Validator\Constraints',
__DIR__.'/../vendor/symfony/doctrine-bridge'
);
4 changes: 2 additions & 2 deletions Tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

if (file_exists($file = __DIR__.'/../autoload.php')) {
if (file_exists($file = __DIR__.'/autoload.php')) {
require_once $file;
} elseif (file_exists($file = __DIR__.'/../autoload.php.dist')) {
} elseif (file_exists($file = __DIR__.'/autoload.php.dist')) {
require_once $file;
}
64 changes: 0 additions & 64 deletions Tests/vendors.php

This file was deleted.

45 changes: 0 additions & 45 deletions autoload.php.dist

This file was deleted.

0 comments on commit a5f982c

Please sign in to comment.