Skip to content

Commit

Permalink
Merge pull request #2703 from Toflar/optional-mongodb-tests
Browse files Browse the repository at this point in the history
Removed hard dependencies on doctrine odm to run the tests
  • Loading branch information
teohhanhui authored May 3, 2019
2 parents f254e14 + 8aaad92 commit 09e8006
Show file tree
Hide file tree
Showing 31 changed files with 316 additions and 174 deletions.
5 changes: 5 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ reusable-steps:
run:
name: Disable Xdebug PHP extension
command: sudo rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
- &install-doctrine-mongodb-odm
run:
name: Install Doctrine MongoDB ODM
command: composer require --prefer-dist --no-progress --no-suggest --no-update --ansi doctrine/mongodb-odm:^2.0.0@beta doctrine/mongodb-odm-bundle:^4.0.0@beta
- &install-php-extensions
run:
name: Install PHP extensions
Expand Down Expand Up @@ -134,6 +138,7 @@ jobs:
- *disable-php-memory-limit
- *install-php-extensions
- *update-composer
- *install-doctrine-mongodb-odm
- *update-project-dependencies
- *save-composer-cache-by-revision
- *save-composer-cache-by-branch
Expand Down
16 changes: 7 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ cache:
jobs:
include:
- php: '7.1'
env: NO_UNIT_TESTS=true
before_install:
- composer remove --dev ext-mongodb doctrine/mongodb-odm doctrine/mongodb-odm-bundle
- sed -i '33,39d' tests/Fixtures/app/config/config_common.yml
- php: '7.2'
- php: '7.3'
- php: '7.3'
Expand Down Expand Up @@ -46,12 +42,15 @@ before_install:
- if [[ $APP_ENV = 'elasticsearch' ]]; then
curl -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.0.deb && sudo dpkg -i --force-confnew elasticsearch-6.5.0.deb && sudo service elasticsearch restart;
fi
- phpenv config-rm xdebug.ini || echo "xdebug not available"
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- echo "extension=mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- if [[ $APP_ENV = 'mongodb' ]]; then
echo "extension=mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/mongodb.ini;
fi
- phpenv config-rm xdebug.ini || echo "xdebug not available"
- export PATH="$PATH:$HOME/.composer/vendor/bin"

install:
- if [[ $APP_ENV = 'mongodb' ]]; then composer require --prefer-dist --no-progress --no-suggest --no-update --ansi doctrine/mongodb-odm:^2.0.0@beta doctrine/mongodb-odm-bundle:^4.0.0@beta; fi
- if [[ $deps = 'low' ]]; then
composer update --prefer-dist --no-progress --no-suggest --prefer-stable --prefer-lowest --ansi;
else
Expand All @@ -60,11 +59,10 @@ install:

script:
- tests/Fixtures/app/console cache:clear
- if [[ $NO_UNIT_TESTS != true ]]; then
vendor/bin/phpunit;
fi
- if [[ $APP_ENV = 'mongodb' ]]; then
vendor/bin/phpunit -c phpunit.mongo.xml;
else
vendor/bin/phpunit;
fi
- tests/Fixtures/app/console cache:clear
- if [[ $APP_ENV = 'postgres' ]]; then
Expand Down
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
"doctrine/annotations": "^1.2",
"doctrine/doctrine-bundle": "^1.8",
"doctrine/doctrine-cache-bundle": "^1.3.5",
"doctrine/mongodb-odm": "^2.0.0@beta",
"doctrine/mongodb-odm-bundle": "^4.0.0@beta",
"doctrine/orm": "^2.6.3",
"elasticsearch/elasticsearch": "^6.0",
"friendsofsymfony/user-bundle": "^2.2@dev",
Expand Down
2 changes: 1 addition & 1 deletion phpunit.mongo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak_vendors" />
<server name="KERNEL_DIR" value="tests/Fixtures/app/" />
<server name="KERNEL_CLASS" value="AppKernel" />
<server name="APP_ENV" value="test_mongodb" />
<server name="APP_ENV" value="mongodb" />
<server name="LEGACY" value="0" />
</php>

Expand Down
6 changes: 6 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>

<groups>
<exclude>
<group>mongodb</group>
</exclude>
</groups>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function testSingleIdentifier()

/**
* @group legacy
* @group mongodb
*/
public function testSingleDocumentIdentifier()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
use PHPUnit\Framework\TestCase;

/**
* @group mongodb
*
* @author Alan Poulain <contact@alanpoulain.eu>
*/
class CollectionDataProviderTest extends TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
use Psr\Container\ContainerInterface;

/**
* @group mongodb
*
* @author Alan Poulain <contact@alanpoulain.eu>
*/
class FilterExtensionTest extends TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
use PHPUnit\Framework\TestCase;

/**
* @group mongodb
*
* @author Alan Poulain <contact@alanpoulain.eu>
*/
class OrderExtensionTest extends TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
use PHPUnit\Framework\TestCase;

/**
* @group mongodb
*
* @author Alan Poulain <contact@alanpoulain.eu>
*/
class PaginationExtensionTest extends TestCase
Expand Down
2 changes: 2 additions & 0 deletions tests/Bridge/Doctrine/MongoDbOdm/Filter/BooleanFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use ApiPlatform\Core\Tests\Bridge\Doctrine\Common\Filter\BooleanFilterTestTrait;

/**
* @group mongodb
*
* @author Alan Poulain <contact@alanpoulain.eu>
*/
class BooleanFilterTest extends DoctrineMongoDbOdmFilterTestCase
Expand Down
2 changes: 2 additions & 0 deletions tests/Bridge/Doctrine/MongoDbOdm/Filter/DateFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use MongoDB\BSON\UTCDateTime;

/**
* @group mongodb
*
* @author Alan Poulain <contact@alanpoulain.eu>
*/
class DateFilterTest extends DoctrineMongoDbOdmFilterTestCase
Expand Down
2 changes: 2 additions & 0 deletions tests/Bridge/Doctrine/MongoDbOdm/Filter/ExistsFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use ApiPlatform\Core\Tests\Bridge\Doctrine\Common\Filter\ExistsFilterTestTrait;

/**
* @group mongodb
*
* @author Alan Poulain <contact@alanpoulain.eu>
*/
class ExistsFilterTest extends DoctrineMongoDbOdmFilterTestCase
Expand Down
2 changes: 2 additions & 0 deletions tests/Bridge/Doctrine/MongoDbOdm/Filter/NumericFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use ApiPlatform\Core\Tests\Bridge\Doctrine\Common\Filter\NumericFilterTestTrait;

/**
* @group mongodb
*
* @author Alan Poulain <contact@alanpoulain.eu>
*/
class NumericFilterTest extends DoctrineMongoDbOdmFilterTestCase
Expand Down
2 changes: 2 additions & 0 deletions tests/Bridge/Doctrine/MongoDbOdm/Filter/OrderFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use Doctrine\Common\Persistence\ManagerRegistry;

/**
* @group mongodb
*
* @author Alan Poulain <contact@alanpoulain.eu>
*/
class OrderFilterTest extends DoctrineMongoDbOdmFilterTestCase
Expand Down
2 changes: 2 additions & 0 deletions tests/Bridge/Doctrine/MongoDbOdm/Filter/RangeFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use ApiPlatform\Core\Tests\Bridge\Doctrine\Common\Filter\RangeFilterTestTrait;

/**
* @group mongodb
*
* @author Alan Poulain <contact@alanpoulain.eu>
*/
class RangeFilterTest extends DoctrineMongoDbOdmFilterTestCase
Expand Down
2 changes: 2 additions & 0 deletions tests/Bridge/Doctrine/MongoDbOdm/Filter/SearchFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
use Prophecy\Argument;

/**
* @group mongodb
*
* @author Alan Poulain <contact@alanpoulain.eu>
*/
class SearchFilterTest extends DoctrineMongoDbOdmFilterTestCase
Expand Down
2 changes: 2 additions & 0 deletions tests/Bridge/Doctrine/MongoDbOdm/ItemDataProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
use PHPUnit\Framework\TestCase;

/**
* @group mongodb
*
* @author Alan Poulain <contact@alanpoulain.eu>
*/
class ItemDataProviderTest extends TestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
use PHPUnit\Framework\TestCase;

/**
* @group mongodb
*
* @author Alan Poulain <contact@alanpoulain.eu>
*/
class DoctrineMongoDbOdmPropertyMetadataFactoryTest extends TestCase
Expand Down
3 changes: 3 additions & 0 deletions tests/Bridge/Doctrine/MongoDbOdm/PaginatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
use Doctrine\ODM\MongoDB\UnitOfWork;
use PHPUnit\Framework\TestCase;

/**
* @group mongodb
*/
class PaginatorTest extends TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
use Symfony\Component\PropertyInfo\Type;

/**
* @group mongodb
*
* @author Kévin Dunglas <dunglas@gmail.com>
* @author Alan Poulain <contact@alanpoulain.eu>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
use Prophecy\Argument;

/**
* @group mongodb
*
* @author Alan Poulain <contact@alanpoulain.eu>
*/
class SubresourceDataProviderTest extends TestCase
Expand Down
Loading

0 comments on commit 09e8006

Please sign in to comment.