Skip to content

Commit d358b2e

Browse files
authored
Fix the tests (#1621)
1 parent 62a2813 commit d358b2e

File tree

9 files changed

+32
-17
lines changed

9 files changed

+32
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.phpunit
12
phpunit.xml
23
vendor
34
composer.lock

.travis.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ php:
44
- 5.5
55
- 5.6
66
- 7.0
7+
- 7.1
78
- hhvm
89

910
sudo: false
1011

1112
cache:
1213
directories:
14+
- .phpunit
1315
- $HOME/.composer/cache/files
1416

1517
branches:
@@ -25,16 +27,12 @@ matrix:
2527
- php: 7.0
2628
env: SYMFONY_VERSION='2.8.*'
2729
- php: 7.0
28-
env: SYMFONY_VERSION='3.1.*'
30+
env: SYMFONY_VERSION='3.2.*'
2931

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

3536
install: composer update $COMPOSER_FLAGS --prefer-dist
3637

37-
script: if [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then phpunit --coverage-clover=coverage.clover; else phpunit; fi
38-
39-
after_script:
40-
- 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
38+
script: ./phpunit

Tests/Functional/app/ExceptionListener/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ framework:
66
enabled: true
77
templating:
88
engines: ['twig']
9+
assets: false
910

1011
fos_rest:
1112
exception: ~

Tests/Functional/app/Serializer/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ framework:
77
enabled: true
88
templating:
99
engines: ['twig']
10+
assets: false
1011

1112
fos_rest:
1213
view:

Tests/Functional/app/Version/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ framework:
66
enabled: true
77
templating:
88
engines: ['twig']
9+
assets: false
910

1011
fos_rest:
1112
format_listener:

Tests/Functional/app/config/framework.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ framework:
99
default_locale: en
1010
templating:
1111
engines: ['php']
12+
assets: false

Tests/View/ViewTest.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,25 @@ public function testSetFormat()
126126
$this->assertEquals($format, $view->getFormat());
127127
}
128128

129+
/**
130+
* @dataProvider viewWithHeadersProvider
131+
*/
129132
public function testSetHeaders()
130133
{
131134
$view = new View();
132-
$headers = ['foo' => 'bar'];
133-
$expected = ['foo' => ['bar'], 'cache-control' => ['no-cache']];
134-
$view->setHeaders($headers);
135-
$this->assertEquals($expected, $view->getHeaders());
135+
$view->setHeaders(['foo' => 'bar']);
136+
137+
$headers = $view->getResponse()->headers;
138+
$this->assertTrue($headers->has('foo'));
139+
$this->assertEquals('bar', $headers->get('foo'));
136140
}
137141

138-
public function testHeadersInConstructorAreAssignedToResponseObject()
142+
public function viewWithHeadersProvider()
139143
{
140-
$headers = ['foo' => 'bar'];
141-
$expected = ['foo' => ['bar'], 'cache-control' => ['no-cache']];
142-
$view = new View(null, null, $headers);
143-
$this->assertEquals($expected, $view->getHeaders());
144+
return [
145+
[(new View())->setHeaders(['foo' => 'bar'])],
146+
[new View(null, null, ['foo' => 'bar'])],
147+
];
144148
}
145149

146150
public function testSetStatusCode()

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
"require-dev": {
4343
"sensio/framework-extra-bundle": "^3.0.13",
44-
"symfony/phpunit-bridge": "~2.7|^3.0",
44+
"symfony/phpunit-bridge": "^3.2",
4545
"symfony/form": "^2.7|^3.0",
4646
"symfony/validator": "^2.7|^3.0",
4747
"symfony/serializer": "^2.7.11|^3.0.4",

phpunit

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env php
2+
<?php
3+
if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
4+
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";
5+
exit(1);
6+
}
7+
putenv('SYMFONY_PHPUNIT_DIR='.__DIR__.'/.phpunit');
8+
require __DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit';

0 commit comments

Comments
 (0)