8000 Merge branch '3.2' · symfony/symfony@c2a0bcf · GitHub
[go: up one dir, main page]

Skip to content
< 8000 div class="d-none">

Commit c2a0bcf

Browse files
Merge branch '3.2'
* 3.2: [ci] Update travis/appveyor [HttpFoundation] Validate/cast cookie expire time
2 parents 0c5afe4 + fcf8b33 commit c2a0bcf

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ install:
8686
- if [[ ! $skip && $deps ]]; then export SYMFONY_DEPRECATIONS_HELPER=weak; fi
8787
- if [[ ! $skip && $deps ]]; then mv composer.json.phpunit composer.json; fi
8888
- if [[ ! $skip ]]; then composer update; fi
89-
- if [[ ! $skip ]]; then COMPOSER_ROOT_VERSION= ./phpunit install; fi
89+
- if [[ ! $skip ]]; then ./phpunit install; fi
9090
- if [[ ! $skip && ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi
9191

9292
script:
@@ -95,7 +95,7 @@ script:
9595
- if [[ ! $deps && ! $PHP = hhvm* ]]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi
9696
- if [[ ! $deps && $PHP = hhvm* ]]; then $PHPUNIT --exclude-group benchmark,intl-data; fi
9797
- if [[ ! $deps && $PHP = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | xargs -I{} sh -c 'echo "\\nPHP --enable-sigchild enhanced={}" && ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/'; fi
98-
- if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY; fi
99-
- if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi
98+
- if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY' && echo -e "\\e[33mOK\\e[0m {}" || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1))'; fi
99+
- if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --no-progress --ansi --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data && echo -e "\\e[33mOK\\e[0m {}" || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1))'; fi
100100
# Test the PhpUnit bridge using the original phpunit script
101101
- if [[ $deps = low ]]; then (cd src/Symfony/Bridge/PhpUnit && phpenv global 5.3 && php --version && composer update && phpunit); fi

appveyor.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ clone_depth: 1
33
clone_folder: c:\projects\symfony
44

55
cache:
6-
- c:\projects\symfony\composer.phar
6+
- composer.phar
77
- .phpunit -> phpunit
88

99
init:
@@ -46,13 +46,12 @@ install:
4646
- echo curl.cainfo=c:\php\cacert.pem >> php.ini-max
4747
- copy /Y php.ini-max php.ini
4848
- cd c:\projects\symfony
49-
- IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.2.1/composer.phar)
49+
- IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.3.0/composer.phar)
5050
- php composer.phar self-update
5151
- copy /Y .composer\* %APPDATA%\Composer\
5252
- php .github/build-packages.php "HEAD^" src\Symfony\Bridge\PhpUnit
5353
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
5454
- php composer.phar update --no-progress --ansi
55-
- SET COMPOSER_ROOT_VERSION=
5655
- php phpunit install
5756

5857
test_script:

phpunit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env php
22
<?php
33

4+
// Cache-Id: https://github.com/symfony/phpunit-bridge/commit/89cd0aab376105fb34e773e3dff641f68e3f9645
5+
46
if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
57
echo "Unable to find the `simple-phpunit` script in `vendor/symfony/phpunit-bridge/bin/`.\nPlease run `composer update` before running this command.\n";
68
exit(1);

src/Symfony/Component/HttpFoundation/Cookie.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,15 @@ public function __construct($name, $value = null, $expire = 0, $path = '/', $dom
112112
} elseif (!is_numeric($expire)) {
113113
$expire = strtotime($expire);
114114

115-
if (false === $expire || -1 === $expire) {
115+
if (false === $expire) {
116116
throw new \InvalidArgumentException('The cookie expiration time is not valid.');
117117
}
118118
}
119119

120120
$this->name = $name;
121121
$this->value = $value;
122122
$this->domain = $domain;
123-
$this->expire = $expire;
123+
$this->expire = 0 < $expire ? (int) $expire : 0;
124124
$this->path = empty($path) ? '/' : $path;
125125
$this->secure = (bool) $secure;
126126
$this->httpOnly = (bool) $httpOnly;
@@ -147,7 +147,7 @@ public function __toString()
147147
} else {
148148
$str .= $this->isRaw() ? $this->getValue() : urlencode($this->getValue());
149149

150-
if ($this->getExpiresTime() !== 0) {
150+
if (0 !== $this->getExpiresTime()) {
151151
$str .= '; expires='.gmdate('D, d-M-Y H:i:s T', $this->getExpiresTime()).'; max-age='.$this->getMaxAge();
152152
}
153153
}

src/Symfony/Component/HttpFoundation/Tests/CookieTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,14 @@ public function testInstantiationThrowsExceptionIfCookieNameContainsInvalidChara
5252
*/
5353
public function testInvalidExpiration()
5454
{
55-
$cookie = new Cookie('MyCookie', 'foo', 'bar');
55+
new Cookie('MyCookie', 'foo', 'bar');
56+
}
57+
58+
public function testNegativeExpirationIsNotPossible()
59+
{
60+
$cookie = new Cookie('foo', 'bar', -100);
61+
62+
$this->assertSame(0, $cookie->getExpiresTime());
5663
}
5764

5865
public function testGetValue()
@@ -81,6 +88,13 @@ public function testGetExpiresTime()
8188
$this->assertEquals($expire, $cookie->getExpiresTime(), '->getExpiresTime() returns the expire date');
8289
}
8390

91+
public function testGetExpiresTimeIsCastToInt()
92+
{
93+
$cookie = new Cookie('foo', 'bar', 3600.9);
94+
95+
$this->assertSame(3600, $cookie->getExpiresTime(), '->getExpiresTime() returns the expire date as an integer');
96+
}
97+
8498
public function testConstructorWithDateTime()
8599
{
86100
$expire = new \DateTime();

0 commit comments

Comments
 (0)
0