Skip to content

Commit

Permalink
Merge branch '5.4' of github.com:laravel/framework into 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jun 13, 2017
2 parents 097f02f + ca3955f commit a7ebbfa
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Queue/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ protected function getNextJob($connection, $queue)

$this->stopWorkerIfLostConnection($e);
} catch (Throwable $e) {
$this->exceptions->report(new FatalThrowableError($e));
$this->exceptions->report($e = new FatalThrowableError($e));

$this->stopWorkerIfLostConnection($e);
}
Expand All @@ -270,7 +270,7 @@ protected function runJob($job, $connectionName, WorkerOptions $options)

$this->stopWorkerIfLostConnection($e);
} catch (Throwable $e) {
$this->exceptions->report(new FatalThrowableError($e));
$this->exceptions->report($e = new FatalThrowableError($e));

$this->stopWorkerIfLostConnection($e);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,9 @@ protected function failsRatioCheck($parameters, $width, $height)
[1, 1], array_filter(sscanf($parameters['ratio'], '%f/%d'))
);

return abs($numerator / $denominator - $width / $height) > 0.000001;
$precision = 1 / max($width, $height);

return abs($numerator / $denominator - $width / $height) > $precision;
}

/**
Expand Down
4 changes: 4 additions & 0 deletions tests/Validation/ValidationDimensionsRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ public function testItCorrectlyFormatsAStringVersionOfTheRule()
$rule = Rule::dimensions()->maxWidth(1000)->maxHeight(500)->ratio(3 / 2);

$this->assertEquals('dimensions:max_width=1000,max_height=500,ratio=1.5', (string) $rule);

$rule = new Dimensions(['ratio' => '2/3']);

$this->assertEquals('dimensions:ratio=2/3', (string) $rule);
}
}
11 changes: 11 additions & 0 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,9 @@ public function testValidateImage()
$this->assertTrue($v->passes());
}

/**
* @group dimension
*/
public function testValidateImageDimensions()
{
// Knowing that demo image.png has width = 3 and height = 2
Expand Down Expand Up @@ -2037,6 +2040,14 @@ public function testValidateImageDimensions()

$v = new Validator($trans, ['x' => $emptyUploadedFile], ['x' => 'dimensions:min_width=1']);
$this->assertTrue($v->fails());

// Knowing that demo image3.png has width = 7 and height = 10
$uploadedFile = new \Symfony\Component\HttpFoundation\File\UploadedFile(__DIR__.'/fixtures/image3.png', '', null, null, null, true);
$trans = $this->getIlluminateArrayTranslator();

// Ensure validation doesn't erroneously fail when ratio has no fractional part
$v = new Validator($trans, ['x' => $uploadedFile], ['x' => 'dimensions:ratio=2/3']);
$this->assertTrue($v->passes());
}

/**
Expand Down
Binary file added tests/Validation/fixtures/image3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a7ebbfa

Please sign in to comment.