Skip to content

Commit a8763ff

Browse files
committed
feat: update tests
1 parent aefae4c commit a8763ff

File tree

2 files changed

+36
-46
lines changed

2 files changed

+36
-46
lines changed

phpunit.xml.dist

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,21 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
bootstrap="vendor/autoload.php"
55
backupGlobals="false"
6-
backupStaticAttributes="false"
76
colors="true"
8-
verbose="true"
9-
convertDeprecationsToExceptions="true"
10-
convertErrorsToExceptions="true"
11-
convertNoticesToExceptions="true"
12-
convertWarningsToExceptions="true"
137
processIsolation="false"
148
stopOnFailure="false"
159
cacheResult="false"
16-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
10+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.1/phpunit.xsd"
11+
cacheDirectory=".phpunit.cache" backupStaticProperties="false"
1712
>
18-
<coverage>
19-
<include>
20-
<directory suffix=".php">src/</directory>
21-
</include>
22-
</coverage>
2313
<testsuites>
2414
<testsuite name="laravel-rif-validation test suite">
2515
<directory>tests</directory>
2616
</testsuite>
2717
</testsuites>
28-
</phpunit>
18+
<source>
19+
<include>
20+
<directory suffix=".php">src/</directory>
21+
</include>
22+
</source>
23+
</phpunit>

tests/Rules/RifTest.php

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,109 +38,104 @@ protected function getPackageProviders($app)
3838
];
3939
}
4040

41-
/** @test */
42-
public function it_will_return_true_if_rif_is_valid()
41+
public function testItWillReturnVoidIfRifIsValid()
4342
{
4443
// Valid RIF of "Universidad de Carabobo"
4544
$rif = 'G-20000041-4';
4645

47-
$this->assertTrue($this->rule->passes('rif', $rif));
46+
$this->assertNull($this->rule->validate('rif', $rif, fn () => null));
4847

4948
// Valid RIF of "Banesco Banco Universal"
5049
$rif = 'J-07013380-5';
5150

52-
$this->assertTrue($this->rule->passes('rif', $rif));
51+
$this->assertNull($this->rule->validate('rif', $rif, fn () => null));
5352

5453
// Valid RIF of "Nicolas Maduro Moros"
5554
$rif = 'V-05892464-0';
5655

57-
$this->assertTrue($this->rule->passes('rif', $rif));
56+
$this->assertNull($this->rule->validate('rif', $rif, fn () => null));
5857
}
5958

60-
/** @test */
61-
public function it_will_return_false_if_format_is_invalid()
59+
public function testItWillReturnFalseIfFormatIsInvalid()
6260
{
6361
// Starts with a RIF Type that doesn't exist
6462
$rif = 'Q-00000000-0';
6563

66-
$this->assertFalse($this->rule->passes('rif', $rif));
64+
$this->assertNull($this->rule->validate('rif', $rif, fn ($value) => $this->assertNotNull($value)));
6765

6866
// Extra number
6967
$rif = 'G-200000041-4';
7068

71-
$this->assertFalse($this->rule->passes('rif', $rif));
69+
$this->assertNull($this->rule->validate('rif', $rif, fn ($value) => $this->assertNotNull($value)));
7270

7371
// Missing numbers
7472
$rif = 'V-5892464';
7573

76-
$this->assertFalse($this->rule->passes('rif', $rif));
74+
$this->assertNull($this->rule->validate('rif', $rif, fn ($value) => $this->assertNotNull($value)));
7775

7876
// Letter where there should be only numbers
7977
$rif = 'G-200F00041-F';
8078

81-
$this->assertFalse($this->rule->passes('rif', $rif));
79+
$this->assertNull($this->rule->validate('rif', $rif, fn ($value) => $this->assertNotNull($value)));
8280
}
8381

84-
/** @test */
85-
public function it_will_convert_values_to_uppercase_before_testing()
82+
public function testItWillConvertValuesToUppercaseBeforeTesting()
8683
{
8784
// Valid RIF of "Universidad de Carabobo"
8885
$rif = 'g-20000041-4';
8986

90-
$this->assertTrue($this->rule->passes('rif', $rif));
87+
$this->assertNull($this->rule->validate('rif', $rif, fn () => null));
9188

9289
// Valid RIF of "Banesco Banco Universal"
9390
$rif = 'j-07013380-5';
9491

95-
$this->assertTrue($this->rule->passes('rif', $rif));
92+
$this->assertNull($this->rule->validate('rif', $rif, fn () => null));
9693

9794
// Valid RIF of "Nicolas Maduro Moros"
9895
$rif = 'v-05892464-0';
9996

100-
$this->assertTrue($this->rule->passes('rif', $rif));
97+
$this->assertNull($this->rule->validate('rif', $rif, fn () => null));
10198
}
10299

103-
/** @test */
104-
public function it_will_validate_using_class()
100+
public function testItWillValidateUsingClass()
105101
{
106102
// Valid RIF of "Universidad de Carabobo"
107-
$this->assertTrue($this->validator->make(
103+
$this->assertEquals(['rif' => 'G-20000041-4'], $this->validator->make(
108104
['rif' => 'G-20000041-4'],
109105
['rif' => new Rif],
110-
)->passes());
106+
)->validate());
111107

112108
// Valid RIF of "Banesco Banco Universal"
113-
$this->assertTrue($this->validator->make(
109+
$this->assertEquals(['rif' => 'J-07013380-5'], $this->validator->make(
114110
['rif' => 'J-07013380-5'],
115111
['rif' => new Rif],
116-
)->passes());
112+
)->validate());
117113

118114
// Valid RIF of "Nicolas Maduro Moros"
119-
$this->assertTrue($this->validator->make(
115+
$this->assertEquals(['rif' => 'V-05892464-0'], $this->validator->make(
120116
['rif' => 'V-05892464-0'],
121117
['rif' => new Rif],
122-
)->passes());
118+
)->validate());
123119
}
124120

125-
/** @test */
126-
public function it_will_validate_using_shortname()
121+
public function testItWillValidateUsingShortname()
127122
{
128123
// Valid RIF of "Universidad de Carabobo"
129-
$this->assertTrue($this->validator->make(
124+
$this->assertEquals(['rif' => 'G-20000041-4'], $this->validator->make(
130125
['rif' => 'G-20000041-4'],
131126
['rif' => 'rif'],
132-
)->passes());
127+
)->validate());
133128

134129
// Valid RIF of "Banesco Banco Universal"
135-
$this->assertTrue($this->validator->make(
130+
$this->assertEquals(['rif' => 'J-07013380-5'], $this->validator->make(
136131
['rif' => 'J-07013380-5'],
137132
['rif' => 'rif'],
138-
)->passes());
133+
)->validate());
139134

140135
// Valid RIF of "Nicolas Maduro Moros"
141-
$this->assertTrue($this->validator->make(
136+
$this->assertEquals(['rif' => 'V-05892464-0'], $this->validator->make(
142137
['rif' => 'V-05892464-0'],
143138
['rif' => 'rif'],
144-
)->passes());
139+
)->validate());
145140
}
146-
}
141+
}

0 commit comments

Comments
 (0)