Skip to content

Commit

Permalink
laravel 11 upgrade (#6)
Browse files Browse the repository at this point in the history
* remove deprecated phpunit --verbose option
* drop support for laravel <11
* + php 8.3
  • Loading branch information
reliq authored Mar 16, 2024
1 parent 771bd10 commit ed8f464
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 96 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
fail-fast: false
max-parallel: 10
matrix:
laravel-version: ['^8.0', '^9.0', '^10.0']
laravel-version: ['^11.0']
preference: ['stable']
experimental: [false]
php-version: ['8.2']
php-version: ['8.2', '8.3']
exclude:
- laravel-version: ^10.0
php-version: 8.0
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
],
"require": {
"php": "^8.2",
"illuminate/support": "^8.0 || ^9.0 || ^10.0",
"monolog/monolog": "1.24 - 3",
"illuminate/support": "^11.0",
"monolog/monolog": "^3.5",
"ext-json": "*",
"spatie/laravel-sitemap": "^6.0",
"spatie/laravel-sitemap": "^7.0",
"anhskohbo/no-captcha": "^3.1||dev-master"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
"phpunit/phpunit": "^9.3",
"phpunit/phpunit": "^11.0",
"phpro/grumphp": "^2.0",
"phpspec/prophecy-phpunit": "^2.0",
"orchestra/testbench": "6 - 8",
"orchestra/testbench": "^9.0",
"laravel/pint": "^1.13",
"yieldstudio/grumphp-laravel-pint": "^1.0"
},
Expand All @@ -50,8 +50,8 @@
},
"scripts": {
"test": "phpunit",
"test:ci": "phpunit --verbose --coverage-clover=./build/coverage.xml",
"test:unit": "phpunit --testsuite=Unit --verbose --coverage-clover=./build/coverage.xml"
"test:ci": "phpunit --coverage-clover=./build/coverage.xml",
"test:unit": "phpunit --testsuite=Unit --coverage-clover=./build/coverage.xml"
},
"config": {
"allow-plugins": {
Expand Down
15 changes: 7 additions & 8 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" beStrictAboutTestsThatDoNotTestAnything="true" bootstrap="vendor/autoload.php" cacheResult="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" verbose="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src/</directory>
</include>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" beStrictAboutTestsThatDoNotTestAnything="true" bootstrap="vendor/autoload.php" cacheResult="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<report>
<clover outputFile="build/coverage.xml"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<testsuites>
<testsuite name="Tests">
<directory>tests</directory>
</testsuite>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
Expand All @@ -25,4 +19,9 @@
<env name="CACHE_DRIVER" value="array"/>
</php>
<logging/>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>
16 changes: 6 additions & 10 deletions tests/Unit/Helper/HtmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
namespace ReliqArts\Tests\Unit\Helper;

use Exception;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use ReliqArts\Contract\HtmlHelper;
use ReliqArts\Helper\Html;
use ReliqArts\Tests\TestCase;

/**
* Class HtmlTest.
*
* @coversDefaultClass \ReliqArts\Helper\Html
*
* @internal
*/
#[CoversClass(Html::class)]
final class HtmlTest extends TestCase
{
private HtmlHelper $subject;
Expand All @@ -28,18 +27,15 @@ protected function setUp(): void
}

/**
* @covers ::stripTags
*
* @dataProvider stripTagsDataProvider
*
* @throws Exception
*/
public function testStripTags(string $html, string $expectedResult, string $allowedTags = null): void
#[DataProvider('stripTagsDataProvider')]
public function testStripTags(string $html, string $expectedResult, ?string $allowedTags = null): void
{
self::assertSame($expectedResult, $this->subject->stripTags($html, $allowedTags));
}

public function stripTagsDataProvider(): array
public static function stripTagsDataProvider(): array
{
return [
'simple' => [
Expand Down
6 changes: 2 additions & 4 deletions tests/Unit/ResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
namespace ReliqArts\Tests\Unit;

use Exception;
use PHPUnit\Framework\Attributes\CoversClass;
use ReliqArts\Result;
use ReliqArts\Tests\TestCase;

/**
* Class ResultTest.
*
* @coversDefaultClass \ReliqArts\Result
*
* @internal
*/
#[CoversClass(Result::class)]
final class ResultTest extends TestCase
{
private Result $subject;
Expand Down
15 changes: 2 additions & 13 deletions tests/Unit/Service/ConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Exception;
use Illuminate\Contracts\Config\Repository;
use PHPUnit\Framework\Attributes\CoversClass;
use Prophecy\Exception\Doubler\DoubleException;
use Prophecy\Exception\Doubler\InterfaceNotFoundException;
use Prophecy\Exception\Prophecy\ObjectProphecyException;
Expand All @@ -14,13 +15,7 @@
use ReliqArts\Service\ConfigProvider;
use ReliqArts\Tests\TestCase;

/**
* Class ConfigProviderTest.
*
* @coversDefaultClass \ReliqArts\Service\ConfigProvider
*
* @internal
*/
#[CoversClass(ConfigProvider::class)]
final class ConfigProviderTest extends TestCase
{
use ProphecyTrait;
Expand All @@ -46,9 +41,6 @@ protected function setUp(): void
}

/**
* @covers ::__construct
* @covers ::get
*
* @throws Exception
*/
public function testGet(): void
Expand All @@ -69,9 +61,6 @@ public function testGet(): void
}

/**
* @covers ::__construct
* @covers ::get
*
* @throws Exception
*/
public function testGetWhenKeyIsEmpty(): void
Expand Down
45 changes: 21 additions & 24 deletions tests/Unit/Service/DescendantsFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,20 @@

use Exception;
use Illuminate\Support\Collection;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use ReliqArts\Contract\DescendantsFinder as DescendantsFinderContract;
use ReliqArts\Service\DescendantsFinder;
use ReliqArts\Tests\TestCase;
use stdClass;

/**
* @coversDefaultClass \ReliqArts\Service\DescendantsFinder
*/
#[CoversClass(DescendantsFinder::class)]
final class DescendantsFinderTest extends TestCase
{
/**
* @covers ::findDescendantsInCollection
*
* @dataProvider dataProvider
*
* @throws Exception
*/
#[DataProvider('dataProvider')]
public function testFindDescendants(
int $parentId,
Collection $collection,
Expand All @@ -44,22 +41,22 @@ public function testFindDescendants(
}
}

public function dataProvider(): array
public static function dataProvider(): array
{
$item1 = $this->getItem(1);
$item2 = $this->getItem(2, 1);
$item3 = $this->getItem(3, 1);
$item4 = $this->getItem(4);
$item5 = $this->getItem(5, 4);
$item6 = $this->getItem(6, 7);
$item7 = $this->getItem(7, 5);
$item8 = $this->getItem(8, 7);
$item9 = $this->getItem(9, 8, 'foo');
$item10 = $this->getItem(10, 9, 'foo');
$item11 = $this->getItem(11, 8, 'foo');
$item12 = $this->getItem(12, 12);
$item13 = $this->getItem(13, 12);
$item14 = $this->getItem(14, 14);
$item1 = self::getItem(1);
$item2 = self::getItem(2, 1);
$item3 = self::getItem(3, 1);
$item4 = self::getItem(4);
$item5 = self::getItem(5, 4);
$item6 = self::getItem(6, 7);
$item7 = self::getItem(7, 5);
$item8 = self::getItem(8, 7);
$item9 = self::getItem(9, 8, 'foo');
$item10 = self::getItem(10, 9, 'foo');
$item11 = self::getItem(11, 8, 'foo');
$item12 = self::getItem(12, 12);
$item13 = self::getItem(13, 12);
$item14 = self::getItem(14, 14);

$collection = collect(
[
Expand Down Expand Up @@ -129,9 +126,9 @@ public function dataProvider(): array
];
}

private function getItem(
private static function getItem(
int $id,
int $parentId = null,
?int $parentId = null,
string $parentIdAttributeName = DescendantsFinderContract::DEFAULT_PARENT_ID_ATTRIBUTE
): stdClass {
$item = new stdClass();
Expand Down
30 changes: 2 additions & 28 deletions tests/Unit/Service/VersionProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use Exception;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use PHPUnit\Framework\Attributes\CoversClass;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Prophecy\Prophecy\ObjectProphecy;
Expand All @@ -20,12 +21,9 @@
use ReliqArts\Tests\TestCase;

/**
* Class VersionProviderTest.
*
* @coversDefaultClass \ReliqArts\Service\VersionProvider
*
* @internal
*/
#[CoversClass(VersionProvider::class)]
final class VersionProviderTest extends TestCase
{
use ProphecyTrait;
Expand Down Expand Up @@ -71,10 +69,6 @@ static function ($key) {
}

/**
* @covers ::__construct
* @covers ::cleanText
* @covers ::getBuildNumber
*
* @throws Exception
*/
public function testGetBuildNumber(): void
Expand All @@ -94,11 +88,6 @@ public function testGetBuildNumber(): void
}

/**
* @covers ::__construct
* @covers ::cleanText
* @covers ::getBuildNumber
* @covers ::logWarning
*
* @throws Exception
*/
public function testGetBuildNumberWhenBuildNumberFileDoesNotExist(): void
Expand Down Expand Up @@ -130,10 +119,6 @@ static function ($message) use ($buildFile) {
}

/**
* @covers ::__construct
* @covers ::cleanText
* @covers ::getVersionNumber
*
* @throws Exception
*/
public function testGetVersionNumber(): void
Expand All @@ -153,11 +138,6 @@ public function testGetVersionNumber(): void
}

/**
* @covers ::__construct
* @covers ::cleanText
* @covers ::getVersionNumber
* @covers ::logWarning
*
* @throws Exception
*/
public function testGetVersionNumberWhenVersionNumberFileDoesNotExist(): void
Expand Down Expand Up @@ -189,12 +169,6 @@ static function ($message) use ($versionFile) {
}

/**
* @covers ::__construct
* @covers ::cleanText
* @covers ::getBuildNumber
* @covers ::getVersion
* @covers ::getVersionNumber
*
* @throws Exception
*/
public function testGetVersion(): void
Expand Down

0 comments on commit ed8f464

Please sign in to comment.