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

[5.x] Laravel 10 Support #1036

Merged
merged 17 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 12 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
21 changes: 11 additions & 10 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 @@ -74,9 +75,9 @@ references:
- APP_KEY: deela5kinohw0haekoothahSh8eexach

jobs:
"php-8.0-apache":
"php-8.1-apache":
docker:
- image: php:8.0-apache
- image: php:8.1-apache
environment: *environment
- *mysql
- *mariadb
Expand All @@ -85,9 +86,9 @@ jobs:
- *mariadb2
- *pgsql2
<<: *steps
"php-8.0-nginx":
"php-8.1-nginx":
docker:
- image: php:8.0-fpm
- image: php:8.1-fpm
environment: *environment
- *mysql
- *mariadb
Expand All @@ -98,7 +99,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 +128,12 @@ workflows:
version: 2
test:
jobs:
- "php-8.0-apache"
- "php-8.0-nginx"
- "php-8.1-apache"
- "php-8.1-nginx"
- 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
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