Skip to content

Commit b3541bc

Browse files
committed
fix conflicts
2 parents f1e11e4 + 85c0801 commit b3541bc

7 files changed

Lines changed: 79 additions & 8 deletions

File tree

CHANGELOG-5.8.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
# Release Notes for 5.8.x
22

3-
## [Unreleased](https://github.com/laravel/framework/compare/v5.8.22...5.8)
3+
## [Unreleased](https://github.com/laravel/framework/compare/v5.8.23...5.8)
44

5+
### Added
6+
- Added possibility to assert that the session contains a given piece of data using a closure in `TestResponse::assertSessionHas()` ([#28837](https://github.com/laravel/framework/pull/28837))
7+
- Added `TestResponse::assertUnauthorized()` ([#28851](https://github.com/laravel/framework/pull/28851))
8+
9+
10+
## [v5.8.23 (2019-06-14)](https://github.com/laravel/framework/compare/v5.8.21...v5.8.23)
11+
12+
### Fixed
13+
- Fixed strict comparison in redis configuration Parsing. ([#28830](https://github.com/laravel/framework/pull/28830))
14+
15+
### Changed
16+
- Improved support for arrays on `TestResponse::assertJsonValidationErrors()` ([2970dab](https://github.com/laravel/framework/commit/2970dab3944e3b37578fa193503aae4217c62e59))
517

618

719
## [v5.8.22 (2019-06-12)](https://github.com/laravel/framework/compare/v5.8.21...v5.8.22)

src/Illuminate/Database/Eloquent/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Collection extends BaseCollection implements QueueableCollection
1717
*
1818
* @param mixed $key
1919
* @param mixed $default
20-
* @return \Illuminate\Database\Eloquent\Model|static
20+
* @return \Illuminate\Database\Eloquent\Model|static|null
2121
*/
2222
public function find($key, $default = null)
2323
{

src/Illuminate/Foundation/Console/ServeCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ protected function host()
8686
*/
8787
protected function port()
8888
{
89-
return $this->input->getOption('port') + $this->portOffset;
89+
$port = $this->input->getOption('port') ?: 8000;
90+
91+
return $port + $this->portOffset;
9092
}
9193

9294
/**
@@ -96,7 +98,8 @@ protected function port()
9698
*/
9799
protected function canTryAnotherPort()
98100
{
99-
return $this->input->getOption('tries') > $this->portOffset;
101+
return is_null($this->input->getOption('port')) &&
102+
($this->input->getOption('tries') > $this->portOffset);
100103
}
101104

102105
/**
@@ -109,7 +112,7 @@ protected function getOptions()
109112
return [
110113
['host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on', '127.0.0.1'],
111114

112-
['port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on', 8000],
115+
['port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on', $_ENV['SERVER_PORT'] ?? null],
113116

114117
['tries', null, InputOption::VALUE_OPTIONAL, 'The max number of ports to attempt to serve from', 10],
115118
];

src/Illuminate/Foundation/Testing/TestResponse.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,23 @@ public function assertForbidden()
118118
return $this;
119119
}
120120

121+
/**
122+
* Assert that the response has an unauthorized status code.
123+
*
124+
* @return $this
125+
*/
126+
public function assertUnauthorized()
127+
{
128+
$actual = $this->getStatusCode();
129+
130+
PHPUnit::assertTrue(
131+
401 === $actual,
132+
'Response status code ['.$actual.'] is not an unauthorized status code.'
133+
);
134+
135+
return $this;
136+
}
137+
121138
/**
122139
* Assert that the response has the given status code.
123140
*
@@ -863,6 +880,8 @@ public function assertSessionHas($key, $value = null)
863880
$this->session()->has($key),
864881
"Session is missing expected key [{$key}]."
865882
);
883+
} elseif ($value instanceof Closure) {
884+
PHPUnit::assertTrue($value($this->session()->get($key)));
866885
} else {
867886
PHPUnit::assertEquals($value, $this->session()->get($key));
868887
}

src/Illuminate/Redis/RedisManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ protected function parseConnectionConfiguration($config)
170170
$parsed = (new ConfigurationUrlParser)->parseConfiguration($config);
171171

172172
return array_filter($parsed, function ($key) {
173-
return ! in_array($key, ['driver', 'username']);
173+
return ! in_array($key, ['driver', 'username'], true);
174174
}, ARRAY_FILTER_USE_KEY);
175175
}
176176

src/Illuminate/Support/helpers.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,12 @@ function preg_replace_array($pattern, array $replacements, $subject)
376376
* @param int $times
377377
* @param callable $callback
378378
* @param int $sleep
379+
* @param callable $when
379380
* @return mixed
380381
*
381382
* @throws \Exception
382383
*/
383-
function retry($times, callable $callback, $sleep = 0)
384+
function retry($times, callable $callback, $sleep = 0, $when = null)
384385
{
385386
$attempts = 0;
386387
$times--;
@@ -391,7 +392,7 @@ function retry($times, callable $callback, $sleep = 0)
391392
try {
392393
return $callback($attempts);
393394
} catch (Exception $e) {
394-
if (! $times) {
395+
if (! $times || ($when && ! $when($e))) {
395396
throw $e;
396397
}
397398

tests/Support/SupportHelpersTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,42 @@ public function testRetry()
495495
$this->assertTrue(microtime(true) - $startTime >= 0.1);
496496
}
497497

498+
public function testRetryWithPassingWhenCallback()
499+
{
500+
$startTime = microtime(true);
501+
502+
$attempts = retry(2, function ($attempts) {
503+
if ($attempts > 1) {
504+
return $attempts;
505+
}
506+
507+
throw new RuntimeException;
508+
}, 100, function ($ex) {
509+
return true;
510+
});
511+
512+
// Make sure we made two attempts
513+
$this->assertEquals(2, $attempts);
514+
515+
// Make sure we waited 100ms for the first attempt
516+
$this->assertTrue(microtime(true) - $startTime >= 0.1);
517+
}
518+
519+
public function testRetryWithFailingWhenCallback()
520+
{
521+
$this->expectException(RuntimeException::class);
522+
523+
$attempts = retry(2, function ($attempts) {
524+
if ($attempts > 1) {
525+
return $attempts;
526+
}
527+
528+
throw new RuntimeException;
529+
}, 100, function ($ex) {
530+
return false;
531+
});
532+
}
533+
498534
public function testTransform()
499535
{
500536
$this->assertEquals(10, transform(5, function ($value) {

0 commit comments

Comments
 (0)