Skip to content

Commit 13146f4

Browse files
Merge pull request #1036 from ArlonHelps/aa/5.x-laravel-10
[5.x] Laravel 10 Support
2 parents 95813cc + b5fdb01 commit 13146f4

File tree

9 files changed

+68
-31
lines changed

9 files changed

+68
-31
lines changed

.circleci/config.yml

+43-12
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ references:
66
steps:
77
- checkout
88
- run: apt-get -yqq update
9-
- run: apt-get -yqq install git unzip zip libpq-dev default-mysql-client libpng-dev
9+
- run: apt-get -yqq install git unzip zip libpq-dev default-mysql-client libpng-dev postgresql
1010
- run: docker-php-ext-install pdo_pgsql pdo_mysql gd
1111
- run: curl -sS https://getcomposer.org/installer | php
1212
- run: chmod +x composer.phar
@@ -19,6 +19,7 @@ references:
1919
- run: mysql --host=mysql -e "grant all privileges on *.* to 'testing'@'%' with grant option;"
2020
- run: mysql --host=mariadb2 -e "grant all privileges on *.* to 'testing'@'%' with grant option;"
2121
- run: mysql --host=mysql2 -e "grant all privileges on *.* to 'testing'@'%' with grant option;"
22+
- run: PGPASSWORD=testing psql --host=pgsql --user=testing -c "GRANT ALL ON SCHEMA public TO testing;"
2223
- run: |
2324
if [[ "${CIRCLE_JOB}" == *-nginx ]]; then
2425
apt-get -yqq install nginx
@@ -54,14 +55,14 @@ references:
5455
name: mariadb2
5556
environment: *mysql_environment
5657
pgsql: &pgsql
57-
image: postgres:latest
58+
image: postgres:14
5859
name: pgsql
5960
environment:
6061
- POSTGRES_DB: testing
6162
- POSTGRES_USER: testing
6263
- POSTGRES_PASSWORD: testing
6364
pgsql2: &pgsql2
64-
image: postgres:latest
65+
image: postgres:14
6566
name: pgsql2
6667
environment:
6768
- POSTGRES_DB: testing
@@ -74,9 +75,20 @@ references:
7475
- APP_KEY: deela5kinohw0haekoothahSh8eexach
7576

7677
jobs:
77-
"php-8.0-apache":
78+
"php-8.1-apache":
79+
docker:
80+
- image: php:8.1-apache
81+
environment: *environment
82+
- *mysql
83+
- *mariadb
84+
- *pgsql
85+
- *mysql2
86+
- *mariadb2
87+
- *pgsql2
88+
<<: *steps
89+
"php-8.1-nginx":
7890
docker:
79-
- image: php:8.0-apache
91+
- image: php:8.1-fpm
8092
environment: *environment
8193
- *mysql
8294
- *mariadb
@@ -85,9 +97,20 @@ jobs:
8597
- *mariadb2
8698
- *pgsql2
8799
<<: *steps
88-
"php-8.0-nginx":
100+
"php-8.2-apache":
89101
docker:
90-
- image: php:8.0-fpm
102+
- image: php:8.2-apache
103+
environment: *environment
104+
- *mysql
105+
- *mariadb
106+
- *pgsql
107+
- *mysql2
108+
- *mariadb2
109+
- *pgsql2
110+
<<: *steps
111+
"php-8.2-nginx":
112+
docker:
113+
- image: php:8.2-fpm
91114
environment: *environment
92115
- *mysql
93116
- *mariadb
@@ -98,7 +121,7 @@ jobs:
98121
<<: *steps
99122
coverage:
100123
docker:
101-
- image: php:8.0-fpm
124+
- image: php:8.1-fpm
102125
environment: *environment
103126
- *mariadb
104127
- *mariadb2
@@ -127,12 +150,20 @@ workflows:
127150
version: 2
128151
test:
129152
jobs:
130-
- "php-8.0-apache"
131-
- "php-8.0-nginx"
153+
- "php-8.1-apache"
154+
- "php-8.1-nginx":
155+
requires:
156+
- "php-8.1-apache"
157+
- "php-8.2-apache":
158+
requires:
159+
- "php-8.1-nginx"
160+
- "php-8.2-nginx":
161+
requires:
162+
- "php-8.2-apache"
132163
- coverage:
133164
filters:
134165
branches:
135166
only: /^([0-9]+)\.x$/
136167
requires:
137-
- "php-8.0-apache"
138-
- "php-8.0-nginx"
168+
- "php-8.1-apache"
169+
- "php-8.1-nginx"

ci.phpunit.xml

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
<env name="APP_ENV" value="testing"/>
2828
<env name="APP_KEY" value="Phei9thoong3ai8aqu4ieHie6kee1zee"/>
2929
<env name="DB_DATABASE" value="testing"/>
30-
<env name="DB_PASSWORD" value="root"/>
31-
<env name="DB_USERNAME" value="root"/>
3230
<env name="IN_CI" value="1"/>
3331
<env name="LIMIT_UUID_LENGTH_32" value="1"/>
3432
<env name="MAIL_MAILER" value="log"/>

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626
"php": "^8.0",
2727
"doctrine/dbal": "~2.5|~3.0",
2828
"ramsey/uuid": "^4.0",
29-
"laravel/framework": "^9.0"
29+
"laravel/framework": "^10.0"
3030
},
3131
"require-dev": {
3232
"fakerphp/faker": "^1.12",
33-
"laravel/laravel": "^9.0",
33+
"laravel/laravel": "^10.0",
3434
"mockery/mockery": "^1.0",
3535
"phpunit/phpunit": "^9.0",
3636
"symfony/dom-crawler": "~3.1"

src/Middleware/HostnameActions.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use Hyn\Tenancy\Events\Hostnames\Secured;
2323
use Hyn\Tenancy\Events\Hostnames\UnderMaintenance;
2424
use Hyn\Tenancy\Traits\DispatchesEvents;
25-
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
2625
use Illuminate\Http\RedirectResponse;
2726
use Illuminate\Http\Request;
2827
use Illuminate\Routing\Redirector;
@@ -104,7 +103,12 @@ protected function secure(Hostname $hostname, Request $request)
104103
protected function maintenance(Hostname $hostname)
105104
{
106105
$this->emitEvent(new UnderMaintenance($hostname));
107-
throw new MaintenanceModeException($hostname->under_maintenance_since->timestamp, null, "");
106+
107+
throw new \Symfony\Component\HttpKernel\Exception\HttpException(
108+
503,
109+
'Service Unavailable',
110+
null
111+
);
108112
}
109113

110114
/**

src/Models/Hostname.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ class Hostname extends SystemModel implements HostnameContract
3636
{
3737
use SoftDeletes;
3838

39-
protected $dates = ['under_maintenance_since'];
39+
protected $casts = [
40+
'under_maintenance_since' => 'datetime',
41+
];
4042

4143
public function website(): BelongsTo
4244
{

tests/unit-tests/Filesystem/LoadsTranslationsTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ protected function duringSetUp(Application $app)
3232

3333
$this->directory = $app->make(Directory::class);
3434
$this->directory->setWebsite($this->website);
35+
36+
$this->artisan('lang:publish');
3537
}
3638

3739
/**

tests/unit-tests/Middleware/HostnameActionsTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
use Hyn\Tenancy\Middleware\HostnameActions;
2222
use Hyn\Tenancy\Tests\Test;
2323
use Illuminate\Contracts\Foundation\Application;
24-
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
2524
use Illuminate\Http\Request;
2625
use Illuminate\Routing\Redirector;
2726
use Illuminate\Support\Carbon;
27+
use Symfony\Component\HttpKernel\Exception\HttpException;
2828
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
2929

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

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

5050
$this->hostname->under_maintenance_since = null;

tests/unit-tests/Queue/TenantAwareJobTest.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -102,50 +102,50 @@ public function current_website_id_is_included_in_notification_job_payload()
102102
}
103103

104104
/** @test */
105-
public function dispatch_now_without_identified()
105+
public function dispatch_sync_without_identified()
106106
{
107107
$job = new TestJob();
108-
dispatch_now($job);
108+
dispatch_sync($job);
109109

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

113113
/** @test */
114-
public function dispatch_now_overrides_without_identified()
114+
public function dispatch_sync_overrides_without_identified()
115115
{
116116
$second = new Website;
117117
$this->websites->create($second);
118118

119119
$id = $second->id;
120120
$job = new TestJob($id);
121-
dispatch_now($job);
121+
dispatch_sync($job);
122122

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

126126
/** @test */
127-
public function dispatch_now_identified()
127+
public function dispatch_sync_identified()
128128
{
129129
$this->activateTenant();
130130

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

133133
$job = new TestJob();
134-
dispatch_now($job);
134+
dispatch_sync($job);
135135

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

139139
/** @test */
140-
public function dispatch_now_overrides_identified()
140+
public function dispatch_sync_overrides_identified()
141141
{
142142
$second = new Website;
143143
$this->websites->create($second);
144144
$this->activateTenant();
145145

146146
$id = $second->id;
147147
$job = new TestJob($id);
148-
dispatch_now($job);
148+
dispatch_sync($job);
149149

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

tests/unit-tests/Repositories/HostnameRepositoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function hostname_regex_validation()
149149
try {
150150
$this->hostnames->create($this->hostname);
151151
} catch (ModelValidationException $e) {
152-
$this->assertStringContainsString("The fqdn format is invalid.", $e->getMessage());
152+
$this->assertStringContainsString("The fqdn field format is invalid.", $e->getMessage());
153153
}
154154
}
155155
}

0 commit comments

Comments
 (0)