Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Small test fixes #47369

Merged
merged 3 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/Validation/ValidationEnumRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class ValidationEnumRuleTest extends TestCase
{
public function testvalidationPassesWhenPassingCorrectEnum()
public function testValidationPassesWhenPassingCorrectEnum()
{
$v = new Validator(
resolve('translator'),
Expand All @@ -32,7 +32,7 @@ public function testvalidationPassesWhenPassingCorrectEnum()
$this->assertFalse($v->fails());
}

public function testvalidationPassesWhenPassingInstanceOfEnum()
public function testValidationPassesWhenPassingInstanceOfEnum()
{
$v = new Validator(
resolve('translator'),
Expand All @@ -47,7 +47,7 @@ public function testvalidationPassesWhenPassingInstanceOfEnum()
$this->assertFalse($v->fails());
}

public function testvalidationPassesWhenPassingInstanceOfPureEnum()
public function testValidationPassesWhenPassingInstanceOfPureEnum()
{
$v = new Validator(
resolve('translator'),
Expand Down
8 changes: 4 additions & 4 deletions tests/Validation/ValidationExcludeIfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class ValidationExcludeIfTest extends TestCase
{
public function testItClousureReturnsFormatsAStringVersionOfTheRule()
public function testItReturnsStringVersionOfRuleWhenCast()
{
$rule = new ExcludeIf(function () {
return true;
Expand All @@ -33,7 +33,7 @@ public function testItClousureReturnsFormatsAStringVersionOfTheRule()
$this->assertSame('', (string) $rule);
}

public function testItOnlyCallableAndBooleanAreAcceptableArgumentsOfTheRule()
public function testItValidatesCallableAndBooleanAreAcceptableArguments()
{
new ExcludeIf(false);
new ExcludeIf(true);
Expand All @@ -49,11 +49,11 @@ public function testItOnlyCallableAndBooleanAreAcceptableArgumentsOfTheRule()
}
}

public function testItReturnedRuleIsNotSerializable()
public function testItThrowsExceptionIfRuleIsNotSerializable()
{
$this->expectException(Exception::class);

$rule = serialize(new ExcludeIf(function () {
serialize(new ExcludeIf(function () {
return true;
}));
}
Expand Down
6 changes: 0 additions & 6 deletions tests/Validation/ValidationForEachTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Illuminate\Translation\Translator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Validator;
use Mockery as m;
use PHPUnit\Framework\TestCase;

class ValidationForEachTest extends TestCase
Expand Down Expand Up @@ -320,11 +319,6 @@ public function testConditionalRulesCanBeAddedToForEachWithObject()
], $v->getMessageBag()->toArray());
}

protected function getTranslator()
{
return m::mock(TranslatorContract::class);
}

public function getIlluminateArrayTranslator()
{
return new Translator(
Expand Down
16 changes: 8 additions & 8 deletions tests/Validation/ValidationProhibitedIfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class ValidationProhibitedIfTest extends TestCase
{
public function testItClousureReturnsFormatsAStringVersionOfTheRule()
public function testItReturnsStringVersionOfRuleWhenCast()
{
$rule = new ProhibitedIf(function () {
return true;
Expand All @@ -33,27 +33,27 @@ public function testItClousureReturnsFormatsAStringVersionOfTheRule()
$this->assertSame('', (string) $rule);
}

public function testItOnlyCallableAndBooleanAreAcceptableArgumentsOfTheRule()
public function testItValidatesCallableAndBooleanAreAcceptableArguments()
{
$rule = new ProhibitedIf(false);

$rule = new ProhibitedIf(true);
new ProhibitedIf(false);
new ProhibitedIf(true);
new ProhibitedIf(fn () => true);

foreach ([1, 1.1, 'phpinfo', new stdClass] as $condition) {
try {
$rule = new ProhibitedIf($condition);
new ProhibitedIf($condition);
$this->fail('The ProhibitedIf constructor must not accept '.gettype($condition));
} catch (InvalidArgumentException $exception) {
$this->assertEquals('The provided condition must be a callable or boolean.', $exception->getMessage());
}
}
}

public function testItReturnedRuleIsNotSerializable()
public function testItThrowsExceptionIfRuleIsNotSerializable()
{
$this->expectException(Exception::class);

$rule = serialize(new ProhibitedIf(function () {
serialize(new ProhibitedIf(function () {
return true;
}));
}
Expand Down