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

Enhancement: Merge 1.23 into 2.0 #786

Merged
merged 2 commits into from
Sep 26, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Removed legacy autoloader (#762)
- Removed functionality for populating ORM entities and models (#764)
- Added a PHP version support policy (#752)
- Stopped using `static` in callables in `Provider\pt_BR\PhoneNumber` (#785)

## [2023-06-12, v1.23.0](https://github.com/FakerPHP/Faker/compare/v1.22.0..v1.23.0)

Expand Down
6 changes: 3 additions & 3 deletions src/Provider/pt_BR/PhoneNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static function phone($formatted = true)
['landline', null],
]);

return call_user_func("static::{$options[0]}", $formatted, $options[1]);
return call_user_func([static::class, $options[0]], $formatted, $options[1]);
}

/**
Expand Down Expand Up @@ -135,7 +135,7 @@ public function phoneNumber()
{
$method = static::randomElement(['cellphoneNumber', 'landlineNumber']);

return call_user_func("static::$method", true);
return call_user_func([static::class, $method], true);
}

/**
Expand All @@ -145,6 +145,6 @@ public static function phoneNumberCleared()
{
$method = static::randomElement(['cellphoneNumber', 'landlineNumber']);

return call_user_func("static::$method", false);
return call_user_func([static::class, $method], false);
}
}
51 changes: 51 additions & 0 deletions test/Provider/pt_BR/PhoneNumberTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

namespace Faker\Test\Provider\pt_BR;

use Faker\Provider;
use Faker\Test;

/**
* @covers \Faker\Provider\pt_BR\PhoneNumber
*/
final class PhoneNumberTest extends Test\TestCase
{
public function testPhoneReturnsPhoneNumberWhenArgumentIsFalse(): void
{
$phoneNumber = $this->faker->phone(false);

self::assertIsString($phoneNumber);
self::assertNotEmpty($phoneNumber);
}

public function testPhoneReturnsPhoneNumberWhenArgumentIsTrue(): void
{
$phoneNumber = $this->faker->phone(true);

self::assertIsString($phoneNumber);
self::assertNotEmpty($phoneNumber);
}

public function testPhoneNumberReturnsPhoneNumber(): void
{
$phoneNumber = $this->faker->phoneNumber();

self::assertIsString($phoneNumber);
self::assertNotEmpty($phoneNumber);
}

public function testPhoneNumberClearedReturnsPhoneNumber(): void
{
$phoneNumber = $this->faker->phoneNumberCleared();

self::assertIsString($phoneNumber);
self::assertNotEmpty($phoneNumber);
}

protected function getProviders(): iterable
{
yield new Provider\pt_BR\PhoneNumber($this->faker);
}
}
Loading