Skip to content

Commit

Permalink
Fix the tests (#1621)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhemN authored Dec 2, 2016
1 parent 62a2813 commit d358b2e
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.phpunit
phpunit.xml
vendor
composer.lock
Expand Down
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ php:
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm

sudo: false

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

branches:
Expand All @@ -25,16 +27,12 @@ matrix:
- php: 7.0
env: SYMFONY_VERSION='2.8.*'
- php: 7.0
env: SYMFONY_VERSION='3.1.*'
env: SYMFONY_VERSION='3.2.*'

before_install:
- if [[ "$TRAVIS_PHP_VERSION" != "5.6" && "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then phpenv config-rm xdebug.ini; fi
- composer self-update
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then phpenv config-rm xdebug.ini; fi
- if [ "$SYMFONY_VERSION" != "" ]; then composer require --dev --no-update symfony/symfony=$SYMFONY_VERSION; fi

install: composer update $COMPOSER_FLAGS --prefer-dist

script: if [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then phpunit --coverage-clover=coverage.clover; else phpunit; fi

after_script:
- if [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
script: ./phpunit
1 change: 1 addition & 0 deletions Tests/Functional/app/ExceptionListener/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ framework:
enabled: true
templating:
engines: ['twig']
assets: false

fos_rest:
exception: ~
Expand Down
1 change: 1 addition & 0 deletions Tests/Functional/app/Serializer/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ framework:
enabled: true
templating:
engines: ['twig']
assets: false

fos_rest:
view:
Expand Down
1 change: 1 addition & 0 deletions Tests/Functional/app/Version/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ framework:
enabled: true
templating:
engines: ['twig']
assets: false

fos_rest:
format_listener:
Expand Down
1 change: 1 addition & 0 deletions Tests/Functional/app/config/framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ framework:
default_locale: en
templating:
engines: ['php']
assets: false
22 changes: 13 additions & 9 deletions Tests/View/ViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,25 @@ public function testSetFormat()
$this->assertEquals($format, $view->getFormat());
}

/**
* @dataProvider viewWithHeadersProvider
*/
public function testSetHeaders()
{
$view = new View();
$headers = ['foo' => 'bar'];
$expected = ['foo' => ['bar'], 'cache-control' => ['no-cache']];
$view->setHeaders($headers);
$this->assertEquals($expected, $view->getHeaders());
$view->setHeaders(['foo' => 'bar']);

$headers = $view->getResponse()->headers;
$this->assertTrue($headers->has('foo'));
$this->assertEquals('bar', $headers->get('foo'));
}

public function testHeadersInConstructorAreAssignedToResponseObject()
public function viewWithHeadersProvider()
{
$headers = ['foo' => 'bar'];
$expected = ['foo' => ['bar'], 'cache-control' => ['no-cache']];
$view = new View(null, null, $headers);
$this->assertEquals($expected, $view->getHeaders());
return [
[(new View())->setHeaders(['foo' => 'bar'])],
[new View(null, null, ['foo' => 'bar'])],
];
}

public function testSetStatusCode()
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

"require-dev": {
"sensio/framework-extra-bundle": "^3.0.13",
"symfony/phpunit-bridge": "~2.7|^3.0",
"symfony/phpunit-bridge": "^3.2",
"symfony/form": "^2.7|^3.0",
"symfony/validator": "^2.7|^3.0",
"symfony/serializer": "^2.7.11|^3.0.4",
Expand Down
8 changes: 8 additions & 0 deletions phpunit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env php
<?php
if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";
exit(1);
}
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
require __DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';

0 comments on commit d358b2e

Please sign in to comment.