Skip to content

Commit

Permalink
prepare for next major release
Browse files Browse the repository at this point in the history
  • Loading branch information
1ma committed Sep 24, 2023
1 parent 42dc61b commit 38615f3
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 71 deletions.
40 changes: 10 additions & 30 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,15 @@
on: push

jobs:
php73:
run:
name: Continuous Integration
runs-on: ubuntu-latest
container: 1maa/php-dev:7.3
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Run tests in PHP 7.3
run: |
composer install
composer test
php74:
runs-on: ubuntu-latest
container: 1maa/php-dev:7.4
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Run tests in PHP 7.4
run: |
composer install
composer test
php80:
runs-on: ubuntu-latest
container: 1maa/php-dev:8.0
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Run tests in PHP 8.0
run: |
composer install
composer test
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: 8.2
- run: composer install
- run: composer test
- run: php vendor/bin/php-cs-fixer fix --dry-run -v
- run: php vendor/bin/phpunit
4 changes: 2 additions & 2 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ filter:
excluded_paths:
- 'tests/'
dependency_paths:
- "vendor/"
- 'vendor/'
checks:
php: true
coding_style:
Expand All @@ -17,7 +17,7 @@ build:
- php-scrutinizer-run --enable-security-analysis
testing:
environment:
php: '7.3'
php: '8.2'
tests:
override:
-
Expand Down
18 changes: 5 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
"description": "Lightweight UUID library",
"type": "library",
"license": "MIT",
"minimum-stability": "alpha",
"prefer-stable": true,
"require": {
"php-64bit": "^7.3.0 || ^7.4.0 || ^8.0.0"
"php-64bit": "^8.2.0"
},
"require-dev": {
"phpbench/phpbench": "^1.0@alpha",
"phpunit/phpunit": "^9.5"
"phpbench/phpbench": "^1.0",
"phpunit/phpunit": "^10.3"
},
"autoload": {
"psr-4": {
Expand All @@ -23,14 +21,8 @@
}
},
"scripts": {
"bench": [
"@composer install",
"php vendor/bin/phpbench run --report=env --report=aggregate"
],
"test" : [
"@composer install",
"php vendor/bin/phpunit"
]
"bench": "@php vendor/bin/phpbench run --report=env --report=aggregate",
"test" : "@php vendor/bin/phpunit"
},
"config": {
"sort-packages": true
Expand Down
17 changes: 9 additions & 8 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
backupGlobals="true"
bootstrap="vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
bootstrap="vendor/autoload.php"
cacheResult="false"
colors="true"
executionOrder="depends,defects"
failOnRisky="true"
failOnWarning="true"
testdox="true"
verbose="true"
>
<testsuites>
<testsuite name="uma/uuid test suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<coverage>
<report>
<clover outputFile="build/coverage.xml"/>
<html outputDirectory="build/coverage"/>
<text outputFile="php://stdout" showOnlySummary="true"/>
</report>
</coverage>

<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
6 changes: 3 additions & 3 deletions tests/CombGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class CombGeneratorTest extends TestCase
{
public function testInvalidGranularity()
public function testInvalidGranularity(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('$granularity must be in the [0, 6] range. Got: 10');
Expand All @@ -20,14 +20,14 @@ public function testInvalidGranularity()
/**
* @dataProvider overflowDatesProvider
*/
public function testOverflowDates(int $granularity, string $expectedOverflowDate)
public function testOverflowDates(int $granularity, string $expectedOverflowDate): void
{
$overflowDate = (new CombGenerator($granularity))->getOverflowDate();

self::assertSame($expectedOverflowDate, $overflowDate->format('Y-m-d H:i:s'));
}

public function overflowDatesProvider(): array
public static function overflowDatesProvider(): array
{
// Yes, 5 overflows sooner than 6 because 6 already overflowed over 48-bits
// in the past (on 1978-12-02 19:29:36 UTC) and 5 still hasn't overflowed
Expand Down
6 changes: 3 additions & 3 deletions tests/SequentialGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class SequentialGeneratorTest extends TestCase
{
public function testVanillaUsage()
public function testVanillaUsage(): void
{
$sut = new SequentialGenerator();

Expand All @@ -19,7 +19,7 @@ public function testVanillaUsage()
self::assertSame('00000000-0000-0000-0000-000000000003', (string) $sut->generate());
}

public function testCustomMarksAndStarts()
public function testCustomMarksAndStarts(): void
{
$sut = new SequentialGenerator(15);

Expand All @@ -43,7 +43,7 @@ public function testCustomMarksAndStarts()
self::assertSame('00000000-0000-000a-0000-00000000000d', (string) $sut->generate());
}

public function testOverflows()
public function testOverflows(): void
{
$sut = new SequentialGenerator(0, PHP_INT_MAX);

Expand Down
4 changes: 2 additions & 2 deletions tests/UuidGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class UuidGeneratorTest extends TestCase
* @param int $version The expected version to be found
* on all Uuids generated by $sut.
*/
public function testFormatAndCollisions(UuidGenerator $sut, int $version)
public function testFormatAndCollisions(UuidGenerator $sut, int $version): void
{
$seen = [];

Expand All @@ -36,7 +36,7 @@ public function testFormatAndCollisions(UuidGenerator $sut, int $version)
}
}

public function formatAndCollisionsProvider(): array
public static function formatAndCollisionsProvider(): array
{
return [
[new CombGenerator(), 4],
Expand Down
12 changes: 6 additions & 6 deletions tests/UuidTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,43 @@

class UuidTest extends TestCase
{
public function testNilFactory()
public function testNilFactory(): void
{
self::assertSame(Uuid::NIL, Uuid::nil()->asString());
}

public function testAlias()
public function testAlias(): void
{
$uuid = (new Version4Generator)->generate();

self::assertSame($uuid->asString(), (string) $uuid);
}

public function testEquivalence()
public function testEquivalence(): void
{
$uuid1 = (new Version4Generator)->generate();
$uuid2 = Uuid::fromString($uuid1->asString());

self::assertEquals($uuid1, $uuid2);
}

public function testCaseInsensitivity()
public function testCaseInsensitivity(): void
{
$uuid1 = Uuid::fromString('00112233-4455-6677-8899-aabbccddeeff');
$uuid2 = Uuid::fromString('00112233-4455-6677-8899-AABBCCDDEEFF');

self::assertEquals($uuid1, $uuid2);
}

public function testInvalidBytesInput()
public function testInvalidBytesInput(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Length of $bytes for new Uuid is not 16. Got: 0x61626364');

Uuid::fromBytes('abcd');
}

public function testInvalidTextInput()
public function testInvalidTextInput(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('$text is not a valid Uuid. Got: a-b-cd-');
Expand Down
4 changes: 2 additions & 2 deletions tests/Version1GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

class Version1GeneratorTest extends TestCase
{
public function testValidMACAddress()
public function testValidMacAddress(): void
{
$sut = new Version1Generator('01:23:45:67:89:ab');

self::assertTrue(Uuid::isUuid((string) $sut->generate()));
}

public function testInvalidMACAddress()
public function testInvalidMacAddress(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('$nodeID is not a valid MAC address. Got: wh:at:is:th:is:?!');
Expand Down
4 changes: 2 additions & 2 deletions tests/Version5GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class Version5GeneratorTest extends TestCase
{
public function testIt()
public function testIt(): void
{
$sut = new Version5Generator(Uuid::fromString(Version5Generator::NS_DNS));

Expand All @@ -22,7 +22,7 @@ public function testIt()
);
}

public function testMissingName()
public function testMissingName(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('$name is mandatory. Got: NULL');
Expand Down

0 comments on commit 38615f3

Please sign in to comment.