diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index b24dced..6cbf095 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 215a586..10e9485 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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: | diff --git a/composer.json b/composer.json index ea82b36..6c6d3ad 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/tests/Casts/CurrencyCastTest.php b/tests/Casts/CurrencyCastTest.php index 246c2dc..69e4a16 100644 --- a/tests/Casts/CurrencyCastTest.php +++ b/tests/Casts/CurrencyCastTest.php @@ -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); } diff --git a/tests/Casts/MoneyCastTest.php b/tests/Casts/MoneyCastTest.php index 523132b..d16e946 100644 --- a/tests/Casts/MoneyCastTest.php +++ b/tests/Casts/MoneyCastTest.php @@ -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')), @@ -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"}',