Skip to content

Commit

Permalink
Merge pull request #1036 from ArlonHelps/aa/5.x-laravel-10
Browse files Browse the repository at this point in the history
[5.x] Laravel 10 Support
  • Loading branch information
ArlonAntonius authored Jul 11, 2023
2 parents 95813cc + b5fdb01 commit 13146f4
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 31 deletions.
55 changes: 43 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ references:
steps:
- checkout
- run: apt-get -yqq update
- run: apt-get -yqq install git unzip zip libpq-dev default-mysql-client libpng-dev
- run: apt-get -yqq install git unzip zip libpq-dev default-mysql-client libpng-dev postgresql
- run: docker-php-ext-install pdo_pgsql pdo_mysql gd
- run: curl -sS https://getcomposer.org/installer | php
- run: chmod +x composer.phar
Expand All @@ -19,6 +19,7 @@ references:
- run: mysql --host=mysql -e "grant all privileges on *.* to 'testing'@'%' with grant option;"
- run: mysql --host=mariadb2 -e "grant all privileges on *.* to 'testing'@'%' with grant option;"
- run: mysql --host=mysql2 -e "grant all privileges on *.* to 'testing'@'%' with grant option;"
- run: PGPASSWORD=testing psql --host=pgsql --user=testing -c "GRANT ALL ON SCHEMA public TO testing;"
- run: |
if [[ "${CIRCLE_JOB}" == *-nginx ]]; then
apt-get -yqq install nginx
Expand Down Expand Up @@ -54,14 +55,14 @@ references:
name: mariadb2
environment: *mysql_environment
pgsql: &pgsql
image: postgres:latest
image: postgres:14
name: pgsql
environment:
- POSTGRES_DB: testing
- POSTGRES_USER: testing
- POSTGRES_PASSWORD: testing
pgsql2: &pgsql2
image: postgres:latest
image: postgres:14
name: pgsql2
environment:
- POSTGRES_DB: testing
Expand All @@ -74,9 +75,20 @@ references:
- APP_KEY: deela5kinohw0haekoothahSh8eexach

jobs:
"php-8.0-apache":
"php-8.1-apache":
docker:
- image: php:8.1-apache
environment: *environment
- *mysql
- *mariadb
- *pgsql
- *mysql2
- *mariadb2
- *pgsql2
<<: *steps
"php-8.1-nginx":
docker:
- image: php:8.0-apache
- image: php:8.1-fpm
environment: *environment
- *mysql
- *mariadb
Expand All @@ -85,9 +97,20 @@ jobs:
- *mariadb2
- *pgsql2
<<: *steps
"php-8.0-nginx":
"php-8.2-apache":
docker:
- image: php:8.0-fpm
- image: php:8.2-apache
environment: *environment
- *mysql
- *mariadb
- *pgsql
- *mysql2
- *mariadb2
- *pgsql2
<<: *steps
"php-8.2-nginx":
docker:
- image: php:8.2-fpm
environment: *environment
- *mysql
- *mariadb
Expand All @@ -98,7 +121,7 @@ jobs:
<<: *steps
coverage:
docker:
- image: php:8.0-fpm
- image: php:8.1-fpm
environment: *environment
- *mariadb
- *mariadb2
Expand Down Expand Up @@ -127,12 +150,20 @@ workflows:
version: 2
test:
jobs:
- "php-8.0-apache"
- "php-8.0-nginx"
- "php-8.1-apache"
- "php-8.1-nginx":
requires:
- "php-8.1-apache"
- "php-8.2-apache":
requires:
- "php-8.1-nginx"
- "php-8.2-nginx":
requires:
- "php-8.2-apache"
- coverage:
filters:
branches:
only: /^([0-9]+)\.x$/
requires:
- "php-8.0-apache"
- "php-8.0-nginx"
- "php-8.1-apache"
- "php-8.1-nginx"
2 changes: 0 additions & 2 deletions ci.phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="Phei9thoong3ai8aqu4ieHie6kee1zee"/>
<env name="DB_DATABASE" value="testing"/>
<env name="DB_PASSWORD" value="root"/>
<env name="DB_USERNAME" value="root"/>
<env name="IN_CI" value="1"/>
<env name="LIMIT_UUID_LENGTH_32" value="1"/>
<env name="MAIL_MAILER" value="log"/>
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
"php": "^8.0",
"doctrine/dbal": "~2.5|~3.0",
"ramsey/uuid": "^4.0",
"laravel/framework": "^9.0"
"laravel/framework": "^10.0"
},
"require-dev": {
"fakerphp/faker": "^1.12",
"laravel/laravel": "^9.0",
"laravel/laravel": "^10.0",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^9.0",
"symfony/dom-crawler": "~3.1"
Expand Down
8 changes: 6 additions & 2 deletions src/Middleware/HostnameActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use Hyn\Tenancy\Events\Hostnames\Secured;
use Hyn\Tenancy\Events\Hostnames\UnderMaintenance;
use Hyn\Tenancy\Traits\DispatchesEvents;
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
Expand Down Expand Up @@ -104,7 +103,12 @@ protected function secure(Hostname $hostname, Request $request)
protected function maintenance(Hostname $hostname)
{
$this->emitEvent(new UnderMaintenance($hostname));
throw new MaintenanceModeException($hostname->under_maintenance_since->timestamp, null, "");

throw new \Symfony\Component\HttpKernel\Exception\HttpException(
503,
'Service Unavailable',
null
);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Models/Hostname.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class Hostname extends SystemModel implements HostnameContract
{
use SoftDeletes;

protected $dates = ['under_maintenance_since'];
protected $casts = [
'under_maintenance_since' => 'datetime',
];

public function website(): BelongsTo
{
Expand Down
2 changes: 2 additions & 0 deletions tests/unit-tests/Filesystem/LoadsTranslationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ protected function duringSetUp(Application $app)

$this->directory = $app->make(Directory::class);
$this->directory->setWebsite($this->website);

$this->artisan('lang:publish');
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/unit-tests/Middleware/HostnameActionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
use Hyn\Tenancy\Middleware\HostnameActions;
use Hyn\Tenancy\Tests\Test;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use Illuminate\Support\Carbon;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class HostnameActionsTest extends Test
Expand All @@ -43,8 +43,8 @@ public function under_maintenance()
$this->middleware($this->hostname);

$this->fail('Middleware didn\'t fire maintenance exception');
} catch (MaintenanceModeException $e) {
$this->assertEquals($e->wentDownAt->timestamp, $this->hostname->under_maintenance_since->timestamp);
} catch (HttpException $e) {
$this->assertEquals(503, $e->getStatusCode());
}

$this->hostname->under_maintenance_since = null;
Expand Down
16 changes: 8 additions & 8 deletions tests/unit-tests/Queue/TenantAwareJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,50 +102,50 @@ public function current_website_id_is_included_in_notification_job_payload()
}

/** @test */
public function dispatch_now_without_identified()
public function dispatch_sync_without_identified()
{
$job = new TestJob();
dispatch_now($job);
dispatch_sync($job);

$this->assertNull(resolve(Environment::class)->tenant());
}

/** @test */
public function dispatch_now_overrides_without_identified()
public function dispatch_sync_overrides_without_identified()
{
$second = new Website;
$this->websites->create($second);

$id = $second->id;
$job = new TestJob($id);
dispatch_now($job);
dispatch_sync($job);

$this->assertEquals($id, resolve(Environment::class)->tenant()->id);
}

/** @test */
public function dispatch_now_identified()
public function dispatch_sync_identified()
{
$this->activateTenant();

$id = resolve(Environment::class)->tenant()->id;

$job = new TestJob();
dispatch_now($job);
dispatch_sync($job);

$this->assertEquals($id, resolve(Environment::class)->tenant()->id);
}

/** @test */
public function dispatch_now_overrides_identified()
public function dispatch_sync_overrides_identified()
{
$second = new Website;
$this->websites->create($second);
$this->activateTenant();

$id = $second->id;
$job = new TestJob($id);
dispatch_now($job);
dispatch_sync($job);

$this->assertEquals($id, resolve(Environment::class)->tenant()->id);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-tests/Repositories/HostnameRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function hostname_regex_validation()
try {
$this->hostnames->create($this->hostname);
} catch (ModelValidationException $e) {
$this->assertStringContainsString("The fqdn format is invalid.", $e->getMessage());
$this->assertStringContainsString("The fqdn field format is invalid.", $e->getMessage());
}
}
}
Expand Down

0 comments on commit 13146f4

Please sign in to comment.