Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Revert "Composer and test update (#3) (#308)"
Browse files Browse the repository at this point in the history
This reverts commit 641ad92.
  • Loading branch information
gilles-g authored Apr 16, 2019
1 parent 641ad92 commit b62a684
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 56 deletions.
48 changes: 27 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,48 @@
language: php

sudo: false

cache:
directories:
- $HOME/.composer/cache/files
- $HOME/.composer/cache

php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3

env:
global:
- MONGO_EXTENSION="mongodb.so"
- COMPOSER_FLAGS=""

matrix:
include:
exclude:
- php: 5.6
env: MONGO_EXTENSION="mongo.so" SYMFONY_VERSION="symfony/lts:^2"
- php: 7.1
env: SYMFONY_VERSION="symfony/lts:^3"
env: SYMFONY_VERSION=4.0.*
- php: 7.0
env: SYMFONY_VERSION=4.0.*
fast_finish: true

services:
- mongodb

env:
- SYMFONY_VERSION=2.8.*
- SYMFONY_VERSION=3.0.*
- SYMFONY_VERSION=3.1.*
- SYMFONY_VERSION=3.2.*
- SYMFONY_VERSION=3.3.*
- SYMFONY_VERSION=4.0.*

before_install:
- echo "extension = $MONGO_EXTENSION" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- echo 'memory_limit = -1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- if [[ "$STABLE" != "" ]]; then composer config minimum-stability $STABLE; fi;

before_script:
- composer config platform.ext-mongo 1.6.16
- if [ "$SYMFONY_VERSION" != "" ]; then travis_wait composer require --no-update $SYMFONY_VERSION; fi;
- travis_wait composer update --prefer-dist --no-interaction $COMPOSER_FLAGS
- if ! [[ $TRAVIS_PHP_VERSION =~ ^5 ]]; then composer require alcaeus/mongo-php-adapter; fi;
- echo 'date.timezone = "Europe/Paris"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- echo memory_limit = -1 >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- if [[ $TRAVIS_PHP_VERSION =~ ^5 ]]; then echo 'extension = "mongo.so"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- if ! [[ $TRAVIS_PHP_VERSION =~ ^5 ]]; then echo 'extension = "mongodb.so"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- composer self-update
- if ! [[ $TRAVIS_PHP_VERSION =~ ^5 ]]; then composer config "platform.ext-mongo" "1.6.16" && composer require alcaeus/mongo-php-adapter; fi;
- composer require symfony/framework-bundle:${SYMFONY_VERSION} --no-update
- composer require symfony/form:${SYMFONY_VERSION} --no-update
- composer update

script:
- composer validate --no-check-lock --strict
- bin/phpunit --coverage-text
- bin/phpunit
18 changes: 6 additions & 12 deletions Tests/Filter/Doctrine/DoctrineQueryBuilderUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Lexik\Bundle\FormFilterBundle\Tests\Filter\Doctrine;

use Doctrine\ORM\QueryBuilder;
use Lexik\Bundle\FormFilterBundle\Filter\FilterOperands;
use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\BooleanFilterType;
use Lexik\Bundle\FormFilterBundle\Filter\QueryBuilderUpdater;
use Lexik\Bundle\FormFilterBundle\Tests\TestCase;
use Lexik\Bundle\FormFilterBundle\Tests\Fixtures\Filter\RangeFilterType;
use Lexik\Bundle\FormFilterBundle\Tests\Fixtures\Filter\ItemCallbackFilterType;
Expand Down Expand Up @@ -34,11 +34,6 @@ public function setUp()
$this->conn = $this->em->getConnection();
}

/**
* @return QueryBuilder
*/
abstract protected function createDoctrineQueryBuilder();

/**
* Get query parameters from the query builder.
*
Expand All @@ -51,7 +46,7 @@ protected function getQueryBuilderParameters($qb)
return $qb->getParameters();
}

if ($qb instanceof QueryBuilder) {
if ($qb instanceof \Doctrine\ORM\QueryBuilder) {
$params = array();

foreach ($qb->getParameters() as $parameter) {
Expand Down Expand Up @@ -115,7 +110,6 @@ protected function createBuildQueryTest($method, array $dqls)
$this->assertEquals(array('p_i_position' => 2, 'p_i_enabled' => 1), $this->getQueryBuilderParameters($doctrineQueryBuilder));

// bind a request to the form - date + pattern selector
$year = \date('Y');
$form = $this->formFactory->create(ItemFilterType::class, null, array(
'with_selector' => true,
));
Expand All @@ -124,12 +118,12 @@ protected function createBuildQueryTest($method, array $dqls)
$form->submit(array(
'name' => array('text' => 'blabla', 'condition_pattern' => FilterOperands::STRING_ENDS),
'position' => array('text' => 2, 'condition_operator' => FilterOperands::OPERATOR_LOWER_THAN_EQUAL),
'createdAt' => array('year' => $year, 'month' => 9, 'day' => 27),
'createdAt' => array('year' => 2013, 'month' => 9, 'day' => 27),
));

$filterQueryBuilder->addFilterConditions($form, $doctrineQueryBuilder);
$this->assertEquals($dqls[5], $doctrineQueryBuilder->{$method}());
$this->assertEquals(array('p_i_position' => 2, 'p_i_createdAt' => new \DateTime("{$year}-09-27")), $this->getQueryBuilderParameters($doctrineQueryBuilder));
$this->assertEquals(array('p_i_position' => 2, 'p_i_createdAt' => new \DateTime('2013-09-27')), $this->getQueryBuilderParameters($doctrineQueryBuilder));

// bind a request to the form - datetime + pattern selector
$form = $this->formFactory->create(ItemFilterType::class, null, array(
Expand All @@ -142,14 +136,14 @@ protected function createBuildQueryTest($method, array $dqls)
'name' => array('text' => 'blabla', 'condition_pattern' => FilterOperands::STRING_ENDS),
'position' => array('text' => 2, 'condition_operator' => FilterOperands::OPERATOR_LOWER_THAN_EQUAL),
'createdAt' => array(
'date' => array('year' => $year, 'month' => 9, 'day' => 27),
'date' => array('year' => 2013, 'month' => 9, 'day' => 27),
'time' => array('hour' => 13, 'minute' => 21),
),
));

$filterQueryBuilder->addFilterConditions($form, $doctrineQueryBuilder);
$this->assertEquals($dqls[6], $doctrineQueryBuilder->{$method}());
$this->assertEquals(array('p_i_position' => 2, 'p_i_createdAt' => new \DateTime("{$year}-09-27 13:21:00")), $this->getQueryBuilderParameters($doctrineQueryBuilder));
$this->assertEquals(array('p_i_position' => 2, 'p_i_createdAt' => new \DateTime('2013-09-27 13:21:00')), $this->getQueryBuilderParameters($doctrineQueryBuilder));
}

protected function createDisabledFieldTest($method, array $dqls)
Expand Down
14 changes: 8 additions & 6 deletions Tests/Filter/Doctrine/MongodbQueryBuilderUpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
use Lexik\Bundle\FormFilterBundle\Tests\Fixtures\Filter\RangeFilterType;
use Lexik\Bundle\FormFilterBundle\Filter\FilterOperands;
use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\BooleanFilterType;
use Lexik\Bundle\FormFilterBundle\Filter\QueryBuilderUpdater;
use Lexik\Bundle\FormFilterBundle\Tests\TestCase;
use Lexik\Bundle\FormFilterBundle\Tests\Fixtures\Filter\ItemFilterType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* Mongodb query builder tests.
Expand Down Expand Up @@ -42,16 +46,14 @@ public function setUp()

public function testBuildQuery()
{
$year = \date('Y');

$bson = array(
'#db.items.find\(({ })?\);#',
'db.items.find({ "$and": [ { "name": "blabla" } ] });',
'db.items.find({ "$and": [ { "name": "blabla" }, { "position": { "$gt": 2 } } ] });',
'db.items.find({ "$and": [ { "name": "blabla" }, { "position": { "$gt": 2 } }, { "enabled": true } ] });',
'db.items.find({ "$and": [ { "name": "blabla" }, { "position": { "$gt": 2 } }, { "enabled": true } ] });',
'#db.items.find\(\{ "\$and": \[ \{ "name": new RegExp\("\.\*blabla\$", "i"\) \}, \{ "position": \{ "\$lte": 2 \} \}, \{ "createdAt": new ISODate\("' . $year . '-09-27T00:00:00\+[0-9:]+"\) \} \] \}\);#',
'#db.items.find\(\{ "\$and": \[ \{ "name": new RegExp\("\.\*blabla\$", "i"\) \}, \{ "position": \{ "\$lte": 2 \} \}, \{ "createdAt": new ISODate\("' . $year . '-09-27T13:21:00\+[0-9:]+"\) \} \] \}\);#',
'#db.items.find\(\{ "\$and": \[ \{ "name": new RegExp\("\.\*blabla\$", "i"\) \}, \{ "position": \{ "\$lte": 2 \} \}, \{ "createdAt": new ISODate\("2013-09-27T00:00:00\+[0-9:]+"\) \} \] \}\);#',
'#db.items.find\(\{ "\$and": \[ \{ "name": new RegExp\("\.\*blabla\$", "i"\) \}, \{ "position": \{ "\$lte": 2 \} \}, \{ "createdAt": new ISODate\("2013-09-27T13:21:00\+[0-9:]+"\) \} \] \}\);#',
);

$form = $this->formFactory->create(ItemFilterType::class);
Expand Down Expand Up @@ -108,7 +110,7 @@ public function testBuildQuery()
$form->submit(array(
'name' => array('text' => 'blabla', 'condition_pattern' => FilterOperands::STRING_ENDS),
'position' => array('text' => 2, 'condition_operator' => FilterOperands::OPERATOR_LOWER_THAN_EQUAL),
'createdAt' => array('year' => $year, 'month' => 9, 'day' => 27),
'createdAt' => array('year' => 2013, 'month' => 9, 'day' => 27),
));

$filterQueryBuilder->addFilterConditions($form, $mongoQB);
Expand All @@ -125,7 +127,7 @@ public function testBuildQuery()
'name' => array('text' => 'blabla', 'condition_pattern' => FilterOperands::STRING_ENDS),
'position' => array('text' => 2, 'condition_operator' => FilterOperands::OPERATOR_LOWER_THAN_EQUAL),
'createdAt' => array(
'date' => array('year' => $year, 'month' => 9, 'day' => 27),
'date' => array('year' => 2013, 'month' => 9, 'day' => 27),
'time' => array('hour' => 13, 'minute' => 21),
),
));
Expand Down
4 changes: 2 additions & 2 deletions Tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
abstract class TestCase extends \PHPUnit\Framework\TestCase
{
/**
* @var FormFactory
* @var Symfony\Component\Form\FormFactory
*/
protected $formFactory;

Expand All @@ -30,7 +30,7 @@ public function setUp()
/**
* Create a form factory instance.
*
* @return FormFactory
* @return \Symfony\Component\Form\FormFactory
*/
public function getFormFactory()
{
Expand Down
14 changes: 5 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,23 @@
],
"require": {
"php": ">=5.5.9",
"doctrine/mongodb-odm-bundle": "^3.0",
"doctrine/orm": "^2.4.8",
"symfony/framework-bundle": "~2.8|~3.0|^4.0",
"symfony/form": "~2.8|~3.0|^4.0"
"symfony/form": "~2.8|~3.0|^4.0",
"doctrine/orm": "^2.4.8"
},
"require-dev": {
"phpunit/phpunit": "~5.0|^7.5"
"doctrine/mongodb-odm-bundle": "~3.0",
"phpunit/phpunit": "^5.7|~6.0"
},
"autoload": {
"psr-4": { "Lexik\\Bundle\\FormFilterBundle\\": "" }
},
"config": {
"bin-dir": "bin",
"sort-packages": true
"bin-dir": "bin"
},
"extra": {
"branch-alias": {
"dev-master": "5.x.x-dev"
}
},
"suggest": {
"alcaeus/mongo-php-adapter": "Install this package if using the PHP 7 MongoDB Driver"
}
}
10 changes: 4 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
backupGlobals="false"
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="Tests/bootstrap.php"
>
<testsuites>
Expand All @@ -19,7 +17,7 @@
</testsuite>
</testsuites>
<filter>

<whitelist>
<directory>./</directory>
<exclude>
Expand All @@ -28,7 +26,7 @@
</exclude>
</whitelist>
</filter>

<php>
<server name="ROOT_DIR" value="../../../../.." />
</php>
Expand Down

0 comments on commit b62a684

Please sign in to comment.