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

Added support for Laravel 11 #239

Merged
merged 9 commits into from
Mar 11, 2024
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
8 changes: 7 additions & 1 deletion .github/workflows/ci-phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,21 @@ jobs:
fail-fast: false
matrix:
php: [8.0, 8.1, 8.2, 8.3]
laravel: [9.*, 10.*]
laravel: [9.*, 10.*, 11.*]
include:
- laravel: 11.*
testbench: 9.*
- laravel: 10.*
testbench: 8.*
- laravel: 9.*
testbench: 7.*
exclude:
- laravel: 10.*
php: 8.0
- laravel: 11.*
php: 8.0
- laravel: 11.*
php: 8.1

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

Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ jobs:
fail-fast: false
matrix:
php: [8.0, 8.1, 8.2, 8.3]
laravel: [8.*, 9.*, 10.*]
laravel: [8.*, 9.*, 10.*, 11.*]
include:
- laravel: 11.*
testbench: 9.*
- laravel: 10.*
testbench: 8.*
- laravel: 9.*
Expand All @@ -21,6 +23,10 @@ jobs:
exclude:
- laravel: 10.*
php: 8.0
- laravel: 11.*
php: 8.0
- laravel: 11.*
php: 8.1

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

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
"require": {
"php": "^8.0",
"nesbot/carbon": "~2.0",
"illuminate/container": "^8.0|^9.0|^10.0",
"illuminate/database": "^8.0|^9.0|^10.0",
"illuminate/container": "^8.0|^9.0|^10.0|^11.0",
"illuminate/database": "^8.0|^9.0|^10.0|^11.0",
"jenssegers/agent": "^2.6",
"hashids/hashids": "^4.0|^5.0"
},
"require-dev": {
"mockery/mockery": "^1.0",
"orchestra/testbench": "^6.0|^7.0|^8.0",
"phpunit/phpunit": "^8.2 || ^9.0",
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0",
"phpunit/phpunit": "^8.2|^9.0|^10.0",
"nunomaduro/larastan": "^0.7.12 || ^1.0.0 || ^2.0"
},
"autoload": {
Expand Down
4 changes: 3 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
</php>
</phpunit>
</phpunit>
2 changes: 1 addition & 1 deletion src/Models/ShortURL.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ShortURL extends Model
/**
* The attributes that are mass assignable.
*
* @var string[]
* @var array<int,string>
*/
protected $fillable = [
'destination_url',
Expand Down
2 changes: 1 addition & 1 deletion src/Models/ShortURLVisit.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ShortURLVisit extends Model
/**
* The attributes that are mass assignable.
*
* @var string[]
* @var array<int,string>
*/
protected $fillable = [
'short_url_id',
Expand Down
5 changes: 5 additions & 0 deletions testbench.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
migrations:
- database/migrations

workbench:
install: false
3 changes: 0 additions & 3 deletions tests/Unit/Classes/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
use AshAllenDesign\ShortURL\Exceptions\ValidationException;
use AshAllenDesign\ShortURL\Models\ShortURL;
use AshAllenDesign\ShortURL\Tests\Unit\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Config;
use ShortURL as ShortURLAlias;

class BuilderTest extends TestCase
{
use RefreshDatabase;

protected function setUp(): void
{
parent::setUp();
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Classes/ResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use AshAllenDesign\ShortURL\Models\ShortURL;
use AshAllenDesign\ShortURL\Models\ShortURLVisit;
use AshAllenDesign\ShortURL\Tests\Unit\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Config;
use Jenssegers\Agent\Agent;
Expand All @@ -16,8 +15,6 @@

class ResolverTest extends TestCase
{
use RefreshDatabase;

/** @test */
public function exception_is_thrown_in_the_constructor_if_the_config_variables_are_invalid()
{
Expand Down
5 changes: 1 addition & 4 deletions tests/Unit/Controllers/ShortURLControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
use AshAllenDesign\ShortURL\Models\ShortURL;
use AshAllenDesign\ShortURL\Models\ShortURLVisit;
use AshAllenDesign\ShortURL\Tests\Unit\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Event;

class ShortURLControllerTest extends TestCase
{
use RefreshDatabase;

/** @test */
public function request_is_aborted_with_http_404_if_the_short_url_cannot_be_found()
{
Expand Down Expand Up @@ -184,7 +181,7 @@ public function visitor_is_redirected_to_the_destination_with_source_query_param
$this->get($requestUrl)->assertStatus(301)->assertRedirect($expectedDestinationUrl);
}

public function forwardQueryParamsProvider(): array
public static function forwardQueryParamsProvider(): array
{
return [
[
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Controllers/ShortURLDisableRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@

use AshAllenDesign\ShortURL\Models\ShortURL;
use AshAllenDesign\ShortURL\Tests\Unit\TestCase;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;

class ShortURLDisableRouteTest extends TestCase
{
use LazilyRefreshDatabase;

protected function getEnvironmentSetUp($app)
{
$app['config']->set('short-url.disable_default_route', true);
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Models/ShortURL/CastsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
use AshAllenDesign\ShortURL\Models\ShortURL;
use AshAllenDesign\ShortURL\Tests\Unit\TestCase;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;

final class CastsTest extends TestCase
{
use LazilyRefreshDatabase;

/** @test */
public function carbon_date_objects_are_returned(): void
{
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Models/ShortURL/ShortURLFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@

use AshAllenDesign\ShortURL\Models\ShortURL;
use AshAllenDesign\ShortURL\Tests\Unit\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

class ShortURLFactoryTest extends TestCase
{
use RefreshDatabase;

public function test_that_the_short_url_model_factory_works_fine()
{
$shortURL = ShortURL::factory()->create();
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Models/ShortURL/ShortURLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@

use AshAllenDesign\ShortURL\Models\ShortURL;
use AshAllenDesign\ShortURL\Tests\Unit\TestCase;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;

final class ShortURLTest extends TestCase
{
use LazilyRefreshDatabase;

/** @test */
public function connection_can_be_overridden(): void
{
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Models/ShortURL/TrackingEnabledTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@

use AshAllenDesign\ShortURL\Models\ShortURL;
use AshAllenDesign\ShortURL\Tests\Unit\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

class TrackingEnabledTest extends TestCase
{
use RefreshDatabase;

/** @test */
public function true_is_returned_if_tracking_is_enabled_for_the_short_url()
{
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Models/ShortURL/TrackingFieldsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@

use AshAllenDesign\ShortURL\Models\ShortURL;
use AshAllenDesign\ShortURL\Tests\Unit\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

class TrackingFieldsTest extends TestCase
{
use RefreshDatabase;

/** @test */
public function array_is_returned_with_tracked_fields()
{
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Models/ShortURLVisit/CastsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
use AshAllenDesign\ShortURL\Models\ShortURLVisit;
use AshAllenDesign\ShortURL\Tests\Unit\TestCase;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;

final class CastsTest extends TestCase
{
use LazilyRefreshDatabase;

/** @test */
public function carbon_date_objects_are_returned(): void
{
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Models/ShortURLVisit/ShortURLTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
use AshAllenDesign\ShortURL\Models\ShortURL;
use AshAllenDesign\ShortURL\Models\ShortURLVisit;
use AshAllenDesign\ShortURL\Tests\Unit\TestCase;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;

class ShortURLTest extends TestCase
{
use LazilyRefreshDatabase;

/** @test */
public function short_url_can_be_fetched_from_visit(): void
{
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Models/ShortURLVisit/ShortURLVisitFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
use AshAllenDesign\ShortURL\Models\ShortURL;
use AshAllenDesign\ShortURL\Models\ShortURLVisit;
use AshAllenDesign\ShortURL\Tests\Unit\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

class ShortURLVisitFactoryTest extends TestCase
{
use RefreshDatabase;

/** @test */
public function test_that_short_url_visit_model_factory_works_fine(): void
{
Expand Down
3 changes: 0 additions & 3 deletions tests/Unit/Models/ShortURLVisit/ShortURLVisitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@

use AshAllenDesign\ShortURL\Models\ShortURLVisit;
use AshAllenDesign\ShortURL\Tests\Unit\TestCase;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;

final class ShortURLVisitTest extends TestCase
{
use LazilyRefreshDatabase;

/** @test */
public function connection_can_be_overridden(): void
{
Expand Down
45 changes: 5 additions & 40 deletions tests/Unit/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@

use AshAllenDesign\ShortURL\Facades\ShortURL;
use AshAllenDesign\ShortURL\Providers\ShortURLProvider;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Orchestra\Testbench\Concerns\WithWorkbench;
use Orchestra\Testbench\TestCase as OrchestraTestCase;

abstract class TestCase extends OrchestraTestCase
{
use LazilyRefreshDatabase;
use WithWorkbench;

/**
* Load package service provider.
*
Expand All @@ -32,43 +36,4 @@ protected function getPackageAliases($app)
'ShortURL' => ShortURL::class,
];
}

/**
* Define environment setup.
*
* @param Application $app
* @return void
*/
protected function getEnvironmentSetUp($app)
{
$app['config']->set('database.default', 'testdb');
$app['config']->set('database.connections.testdb', [
'driver' => 'sqlite',
'database' => ':memory:',
]);

$this->migrateDatabase();
}

/**
* Include each of the migrations and migrate them to
* finish preparing the database for running the
* tests.
*/
private function migrateDatabase(): void
{
include_once __DIR__.'/../../database/migrations/2019_12_22_015115_create_short_urls_table.php';
include_once __DIR__.'/../../database/migrations/2019_12_22_015214_create_short_url_visits_table.php';
include_once __DIR__.'/../../database/migrations/2020_02_11_224848_update_short_url_table_for_version_two_zero_zero.php';
include_once __DIR__.'/../../database/migrations/2020_02_12_008432_update_short_url_visits_table_for_version_two_zero_zero.php';
include_once __DIR__.'/../../database/migrations/2020_04_10_224546_update_short_url_table_for_version_three_zero_zero.php';
include_once __DIR__.'/../../database/migrations/2020_04_20_009283_update_short_url_table_add_option_to_forward_query_params.php';

(new \CreateShortUrlsTable)->up();
(new \CreateShortUrlVisitsTable)->up();
(new \UpdateShortURLTableForVersionTwoZeroZero)->up();
(new \UpdateShortURLVisitsTableForVersionTwoZeroZero)->up();
(new \UpdateShortURLTableForVersionThreeZeroZero)->up();
(new \UpdateShortUrlTableAddOptionToForwardQueryParams)->up();
}
}
Loading