Skip to content

Commit

Permalink
Merge pull request #98 from ariaieboy/l11
Browse files Browse the repository at this point in the history
Laravel 11 support
  • Loading branch information
denisdulici authored Mar 19, 2024
2 parents 3e3a432 + 1ce0c41 commit 36f4371
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: psalm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,36 @@ jobs:

strategy:
matrix:
php: ['8.0', '8.1', '8.2']
laravel: [9.*, 10.*]
php: ['8.0', '8.1', '8.2', '8.3']
laravel: [9.*, 10.*, 11.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 9.*
testbench: 7.*
- laravel: 10.*
testbench: 8.*
- laravel: 11.*
testbench: 9.*
exclude:
- laravel: 9.*
php: 8.3
- laravel: 10.*
php: 8.0
- laravel: 11.*
php: 8.0
- laravel: 11.*
php: 8.1

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

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

- name: Install dependencies
run: |
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
],
"require": {
"php": "^8.0",
"illuminate/contracts": "^9.0|^10.0",
"illuminate/support": "^9.0|^10.0",
"illuminate/validation": "^9.0|^10.0",
"illuminate/view": "^9.0|^10.0",
"illuminate/contracts": "^9.0|^10.0|^11.0",
"illuminate/support": "^9.0|^10.0|^11.0",
"illuminate/validation": "^9.0|^10.0|^11.0",
"illuminate/view": "^9.0|^10.0|^11.0",
"vlucas/phpdotenv": "^5.4.1"
},
"require-dev": {
"phpunit/phpunit": "^9.5|^10.0",
"orchestra/testbench": "^7.4|^8.0",
"vimeo/psalm": "^4.23"
"phpunit/phpunit": "^9.5|^10.0|^11.0",
"orchestra/testbench": "^7.4|^8.0|^9.0",
"vimeo/psalm": "^4.23|^5.1"
},
"autoload": {
"psr-4": {
Expand Down
18 changes: 9 additions & 9 deletions tests/Casts/CurrencyCastTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,38 @@

class CurrencyCastTest extends TestCase
{
protected Model $model;
protected function setUp():void
{
$this->model = $model = $this->getMockBuilder(Model::class)->disableOriginalConstructor()->getMock();
}
public function testItWillNotGetCurrencyFromNonStrings()
{
$this->expectException(UnexpectedValueException::class);

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

(new CurrencyCast)->get($model, 'currency', 1, []);
(new CurrencyCast)->get($this->model, 'currency', 1, []);
}

public function testItWillNotSetCurrencyFromNonCurrencies()
{
$this->expectException(UnexpectedValueException::class);

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

(new CurrencyCast)->set($model, 'currency', 'USD', []);
(new CurrencyCast)->set($this->model, 'currency', 'USD', []);
}

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

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

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

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

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

$this->assertSame('USD', $value);
}
Expand Down
24 changes: 12 additions & 12 deletions tests/Casts/MoneyCastTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,39 +11,41 @@

class MoneyCastTest extends TestCase
{
protected Model $model;
protected function setUp():void
{
$this->model = $model = $this->getMockBuilder(Model::class)->disableOriginalConstructor()->getMock();
}

public function testItWillNotGetMoneyFromNonString()
{
$this->expectException(UnexpectedValueException::class);

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

(new MoneyCast)->get($model, 'money', [], []);
(new MoneyCast)->get($this->model, 'money', [], []);
}

public function testItWillNotGetMoneyFromNonJson()
{
$this->expectException(UnexpectedValueException::class);

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

(new MoneyCast)->get($model, 'money', 'testing', []);
(new MoneyCast)->get($this->model, 'money', 'testing', []);
}

public function testItWillNotGetMoneyFromIllFormedJson()
{
$this->expectException(UnexpectedValueException::class);

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

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

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

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

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

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

(new MoneyCast)->set($model, 'money', 1000, []);
(new MoneyCast)->set($this->model, 'money', 1000, []);
}

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

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

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

0 comments on commit 36f4371

Please sign in to comment.