Skip to content

Commit

Permalink
Fix tests for Symfony2 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Nov 14, 2013
1 parent a2d8629 commit e59ae1e
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ php:
- 5.5

env:
- SYMFONY_VERSION=~2.1.0
- SYMFONY_VERSION=~2.2.0
- SYMFONY_VERSION=~2.3.0
- SYMFONY_VERSION=2.1.*
- SYMFONY_VERSION=2.2.*
- SYMFONY_VERSION=2.3.*
- SYMFONY_VERSION=dev-master

matrix:
Expand All @@ -18,6 +18,8 @@ matrix:
before_script:
- composer self-update
- composer require symfony/framework-bundle:${SYMFONY_VERSION} --no-update
- composer require symfony/twig-bundle:${SYMFONY_VERSION} --no-update
- composer require symfony/validator:${SYMFONY_VERSION} --no-update
- composer update

script: phpunit --coverage-text
2 changes: 1 addition & 1 deletion Parser/ValidationParserLegacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function parse(array $input)
$constraints = $propdata->getConstraints();

foreach ($constraints as $constraint) {
$vparams = $this->parseConstraint($constraint, $vparams);
$vparams = $this->parseConstraint($constraint, $vparams, $className);
}
}

Expand Down
8 changes: 7 additions & 1 deletion Tests/Parser/ValidationParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

use Nelmio\ApiDocBundle\Tests\WebTestCase;
use Nelmio\ApiDocBundle\Parser\ValidationParser;
use Nelmio\ApiDocBundle\Parser\ValidationParserLegacy;
use Symfony\Component\HttpKernel\Kernel;

class ValidationParserTest extends WebTestCase
{
Expand All @@ -13,7 +15,11 @@ public function setUp()
$container = $this->getContainer();
$factory = $container->get('validator.mapping.class_metadata_factory');

$this->parser = new ValidationParser($factory);
if (version_compare(Kernel::VERSION, '2.2.0', '<')) {
$this->parser = new ValidationParserLegacy($factory);
} else {
$this->parser = new ValidationParser($factory);
}
}

/**
Expand Down
17 changes: 11 additions & 6 deletions Tests/WebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@

abstract class WebTestCase extends BaseWebTestCase
{
protected function setUp()
{
$this->deleteTmpDir();

parent::setUp();

if (version_compare(Kernel::VERSION, '2.2.0', '<')) {
$this->markTestSkipped('Does not work with Symfony2 2.1 due to a "host" parameter in the `routing.yml` file');
}
}

protected function deleteTmpDir()
{
if (!file_exists($dir = sys_get_temp_dir().'/'.Kernel::VERSION)) {
Expand Down Expand Up @@ -63,12 +74,6 @@ protected static function createKernel(array $options = array())
);
}

public function setUp()
{
$this->deleteTmpDir();
parent::setUp();
}

public function tearDown()
{
parent::tearDown();
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
}
],
"require": {
"symfony/framework-bundle": "~2.1",
"symfony/twig-bundle": "~2.1",
"symfony/framework-bundle": "2.1.*",
"symfony/twig-bundle": "2.1.*",
"symfony/console": "~2.1",
"dflydev/markdown": "1.0.*"
"dflydev/markdown": "1.0.*",
"symfony/validator": "2.1.0"
},
"conflict": {
"jms/serializer": "<0.12",
Expand Down

0 comments on commit e59ae1e

Please sign in to comment.