Skip to content

Commit

Permalink
Merge pull request #79 from vmiguellima/add-laravel-11-support
Browse files Browse the repository at this point in the history
Add Laravel 11.x Support
  • Loading branch information
clarkeash authored Mar 25, 2024
2 parents e55ea32 + 3b34713 commit e94b6be
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 258 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

strategy:
matrix:
php: [8.1]
php: [8.2]
stability: [prefer-lowest, prefer-stable]

# Steps represent a sequence of tasks that will be executed as part of the job
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/.idea
coverage.xml
.phpunit.result.cache
.phpunit.cache
composer.lock
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ Invite Codes:
8.x | 6.x
9.x | 7.x
10.x | 8.x
11.x | 9.x

## Installation

You can pull in the package using [composer](https://getcomposer.org):

```bash
$ composer require "clarkeash/doorman=^8.0"
$ composer require "clarkeash/doorman=^9.0"
```

Next, migrate the database:
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
}
],
"require": {
"php": "^8.1",
"laravel/framework": "^10.0",
"php": "^8.2",
"laravel/framework": "^11.0",
"ramsey/uuid": "^4.0"
},
"autoload": {
Expand All @@ -24,8 +24,8 @@
}
},
"require-dev": {
"orchestra/testbench": "^8.0",
"phpunit/phpunit": "^9.3",
"orchestra/testbench": "^9.0",
"phpunit/phpunit": "^11.0",
"mockery/mockery": "^1.4"
},
"extra": {
Expand Down
12 changes: 7 additions & 5 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<report>
<clover outputFile="coverage.xml"/>
</report>
Expand All @@ -23,4 +20,9 @@
<env name="QUEUE_DRIVER" value="sync"/>
</php>
<logging/>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
40 changes: 8 additions & 32 deletions tests/Feature/CheckInvitesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,12 @@ class CheckInvitesTest extends TestCase
{
use DatabaseMigrations;

/**
* @test
*/
public function check_if_code_is_invalid()
public function test_can_check_if_code_is_invalid()
{
Assert::assertFalse(Doorman::check('NOPE'));
}

/**
* @test
*/
public function check_if_maximum_uses_has_been_reached()
public function text_can_check_if_maximum_uses_has_been_reached()
{
Invite::forceCreate([
'code' => 'ABCDE',
Expand All @@ -35,10 +29,7 @@ public function check_if_maximum_uses_has_been_reached()
Assert::assertFalse(Doorman::check('ABCDE'));
}

/**
* @test
*/
public function check_if_code_has_expired()
public function test_can_check_if_code_has_expired()
{
Invite::forceCreate([
'code' => 'ABCDE',
Expand All @@ -48,10 +39,7 @@ public function check_if_code_has_expired()
Assert::assertFalse(Doorman::check('ABCDE'));
}

/**
* @test
*/
public function check_if_trying_to_use_a_code_belonging_to_someone_else()
public function test_can_check_if_trying_to_use_a_code_belonging_to_someone_else()
{
Invite::forceCreate([
'code' => 'ABCDE',
Expand All @@ -61,10 +49,7 @@ public function check_if_trying_to_use_a_code_belonging_to_someone_else()
Assert::assertFalse(Doorman::check('ABCDE'));
}

/**
* @test
*/
public function check_a_code_for_a_specific_user()
public function test_can_check_a_code_for_a_specific_user()
{
Invite::forceCreate([
'code' => 'ABCDE',
Expand All @@ -74,10 +59,7 @@ public function check_a_code_for_a_specific_user()
Assert::assertTrue(Doorman::check('ABCDE', '[email protected]'));
}

/**
* @test
*/
public function a_unrestricted_invite_can_be_redeemed_when_email_is_provided()
public function test_can_a_unrestricted_invite_can_be_redeemed_when_email_is_provided()
{
Invite::forceCreate([
'code' => 'ABCDE',
Expand All @@ -86,10 +68,7 @@ public function a_unrestricted_invite_can_be_redeemed_when_email_is_provided()
Assert::assertTrue(Doorman::check('ABCDE', '[email protected]'));
}

/**
* @test
*/
public function it_can_have_unlimited_redemptions()
public function test_can_it_can_have_unlimited_redemptions()
{
Invite::forceCreate([
'code' => 'ABCDE',
Expand All @@ -101,10 +80,7 @@ public function it_can_have_unlimited_redemptions()
}
}

/**
* @test
*/
public function it_is_not_case_sensitive()
public function test_it_is_not_case_sensitive()
{
Invite::forceCreate([
'code' => 'ABCDE',
Expand Down
5 changes: 1 addition & 4 deletions tests/Feature/CustomModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ protected function getEnvironmentSetUp($app)
$app['config']->set('doorman.invite_model', MyCustomModel::class);
}

/**
* @test
*/
public function it_can_use_a_custom_model()
public function test_it_can_use_a_custom_model()
{
$invites = Doorman::generate()->make();

Expand Down
15 changes: 3 additions & 12 deletions tests/Feature/CustomValidationRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ class CustomValidationRuleTest extends TestCase
{
use DatabaseMigrations;

/**
* @test
*/
public function basic_validation()
public function test_basic_validation()
{
Invite::forceCreate([
'code' => 'ABCDE',
Expand All @@ -37,10 +34,7 @@ public function basic_validation()
Assert::assertTrue($validator->passes());
}

/**
* @test
*/
public function validates_email_address()
public function test_validates_email_address()
{
Invite::forceCreate([
'code' => 'ABCDE',
Expand All @@ -62,10 +56,7 @@ public function validates_email_address()
Assert::assertTrue($validator->passes());
}

/**
* @test
*/
public function it_provides_an_error_message()
public function test_it_provides_an_error_message()
{
Invite::forceCreate([
'code' => 'ABCDE',
Expand Down
25 changes: 5 additions & 20 deletions tests/Feature/Drivers/BasicDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,23 @@ class BasicDriverTest extends TestCase
{
use DatabaseMigrations;

/**
* @test
*/
public function it_is_a_driver()
public function test_it_is_a_driver()
{
Assert::assertInstanceOf(DriverInterface::class, new BasicDriver);
}

/**
* @test
*/
public function it_is_the_correct_driver()
public function test_it_is_the_correct_driver()
{
Assert::assertInstanceOf(BasicDriver::class, app(DoormanManager::class)->driver('basic'));
}

/**
* @test
*/
public function it_is_the_default_driver()
public function test_it_is_the_default_driver()
{
Assert::assertSame('basic', config('doorman.driver'));
Assert::assertSame('basic', app(DoormanManager::class)->getDefaultDriver());
}

/**
* @test
*/
public function it_has_a_default_length()
public function test_it_has_a_default_length()
{
Assert::assertSame(5, config('doorman.basic.length'));

Expand All @@ -50,10 +38,7 @@ public function it_has_a_default_length()
Assert::assertSame(5, strlen($driver->code()));
}

/**
* @test
*/
public function it_allows_the_length_to_be_overridden()
public function test_it_allows_the_length_to_be_overridden()
{
Assert::assertSame(5, config('doorman.basic.length'));

Expand Down
49 changes: 11 additions & 38 deletions tests/Feature/Drivers/UuidDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,17 @@ class UuidDriverTest extends TestCase
{
use DatabaseMigrations;

/**
* @test
*/
public function it_is_a_driver()
public function test_it_is_a_driver()
{
Assert::assertInstanceOf(DriverInterface::class, new UuidDriver);
}

/**
* @test
*/
public function it_is_the_correct_driver()
public function test_it_is_the_correct_driver()
{
Assert::assertInstanceOf(UuidDriver::class, app(DoormanManager::class)->driver('uuid'));
}

/** @test */
public function it_can_generate_a_version_1_uuid()
public function test_it_can_generate_a_version_1_uuid()
{
$this->app['config']['doorman.uuid.version'] = 1;

Expand All @@ -45,10 +38,7 @@ public function it_can_generate_a_version_1_uuid()
Assert::assertSame(1, Uuid::fromString($code)->getVersion());
}

/**
* @test
*/
public function it_throws_exception_if_invalid_version_supplied()
public function test_it_throws_exception_if_invalid_version_supplied()
{
$this->expectException(InvalidArgumentException::class);

Expand All @@ -59,10 +49,7 @@ public function it_throws_exception_if_invalid_version_supplied()
$driver->code();
}

/**
* @test
*/
public function namespace_is_required_for_version_3()
public function test_namespace_is_required_for_version_3()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Namespace must be set for uuid version 3');
Expand All @@ -75,10 +62,7 @@ public function namespace_is_required_for_version_3()
$driver->code();
}

/**
* @test
*/
public function name_is_required_for_version_3()
public function test_name_is_required_for_version_3()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Name must be set for uuid version 3');
Expand All @@ -91,9 +75,7 @@ public function name_is_required_for_version_3()
$driver->code();
}


/** @test */
public function it_can_generate_a_version_3_uuid()
public function test_it_can_generate_a_version_3_uuid()
{
$this->app['config']['doorman.uuid.version'] = 3;
$this->app['config']['doorman.uuid.namespace'] = Uuid::NAMESPACE_DNS;
Expand All @@ -107,8 +89,7 @@ public function it_can_generate_a_version_3_uuid()
Assert::assertSame(3, Uuid::fromString($code)->getVersion());
}

/** @test */
public function it_can_generate_a_version_4_uuid()
public function test_it_can_generate_a_version_4_uuid()
{
$this->app['config']['doorman.uuid.version'] = 4;

Expand All @@ -120,10 +101,7 @@ public function it_can_generate_a_version_4_uuid()
Assert::assertSame(4, Uuid::fromString($code)->getVersion());
}

/**
* @test
*/
public function namespace_is_required_for_version_5()
public function test_namespace_is_required_for_version_5()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Namespace must be set for uuid version 5');
Expand All @@ -136,10 +114,7 @@ public function namespace_is_required_for_version_5()
$driver->code();
}

/**
* @test
*/
public function name_is_required_for_version_5()
public function test_name_is_required_for_version_5()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Name must be set for uuid version 5');
Expand All @@ -152,9 +127,7 @@ public function name_is_required_for_version_5()
$driver->code();
}


/** @test */
public function it_can_generate_a_version_5_uuid()
public function test_it_can_generate_a_version_5_uuid()
{
$this->app['config']['doorman.uuid.version'] = 5;
$this->app['config']['doorman.uuid.namespace'] = Uuid::NAMESPACE_DNS;
Expand Down
Loading

0 comments on commit e94b6be

Please sign in to comment.