Skip to content

Commit e26ce02

Browse files
authored
Refactor test providers and constructor property visibility (#7444)
1 parent efcadb4 commit e26ce02

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

tests/Cases/ValidationEnumRuleTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ public function testValidationPassesWhenExceptCasesProvided(
149149
$this->assertSame($expected, $v->fails());
150150
}
151151

152+
public static function conditionalCasesDataProvider(): array
153+
{
154+
return [
155+
[IntegerStatus::done, IntegerStatus::done, true],
156+
[IntegerStatus::done, [IntegerStatus::done, IntegerStatus::pending], true],
157+
[IntegerStatus::pending->value, [IntegerStatus::done, IntegerStatus::pending], true],
158+
[IntegerStatus::done->value, IntegerStatus::pending, false],
159+
];
160+
}
161+
152162
public function testOnlyHasHigherOrderThanExcept(): void
153163
{
154164
$v = new Validator(
@@ -271,16 +281,6 @@ public function testValidationFailsWhenProvidingStringToIntegerType(): void
271281
$this->assertEquals(['The selected status is invalid.'], $v->messages()->get('status'));
272282
}
273283

274-
public static function conditionalCasesDataProvider(): array
275-
{
276-
return [
277-
[IntegerStatus::done, IntegerStatus::done, true],
278-
[IntegerStatus::done, [IntegerStatus::done, IntegerStatus::pending], true],
279-
[IntegerStatus::pending->value, [IntegerStatus::done, IntegerStatus::pending], true],
280-
[IntegerStatus::done->value, IntegerStatus::pending, false],
281-
];
282-
}
283-
284284
private function getTranslator(): Translator
285285
{
286286
return new Translator(

tests/Cases/ValidationValidatorTest.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2893,17 +2893,6 @@ public function testValidateUrlWithValidUrls($validUrl)
28932893
$this->assertTrue($v->passes());
28942894
}
28952895

2896-
/**
2897-
* @param mixed $invalidUrl
2898-
*/
2899-
#[DataProvider('invalidUrls')]
2900-
public function testValidateUrlWithInvalidUrls($invalidUrl)
2901-
{
2902-
$trans = $this->getIlluminateArrayTranslator();
2903-
$v = new Validator($trans, ['x' => $invalidUrl], ['x' => 'Url']);
2904-
$this->assertFalse($v->passes());
2905-
}
2906-
29072896
public static function validUrls()
29082897
{
29092898
return [
@@ -3146,6 +3135,17 @@ public static function validUrls()
31463135
];
31473136
}
31483137

3138+
/**
3139+
* @param mixed $invalidUrl
3140+
*/
3141+
#[DataProvider('invalidUrls')]
3142+
public function testValidateUrlWithInvalidUrls($invalidUrl)
3143+
{
3144+
$trans = $this->getIlluminateArrayTranslator();
3145+
$v = new Validator($trans, ['x' => $invalidUrl], ['x' => 'Url']);
3146+
$this->assertFalse($v->passes());
3147+
}
3148+
31493149
public static function invalidUrls()
31503150
{
31513151
return [
@@ -5299,17 +5299,6 @@ public function testValidateWithValidUuid($uuid)
52995299
$this->assertTrue($v->passes());
53005300
}
53015301

5302-
/**
5303-
* @param mixed $uuid
5304-
*/
5305-
#[DataProvider('invalidUuidList')]
5306-
public function testValidateWithInvalidUuid($uuid)
5307-
{
5308-
$trans = $this->getIlluminateArrayTranslator();
5309-
$v = new Validator($trans, ['foo' => $uuid], ['foo' => 'uuid']);
5310-
$this->assertFalse($v->passes());
5311-
}
5312-
53135302
public static function validUuidList()
53145303
{
53155304
return [
@@ -5326,6 +5315,17 @@ public static function validUuidList()
53265315
];
53275316
}
53285317

5318+
/**
5319+
* @param mixed $uuid
5320+
*/
5321+
#[DataProvider('invalidUuidList')]
5322+
public function testValidateWithInvalidUuid($uuid)
5323+
{
5324+
$trans = $this->getIlluminateArrayTranslator();
5325+
$v = new Validator($trans, ['foo' => $uuid], ['foo' => 'uuid']);
5326+
$this->assertFalse($v->passes());
5327+
}
5328+
53295329
public static function invalidUuidList()
53305330
{
53315331
return [

0 commit comments

Comments
 (0)