Skip to content

Commit

Permalink
Support Laravel 11
Browse files Browse the repository at this point in the history
  • Loading branch information
Propaganistas committed Mar 12, 2024
1 parent 51f3b47 commit 46579d7
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 57 deletions.
18 changes: 8 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ 8.0, 8.1, 8.2, 8.3 ]
laravel: [ 8, 9, 10 ]
php: [ 8.1, 8.2, 8.3 ]
laravel: [ 10, 11 ]
stability: [ prefer-lowest, prefer-stable ]
exclude:
- php: 8.0
laravel: 10
- php: 8.1
laravel: 11

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} (${{ matrix.stability }})

Expand All @@ -34,11 +34,6 @@ jobs:
tools: composer:v2
coverage: none

- name: Patch testbench version
if: matrix.laravel == 8
run: |
composer require "orchestra/testbench=^6.23" --dev --no-interaction --no-update
# https://github.com/briannesbitt/Carbon/releases/tag/2.62.1
- name: Patch Carbon version
if: matrix.php == 8.2 || matrix.php == 8.3
Expand All @@ -51,4 +46,7 @@ jobs:
composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress
- name: Execute tests
run: vendor/bin/phpunit --verbose
run: vendor/bin/phpunit

- name: Run phpstan
run: vendor/bin/phpstan analyse --error-format=github
18 changes: 10 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@
}
],
"require": {
"php": "^8.0",
"php": "^8.1",
"ext-json": "*",
"illuminate/cache": "^8.0|^9.0|^10.0",
"illuminate/config": "^8.0|^9.0|^10.0",
"illuminate/contracts": "^8.0|^9.0|^10.0",
"illuminate/support": "^8.0|^9.0|^10.0",
"illuminate/console": "^8.0|^9.0|^10.0",
"illuminate/validation": "^8.0|^9.0|^10.0"
"illuminate/cache": "^10.0|^11.0",
"illuminate/config": "^10.0|^11.0",
"illuminate/contracts": "^10.0|^11.0",
"illuminate/support": "^10.0|^11.0",
"illuminate/console": "^10.0|^11.0",
"illuminate/validation": "^10.0|^11.0"
},
"require-dev": {
"mockery/mockery": "^1.4.2",
"orchestra/testbench": "*",
"phpunit/phpunit": "^9.5.10"
"phpunit/phpunit": "^10.5",
"larastan/larastan": "^2.9",
"laravel/pint": "^1.14"
},
"autoload": {
"psr-4": {
Expand Down
12 changes: 12 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
includes:
- ./vendor/larastan/larastan/extension.neon

parameters:

paths:
- src

# 8 is the highest level
level: 5

checkMissingIterableValueType: false
23 changes: 10 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
<directory suffix=".php">tests</directory>
<exclude>tests/TestCase.php</exclude>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<source>
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
Empty file removed tests/.gitkeep
Empty file.
13 changes: 7 additions & 6 deletions tests/Console/UpdateDisposableDomainsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
namespace Propaganistas\LaravelDisposableEmail\Tests\Console;

use InvalidArgumentException;
use PHPUnit\Framework\Attributes\Test;
use Propaganistas\LaravelDisposableEmail\Contracts\Fetcher;
use Propaganistas\LaravelDisposableEmail\Tests\TestCase;

class UpdateDisposableDomainsCommandTest extends TestCase
{
/** @test */
#[Test]
public function it_creates_the_file()
{
$this->assertFileDoesNotExist($this->storagePath);
Expand All @@ -24,7 +25,7 @@ public function it_creates_the_file()
$this->assertContains('yopmail.com', $domains);
}

/** @test */
#[Test]
public function it_overwrites_the_file()
{
file_put_contents($this->storagePath, json_encode(['foo']));
Expand All @@ -41,7 +42,7 @@ public function it_overwrites_the_file()
$this->assertNotContains('foo', $domains);
}

/** @test */
#[Test]
public function it_doesnt_overwrite_on_fetch_failure()
{
$this->expectException(InvalidArgumentException::class);
Expand All @@ -60,7 +61,7 @@ public function it_doesnt_overwrite_on_fetch_failure()
$this->assertEquals(['foo'], $domains);
}

/** @test */
#[Test]
public function it_can_use_a_custom_fetcher()
{
file_put_contents($this->storagePath, json_encode(['foo']));
Expand All @@ -77,7 +78,7 @@ public function it_can_use_a_custom_fetcher()
$this->assertEquals(['bar'], $domains);
}

/** @test */
#[Test]
public function custom_fetchers_need_fetcher_contract()
{
file_put_contents($this->storagePath, json_encode(['foo']));
Expand All @@ -94,7 +95,7 @@ public function custom_fetchers_need_fetcher_contract()
$this->assertNotEquals(['foo'], $domains);
}

/** @test */
#[Test]
public function it_processes_legacy_source_config()
{
file_put_contents($this->storagePath, json_encode(['foo']));
Expand Down
35 changes: 18 additions & 17 deletions tests/DisposableDomainsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@

namespace Propaganistas\LaravelDisposableEmail\Tests;

use PHPUnit\Framework\Attributes\Test;
use Propaganistas\LaravelDisposableEmail\DisposableDomains;

class DisposableDomainsTest extends TestCase
{
/** @test */
#[Test]
public function it_can_be_resolved_using_alias()
{
$this->assertEquals(DisposableDomains::class, get_class($this->app->make('disposable_email.domains')));
}

/** @test */
#[Test]
public function it_can_be_resolved_using_class()
{
$this->assertEquals(DisposableDomains::class, get_class($this->app->make(DisposableDomains::class)));
}

/** @test */
#[Test]
public function it_can_get_storage_path()
{
$this->assertEquals(
Expand All @@ -27,15 +28,15 @@ public function it_can_get_storage_path()
);
}

/** @test */
#[Test]
public function it_can_set_storage_path()
{
$this->disposable()->setStoragePath('foo');

$this->assertEquals('foo', $this->disposable()->getStoragePath());
}

/** @test */
#[Test]
public function it_can_get_cache_key()
{
$this->assertEquals(
Expand All @@ -44,15 +45,15 @@ public function it_can_get_cache_key()
);
}

/** @test */
#[Test]
public function it_can_set_cache_key()
{
$this->disposable()->setCacheKey('foo');

$this->assertEquals('foo', $this->disposable()->getCacheKey());
}

/** @test */
#[Test]
public function it_takes_cached_domains_if_available()
{
$this->app['cache.store'][$this->disposable()->getCacheKey()] = ['foo'];
Expand All @@ -64,7 +65,7 @@ public function it_takes_cached_domains_if_available()
$this->assertEquals(['foo'], $domains);
}

/** @test */
#[Test]
public function it_flushes_invalid_cache_values()
{
$this->app['cache.store'][$this->disposable()->getCacheKey()] = 'foo';
Expand All @@ -74,7 +75,7 @@ public function it_flushes_invalid_cache_values()
$this->assertNotEquals('foo', $this->app['cache.store'][$this->disposable()->getCacheKey()]);
}

/** @test */
#[Test]
public function it_skips_cache_when_configured()
{
$this->app['config']['disposable-email.cache.enabled'] = false;
Expand All @@ -86,7 +87,7 @@ public function it_skips_cache_when_configured()
$this->assertContains('yopmail.com', $domains);
}

/** @test */
#[Test]
public function it_takes_storage_domains_when_cache_is_not_available()
{
$this->app['config']['disposable-email.cache.enabled'] = false;
Expand All @@ -100,7 +101,7 @@ public function it_takes_storage_domains_when_cache_is_not_available()
$this->assertEquals(['foo'], $domains);
}

/** @test */
#[Test]
public function it_takes_package_domains_when_storage_is_not_available()
{
$this->app['config']['disposable-email.cache.enabled'] = false;
Expand All @@ -111,7 +112,7 @@ public function it_takes_package_domains_when_storage_is_not_available()
$this->assertContains('yopmail.com', $domains);
}

/** @test */
#[Test]
public function it_can_flush_storage()
{
file_put_contents($this->storagePath, 'foo');
Expand All @@ -121,15 +122,15 @@ public function it_can_flush_storage()
$this->assertFileDoesNotExist($this->storagePath);
}

/** @test */
#[Test]
public function it_doesnt_throw_exceptions_for_flush_storage_when_file_doesnt_exist()
{
$this->disposable()->flushStorage();

$this->assertTrue(true);
}

/** @test */
#[Test]
public function it_can_flush_cache()
{
$this->app['cache.store'][$this->disposable()->getCacheKey()] = 'foo';
Expand All @@ -141,7 +142,7 @@ public function it_can_flush_cache()
$this->assertNull($this->app['cache']->get($this->disposable()->getCacheKey()));
}

/** @test */
#[Test]
public function it_can_verify_disposability()
{
$this->assertTrue($this->disposable()->isDisposable('[email protected]'));
Expand All @@ -153,15 +154,15 @@ public function it_can_verify_disposability()
$this->assertTrue($this->disposable()->isIndisposable('[email protected]'));
}

/** @test */
#[Test]
public function it_checks_the_full_email_domain()
{
$this->assertTrue($this->disposable()->isDisposable('[email protected]'));
$this->assertTrue($this->disposable()->isDisposable('[email protected]'));
$this->assertTrue($this->disposable()->isNotDisposable('[email protected]'));
}

/** @test */
#[Test]
public function it_can_exclude_whitelisted_domains()
{
$this->disposable()->setWhitelist(['yopmail.com']);
Expand Down
7 changes: 4 additions & 3 deletions tests/Validation/IndisposableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

namespace Propaganistas\LaravelDisposableEmail\Tests\Validation;

use PHPUnit\Framework\Attributes\Test;
use Propaganistas\LaravelDisposableEmail\Tests\TestCase;
use Propaganistas\LaravelDisposableEmail\Validation\Indisposable;

class IndisposableTest extends TestCase
{
/** @test */
#[Test]
public function it_should_pass_for_indisposable_emails()
{
$validator = new Indisposable;
Expand All @@ -16,7 +17,7 @@ public function it_should_pass_for_indisposable_emails()
$this->assertTrue($validator->validate(null, $email, null, null));
}

/** @test */
#[Test]
public function it_should_fail_for_disposable_emails()
{
$validator = new Indisposable;
Expand All @@ -25,7 +26,7 @@ public function it_should_fail_for_disposable_emails()
$this->assertFalse($validator->validate(null, $email, null, null));
}

/** @test */
#[Test]
public function it_is_usable_through_the_validator()
{
$passingValidation = $this->app['validator']->make(['email' => '[email protected]'], ['email' => 'indisposable']);
Expand Down

0 comments on commit 46579d7

Please sign in to comment.