Skip to content

Commit

Permalink
Support PHP 8.0 (#4)
Browse files Browse the repository at this point in the history

Co-Authored-By: Chris Döhring <6341536+chris-doehring@users.noreply.github.com>
  • Loading branch information
GrahamCampbell and chris-doehring authored Oct 27, 2020
1 parent 0ee2cb2 commit c137172
Show file tree
Hide file tree
Showing 134 changed files with 550 additions and 542 deletions.
1 change: 1 addition & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- "7.2"
- "7.3"
- "7.4"
- "8.0"

steps:
- name: "Checkout"
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
}
],
"require": {
"php": "^7.1"
"php": "^7.1 || ^8.0"
},
"require-dev": {
"ext-intl": "*",
"phpunit/phpunit": "^5.7"
"phpunit/phpunit": "^7.5.20 || ^8.5.8 || ^9.4.2"
},
"autoload": {
"psr-4": {
Expand Down
14 changes: 7 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
colors="true"
columns="max"
verbose="true"
cacheResultFile=".build/.phpunit.result.cache"
>
<testsuites>
<testsuite name="Faker Test Suite">
<directory>./test/Faker/</directory>
<directory suffix="Test.php">./test/Faker</directory>
</testsuite>
</testsuites>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true" processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src/Faker</directory>
</include>
</coverage>
</phpunit>
7 changes: 2 additions & 5 deletions test/Faker/Calculator/EanTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?php


namespace Faker\Test\Calculator;


use Faker\Calculator\Ean;
use PHPUnit\Framework\TestCase;
use Faker\Test\TestCase;

final class EanTest extends TestCase
{
Expand Down Expand Up @@ -80,5 +78,4 @@ public function testEan13Validation($ean13, $valid)
{
$this->assertTrue(Ean::isValid($ean13) === $valid);
}

}
}
3 changes: 1 addition & 2 deletions test/Faker/Calculator/IbanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace Faker\Test\Calculator;

use Faker\Calculator\Iban;
use PHPUnit\Framework\TestCase;
use Faker\Test\TestCase;

final class IbanTest extends TestCase
{

public function checksumProvider()
{
return array(
Expand Down
3 changes: 1 addition & 2 deletions test/Faker/Calculator/InnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace Faker\Test\Calculator;

use Faker\Calculator\Inn;
use PHPUnit\Framework\TestCase;
use Faker\Test\TestCase;

final class InnTest extends TestCase
{

public function checksumProvider()
{
return array(
Expand Down
11 changes: 4 additions & 7 deletions test/Faker/Calculator/LuhnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
namespace Faker\Test\Calculator;

use Faker\Calculator\Luhn;
use PHPUnit\Framework\TestCase;
use Faker\Test\TestCase;

final class LuhnTest extends TestCase
{

public function checkDigitProvider()
{
return array(
Expand All @@ -31,7 +30,7 @@ public function checkDigitProvider()
*/
public function testComputeCheckDigit($partialNumber, $checkDigit)
{
$this->assertInternalType('string', $checkDigit);
$this->assertIsString($checkDigit);
$this->assertEquals($checkDigit, Luhn::computeCheckDigit($partialNumber));
}

Expand Down Expand Up @@ -61,12 +60,10 @@ public function testIsValid($number, $isValid)
$this->assertEquals($isValid, Luhn::isValid($number));
}

/**
* @expectedException InvalidArgumentException
* @expectedExceptionMessage Argument should be an integer.
*/
public function testGenerateLuhnNumberWithInvalidPrefix()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Argument should be an integer.');
Luhn::generateLuhnNumber('abc');
}
}
2 changes: 1 addition & 1 deletion test/Faker/Calculator/TCNoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Faker\Test\Calculator;

use Faker\Calculator\TCNo;
use PHPUnit\Framework\TestCase;
use Faker\Test\TestCase;

final class TCNoTest extends TestCase
{
Expand Down
1 change: 0 additions & 1 deletion test/Faker/DefaultGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Faker\Test;

use Faker\DefaultGenerator;
use PHPUnit\Framework\TestCase;

final class DefaultGeneratorTest extends TestCase
{
Expand Down
11 changes: 3 additions & 8 deletions test/Faker/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Faker\Test;

use Faker\Generator;
use PHPUnit\Framework\TestCase;

final class GeneratorTest extends TestCase
{
Expand All @@ -20,7 +19,7 @@ public function testGetFormatterReturnsCallable()
$generator = new Generator;
$provider = new FooProvider();
$generator->addProvider($provider);
$this->assertInternalType('callable', $generator->getFormatter('fooFormatter'));
$this->assertIsCallable($generator->getFormatter('fooFormatter'));
}

public function testGetFormatterReturnsCorrectFormatter()
Expand All @@ -32,20 +31,16 @@ public function testGetFormatterReturnsCorrectFormatter()
$this->assertEquals($expected, $generator->getFormatter('fooFormatter'));
}

/**
* @expectedException InvalidArgumentException
*/
public function testGetFormatterThrowsExceptionOnIncorrectProvider()
{
$this->expectException(\InvalidArgumentException::class);
$generator = new Generator;
$generator->getFormatter('fooFormatter');
}

/**
* @expectedException InvalidArgumentException
*/
public function testGetFormatterThrowsExceptionOnIncorrectFormatter()
{
$this->expectException(\InvalidArgumentException::class);
$generator = new Generator;
$provider = new FooProvider();
$generator->addProvider($provider);
Expand Down
14 changes: 7 additions & 7 deletions test/Faker/Provider/AddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

use Faker\Generator;
use Faker\Provider\Address;
use PHPUnit\Framework\TestCase;
use Faker\Test\TestCase;

final class AddressTest extends TestCase
{
private $faker;

protected function setUp()
protected function setUp(): void
{
$faker = new Generator();
$faker->addProvider(new Address($faker));
Expand All @@ -20,27 +20,27 @@ protected function setUp()
public function testLatitude()
{
$latitude = $this->faker->latitude();
$this->assertInternalType('float', $latitude);
$this->assertIsFloat($latitude);
$this->assertGreaterThanOrEqual(-90, $latitude);
$this->assertLessThanOrEqual(90, $latitude);
}

public function testLongitude()
{
$longitude = $this->faker->longitude();
$this->assertInternalType('float', $longitude);
$this->assertIsFloat($longitude);
$this->assertGreaterThanOrEqual(-180, $longitude);
$this->assertLessThanOrEqual(180, $longitude);
}

public function testCoordinate()
{
$coordinate = $this->faker->localCoordinates();
$this->assertInternalType('array', $coordinate);
$this->assertInternalType('float', $coordinate['latitude']);
$this->assertIsArray($coordinate);
$this->assertIsFloat($coordinate['latitude']);
$this->assertGreaterThanOrEqual(-90, $coordinate['latitude']);
$this->assertLessThanOrEqual(90, $coordinate['latitude']);
$this->assertInternalType('float', $coordinate['longitude']);
$this->assertIsFloat($coordinate['longitude']);
$this->assertGreaterThanOrEqual(-180, $coordinate['longitude']);
$this->assertLessThanOrEqual(180, $coordinate['longitude']);
}
Expand Down
8 changes: 4 additions & 4 deletions test/Faker/Provider/BarcodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

use Faker\Generator;
use Faker\Provider\Barcode;
use PHPUnit\Framework\TestCase;
use Faker\Test\TestCase;

final class BarcodeTest extends TestCase
{
private $faker;

protected function setUp()
protected function setUp(): void
{
$faker = new Generator();
$faker->addProvider(new Barcode($faker));
Expand All @@ -21,7 +21,7 @@ protected function setUp()
public function testEan8()
{
$code = $this->faker->ean8();
$this->assertRegExp('/^\d{8}$/i', $code);
$this->assertMatchesRegularExpression('/^\d{8}$/i', $code);
$codeWithoutChecksum = substr($code, 0, -1);
$checksum = substr($code, -1);
$this->assertEquals(TestableBarcode::eanChecksum($codeWithoutChecksum), $checksum);
Expand All @@ -30,7 +30,7 @@ public function testEan8()
public function testEan13()
{
$code = $this->faker->ean13();
$this->assertRegExp('/^\d{13}$/i', $code);
$this->assertMatchesRegularExpression('/^\d{13}$/i', $code);
$codeWithoutChecksum = substr($code, 0, -1);
$checksum = substr($code, -1);
$this->assertEquals(TestableBarcode::eanChecksum($codeWithoutChecksum), $checksum);
Expand Down
Loading

0 comments on commit c137172

Please sign in to comment.