Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed hard dependencies on doctrine odm to run the tests #2703

Merged
merged 7 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, tests are green so you tell me 😄

Copy link
Contributor

@teohhanhui teohhanhui Apr 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Toflar But the config wouldn't get applied correctly. So the APP_ENV should be reverted to test_mongodb. 😄

Copy link
Contributor

@teohhanhui teohhanhui Apr 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or better, rename the config files, since we do the same for elasticsearch.

Copy link
Contributor

@teohhanhui teohhanhui Apr 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Toflar I think we should rename the config files instead, for consistency.

Copy link
Contributor

@teohhanhui teohhanhui Apr 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alanpoulain Can you advise why there is config_common.yml (imported from config_orm.yml and config_services_mongodb.yml), config_orm.yml (imported from config_test.yml) and config_mongodb.yml (I don't see where this is imported uhh, there is already a mongodb environment previously)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note https://github.com/api-platform/core/blob/v2.4.2/tests/Fixtures/app/AppKernel.php#L97

It's very confusing if we name config files the same way when it's not environment-specific.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay @Toflar, so my suggestion is that we should merge mongodb and test_mongodb environments into one mongodb environment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's what I was trying 😄 So I revert the latest commit again?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes... But we need to make sure the relevant parts of the old test_mongodb environment are merged in, e.g.:

tests/Fixtures/app/config/config_test_mongodb.yml
tests/Fixtures/app/config/config_services_mongodb.yml
tests/Fixtures/app/config/routing_test_mongodb.yml

And the old files removed.

<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
teohhanhui marked this conversation as resolved.
Show resolved Hide resolved
*
* @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