Skip to content

Commit 36f4371

Browse files
authored
Merge pull request #98 from ariaieboy/l11
Laravel 11 support
2 parents 3e3a432 + 1ce0c41 commit 36f4371

File tree

5 files changed

+41
-33
lines changed

5 files changed

+41
-33
lines changed

.github/workflows/psalm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: psalm
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v3
1515

1616
- name: Setup PHP
1717
uses: shivammathur/setup-php@v2

.github/workflows/tests.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,36 @@ jobs:
1010

1111
strategy:
1212
matrix:
13-
php: ['8.0', '8.1', '8.2']
14-
laravel: [9.*, 10.*]
13+
php: ['8.0', '8.1', '8.2', '8.3']
14+
laravel: [9.*, 10.*, 11.*]
1515
stability: [prefer-lowest, prefer-stable]
1616
include:
1717
- laravel: 9.*
1818
testbench: 7.*
1919
- laravel: 10.*
2020
testbench: 8.*
21+
- laravel: 11.*
22+
testbench: 9.*
2123
exclude:
24+
- laravel: 9.*
25+
php: 8.3
2226
- laravel: 10.*
2327
php: 8.0
28+
- laravel: 11.*
29+
php: 8.0
30+
- laravel: 11.*
31+
php: 8.1
2432

2533
steps:
2634
- name: Checkout code
27-
uses: actions/checkout@v2
35+
uses: actions/checkout@v3
2836

2937
- name: Setup PHP
3038
uses: shivammathur/setup-php@v2
3139
with:
3240
php-version: ${{ matrix.php }}
3341
extensions: bcmath, ctype, dom, fileinfo, intl, gd, json, mbstring, pdo, pdo_sqlite, openssl, sqlite, xml, zip
34-
coverage: none
42+
coverage: xdebug
3543

3644
- name: Install dependencies
3745
run: |

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
],
2020
"require": {
2121
"php": "^8.0",
22-
"illuminate/contracts": "^9.0|^10.0",
23-
"illuminate/support": "^9.0|^10.0",
24-
"illuminate/validation": "^9.0|^10.0",
25-
"illuminate/view": "^9.0|^10.0",
22+
"illuminate/contracts": "^9.0|^10.0|^11.0",
23+
"illuminate/support": "^9.0|^10.0|^11.0",
24+
"illuminate/validation": "^9.0|^10.0|^11.0",
25+
"illuminate/view": "^9.0|^10.0|^11.0",
2626
"vlucas/phpdotenv": "^5.4.1"
2727
},
2828
"require-dev": {
29-
"phpunit/phpunit": "^9.5|^10.0",
30-
"orchestra/testbench": "^7.4|^8.0",
31-
"vimeo/psalm": "^4.23"
29+
"phpunit/phpunit": "^9.5|^10.0|^11.0",
30+
"orchestra/testbench": "^7.4|^8.0|^9.0",
31+
"vimeo/psalm": "^4.23|^5.1"
3232
},
3333
"autoload": {
3434
"psr-4": {

tests/Casts/CurrencyCastTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,38 @@
1010

1111
class CurrencyCastTest extends TestCase
1212
{
13+
protected Model $model;
14+
protected function setUp():void
15+
{
16+
$this->model = $model = $this->getMockBuilder(Model::class)->disableOriginalConstructor()->getMock();
17+
}
1318
public function testItWillNotGetCurrencyFromNonStrings()
1419
{
1520
$this->expectException(UnexpectedValueException::class);
1621

17-
$model = $this->getMockBuilder(Model::class)->getMock();
18-
19-
(new CurrencyCast)->get($model, 'currency', 1, []);
22+
(new CurrencyCast)->get($this->model, 'currency', 1, []);
2023
}
2124

2225
public function testItWillNotSetCurrencyFromNonCurrencies()
2326
{
2427
$this->expectException(UnexpectedValueException::class);
2528

26-
$model = $this->getMockBuilder(Model::class)->getMock();
2729

28-
(new CurrencyCast)->set($model, 'currency', 'USD', []);
30+
(new CurrencyCast)->set($this->model, 'currency', 'USD', []);
2931
}
3032

3133
public function testItGetsCurrencyFromString()
3234
{
33-
$model = $this->getMockBuilder(Model::class)->getMock();
3435

35-
$value = (new CurrencyCast)->get($model, 'currency', 'USD', []);
36+
$value = (new CurrencyCast)->get($this->model, 'currency', 'USD', []);
3637

3738
$this->assertEquals(Currency::USD(), $value);
3839
}
3940

4041
public function testItSetsCurrencyAsString()
4142
{
42-
$mock = $this->getMockBuilder(Model::class)->getMock();
4343

44-
$value = (new CurrencyCast)->set($mock, 'currency', Currency::USD(), []);
44+
$value = (new CurrencyCast)->set($this->model, 'currency', Currency::USD(), []);
4545

4646
$this->assertSame('USD', $value);
4747
}

tests/Casts/MoneyCastTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,41 @@
1111

1212
class MoneyCastTest extends TestCase
1313
{
14+
protected Model $model;
15+
protected function setUp():void
16+
{
17+
$this->model = $model = $this->getMockBuilder(Model::class)->disableOriginalConstructor()->getMock();
18+
}
19+
1420
public function testItWillNotGetMoneyFromNonString()
1521
{
1622
$this->expectException(UnexpectedValueException::class);
1723

18-
$model = $this->getMockBuilder(Model::class)->getMock();
1924

20-
(new MoneyCast)->get($model, 'money', [], []);
25+
(new MoneyCast)->get($this->model, 'money', [], []);
2126
}
2227

2328
public function testItWillNotGetMoneyFromNonJson()
2429
{
2530
$this->expectException(UnexpectedValueException::class);
2631

27-
$model = $this->getMockBuilder(Model::class)->getMock();
2832

29-
(new MoneyCast)->get($model, 'money', 'testing', []);
33+
(new MoneyCast)->get($this->model, 'money', 'testing', []);
3034
}
3135

3236
public function testItWillNotGetMoneyFromIllFormedJson()
3337
{
3438
$this->expectException(UnexpectedValueException::class);
3539

36-
$model = $this->getMockBuilder(Model::class)->getMock();
3740

38-
(new MoneyCast)->get($model, 'money', '{"key":"value"}', []);
41+
(new MoneyCast)->get($this->model, 'money', '{"key":"value"}', []);
3942
}
4043

4144
public function testItGetsMoneyFromJson()
4245
{
43-
$model = $this->getMockBuilder(Model::class)->getMock();
4446
$json = '{"amount":1000,"currency":"USD"}';
4547

46-
$value = (new MoneyCast)->get($model, 'money', $json, []);
48+
$value = (new MoneyCast)->get($this->model, 'money', $json, []);
4749

4850
$this->assertEquals(
4951
new Money('1000', new Currency('USD')),
@@ -55,17 +57,15 @@ public function testItWillNotSetNonMoneyAsJson()
5557
{
5658
$this->expectException(UnexpectedValueException::class);
5759

58-
$model = $this->getMockBuilder(Model::class)->getMock();
5960

60-
(new MoneyCast)->set($model, 'money', 1000, []);
61+
(new MoneyCast)->set($this->model, 'money', 1000, []);
6162
}
6263

6364
public function testItSetsMoneyAsJson()
6465
{
65-
$model = $this->getMockBuilder(Model::class)->getMock();
6666
$money = new Money('1200', Currency::USD());
6767

68-
$value = (new MoneyCast)->set($model, 'money', $money, []);
68+
$value = (new MoneyCast)->set($this->model, 'money', $money, []);
6969

7070
$this->assertSame(
7171
'{"amount":1200,"currency":"USD"}',

0 commit comments

Comments
 (0)