Skip to content

Commit

Permalink
Merge pull request #17 from fnsc/slack/bump-libs
Browse files Browse the repository at this point in the history
slack(libs): bump packages
  • Loading branch information
fnsc authored Oct 1, 2023
2 parents 2d89277 + e253b92 commit 5c9c6dc
Show file tree
Hide file tree
Showing 8 changed files with 1,292 additions and 1,064 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/.idea
.phpunit.result.cache
.phpcs-cache
clover.xml
clover.xml
.phpunit.cache
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
"require": {
"php": "^8.1",
"ext-json": "*",
"illuminate/console": "^9.9",
"illuminate/support": "^9.9",
"illuminate/config": "^9.9"
"illuminate/console": "^9.9|10.*",
"illuminate/support": "^9.9|10.*",
"illuminate/config": "^9.9|10.*"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"illuminate/validation": "^9.9",
"phpunit/phpunit": "^9.6.13|10.3.5",
"illuminate/validation": "^9.9|10.*",
"leroy-merlin-br/coding-standard": "v3.1.0",
"mockery/mockery": "^1.5",
"rector/rector": "^0.12.21",
"phpro/grumphp": "^1.13",
"phpstan/phpstan": "^1.8"
"mockery/mockery": "^1.6.6",
"rector/rector": "^0.18.4",
"phpro/grumphp": "^1.16.0",
"phpstan/phpstan": "^1.10.36"
},
"autoload": {
"psr-4": {
Expand Down
2,158 changes: 1,194 additions & 964 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.1.5-cli
FROM php:8.1-cli

WORKDIR /var/www/html

Expand Down
27 changes: 12 additions & 15 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>
<coverage/>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
26 changes: 13 additions & 13 deletions tests/Unit/src/CNPJ/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,22 @@ public function testShouldValidateCnpj(string $value, bool $expected): void
$this->assertSame($expected, $result);
}

public function testShouldReturnTheValidatorAlias(): void
{
// Set
$validator = new Validator();

// Actions
$result = $validator->getAlias();

// Assertions
$this->assertSame('cnpj', $result);
}

/**
* @return mixed[]
*/
public function getCnpjScenarios(): array
public static function getCnpjScenarios(): array
{
return [
'valid cnpj without special chars' => [
Expand All @@ -49,16 +61,4 @@ public function getCnpjScenarios(): array
],
];
}

public function testShouldReturnTheValidatorAlias(): void
{
// Set
$validator = new Validator();

// Actions
$result = $validator->getAlias();

// Assertions
$this->assertSame('cnpj', $result);
}
}
50 changes: 25 additions & 25 deletions tests/Unit/src/CPF/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,34 @@ public function testShouldValidateCpf(string $value, bool $expected): void
$this->assertSame($expected, $result);
}

public function testShouldReturnTheErrorMessage(): void
{
// Set
$validator = new Validator();

// Actions
$result = $validator->message();

// Assertions
$this->assertSame('O :attribute é inválido.', $result);
}

public function testShouldReturnTheValidatorAlias(): void
{
// Set
$validator = new Validator();

// Actions
$result = $validator->getAlias();

// Assertions
$this->assertSame('cpf', $result);
}

/**
* @return mixed[]
*/
public function getCpfScenarios(): array
public static function getCpfScenarios(): array
{
return [
'valid cpf without special chars' => [
Expand Down Expand Up @@ -57,28 +81,4 @@ public function getCpfScenarios(): array
],
];
}

public function testShouldReturnTheErrorMessage(): void
{
// Set
$validator = new Validator();

// Actions
$result = $validator->message();

// Assertions
$this->assertSame('O :attribute é inválido.', $result);
}

public function testShouldReturnTheValidatorAlias(): void
{
// Set
$validator = new Validator();

// Actions
$result = $validator->getAlias();

// Assertions
$this->assertSame('cpf', $result);
}
}
72 changes: 36 additions & 36 deletions tests/Unit/src/RegistrationNumber/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,44 @@ public function testShouldValidateTheCnpj(string $value, bool $expected): void
$this->assertSame($expected, $result);
}

/**
* @dataProvider getCpfScenarios
*/
public function testShouldValidateTheCpf(string $value, bool $expected): void
{
// Set
$validator = new Validator();
$cpf = m::mock(CPF::class);

// Expectations
/** @phpstan-ignore-next-line */
$cpf->expects()
->passes('cpf')
->andReturn($expected);

// Actions
$result = $validator->passes('cpf', $value);

// Assertions
$this->assertSame($expected, $result);
}

public function testShouldReturnTheValidatorAlias(): void
{
// Set
$validator = new Validator();

// Actions
$result = $validator->getAlias();

// Assertions
$this->assertSame('registration_number', $result);
}

/**
* @return mixed[]
*/
public function getCnpjScenarios(): array
public static function getCnpjScenarios(): array
{
return [
'valid cnpj without special chars' => [
Expand All @@ -60,32 +94,10 @@ public function getCnpjScenarios(): array
];
}

/**
* @dataProvider getCpfScenarios
*/
public function testShouldValidateTheCpf(string $value, bool $expected): void
{
// Set
$validator = new Validator();
$cpf = m::mock(CPF::class);

// Expectations
/** @phpstan-ignore-next-line */
$cpf->expects()
->passes('cpf')
->andReturn($expected);

// Actions
$result = $validator->passes('cpf', $value);

// Assertions
$this->assertSame($expected, $result);
}

/**
* @return mixed[]
*/
public function getCpfScenarios(): array
public static function getCpfScenarios(): array
{
return [
'valid cpf without special chars' => [
Expand Down Expand Up @@ -118,16 +130,4 @@ public function getCpfScenarios(): array
],
];
}

public function testShouldReturnTheValidatorAlias(): void
{
// Set
$validator = new Validator();

// Actions
$result = $validator->getAlias();

// Assertions
$this->assertSame('registration_number', $result);
}
}

0 comments on commit 5c9c6dc

Please sign in to comment.